You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is mainly an issue for DebugUtilsMessengerCallbackData, which contains DebugUtilsObjectNameInfo[], and thus is transitively not unmarshalled for use in CreateDebugUtilsMessenger, I'm currently doing this:
usingSystem;namespaceSharpVk.Multivendor{publicpartialclassDebugReportDelegate:IDisposable{privatereadonlySharpVk.Multivendor.DebugReportCallbackcallback_;privatereadonlySystem.Runtime.InteropServices.GCHandlegch_;internalDebugReportDelegate(System.Runtime.InteropServices.GCHandlegch,SharpVk.Multivendor.DebugReportCallbackcallback){callback_=callback;gch_=gch;}publicvoidDispose(){callback_.Dispose();gch_.Free();}}publicinterfaceIDebugReportDelegate{boolDebugReportDelegate(SharpVk.Multivendor.DebugReportFlagsflags,SharpVk.Multivendor.DebugReportObjectTypeobjectType,ulong@object,HostSizelocation,intmessageCode,stringpLayerPrefix,stringpMessage);}publicpartialclassDebugUtilsDelegate:IDisposable{privatereadonlySharpVk.Multivendor.DebugUtilsMessengercallback_;privatereadonlySystem.Runtime.InteropServices.GCHandlegch_;internalDebugUtilsDelegate(System.Runtime.InteropServices.GCHandlegch,SharpVk.Multivendor.DebugUtilsMessengercallback){callback_=callback;gch_=gch;}publicvoidDispose(){callback_.Dispose();gch_.Free();}}publicinterfaceIDebugUtilsDelegate{boolDebugUtilsDelegate(SharpVk.Multivendor.DebugUtilsMessageSeverityFlagsmessageSeverity,SharpVk.Multivendor.DebugUtilsMessageTypeFlagsmessageTypes,SharpVk.Multivendor.DebugUtilsMessengerCallbackDatapCallbackDatas);}/// <summary>/// /// </summary>publicstaticclassHLInstanceExtensions{/// <summary>/// Create a debug report callback object./// </summary>/// <param name="extendedHandle">/// The Instance handle to extend./// </param>/// <param name="flags">/// flags indicate which event(s) will cause this callback to be/// called. Flags are interpreted as bitmasks and multiple may be set./// Bits which can be set include: + --/// </param>/// <param name="allocator">/// An optional AllocationCallbacks instance that controls host memory/// allocation./// </param>publicstaticSharpVk.Multivendor.DebugReportDelegateCreateDebugReportDelegate(thisSharpVk.InstanceextendedHandle,SharpVk.Multivendor.IDebugReportDelegatecallback,SharpVk.Multivendor.DebugReportFlags?flags=default(SharpVk.Multivendor.DebugReportFlags?),SharpVk.AllocationCallbacks?allocator=default(SharpVk.AllocationCallbacks?)){System.Runtime.InteropServices.GCHandlegch=System.Runtime.InteropServices.GCHandle.Alloc(callback);try{SharpVk.Multivendor.DebugReportCallbackresult=extendedHandle.CreateDebugReportCallback(DebugReportDelegate,flags,System.Runtime.InteropServices.GCHandle.ToIntPtr(gch),allocator);returnnewSharpVk.Multivendor.DebugReportDelegate(gch,result);}catch{gch.Free();throw;}}privatestaticreadonlySharpVk.Multivendor.DebugReportCallbackDelegateDebugReportDelegate=DebugReport;privatestaticBool32DebugReport(SharpVk.Multivendor.DebugReportFlagsflags,SharpVk.Multivendor.DebugReportObjectTypeobjectType,ulong@object,HostSizelocation,intmessageCode,stringpLayerPrefix,stringpMessage,IntPtrpUserData){if(pUserData==IntPtr.Zero){returnfalse;}System.Runtime.InteropServices.GCHandlegch=System.Runtime.InteropServices.GCHandle.FromIntPtr(pUserData);IDebugReportDelegateidrd=(IDebugReportDelegate)gch.Target;if(idrd==null){returnfalse;}returnidrd.DebugReportDelegate(flags,objectType,@object,location,messageCode,pLayerPrefix,pMessage);}/// <summary>/// Create a debug utils messenger object./// </summary>/// <param name="extendedHandle">/// The Instance handle to extend./// </param>/// <param name="flags">/// flags indicate which event(s) will cause this callback to be/// called. Flags are interpreted as bitmasks and multiple may be set./// Bits which can be set include: + --/// </param>/// <param name="allocator">/// An optional AllocationCallbacks instance that controls host memory/// allocation./// </param>publicstaticSharpVk.Multivendor.DebugUtilsDelegateCreateDebugUtilsDelegate(thisSharpVk.InstanceextendedHandle,SharpVk.Multivendor.DebugUtilsMessageSeverityFlagsmessageSeverity,SharpVk.Multivendor.DebugUtilsMessageTypeFlagsmessageType,SharpVk.Multivendor.IDebugUtilsDelegatecallback,SharpVk.Multivendor.DebugUtilsMessengerCreateFlags?flags=default(SharpVk.Multivendor.DebugUtilsMessengerCreateFlags?),SharpVk.AllocationCallbacks?allocator=default(SharpVk.AllocationCallbacks?)){System.Runtime.InteropServices.GCHandlegch=System.Runtime.InteropServices.GCHandle.Alloc(callback);try{SharpVk.Multivendor.DebugUtilsMessengerresult=extendedHandle.CreateDebugUtilsMessenger(messageSeverity,messageType,DebugUtilsDelegate,flags,System.Runtime.InteropServices.GCHandle.ToIntPtr(gch),allocator);returnnewSharpVk.Multivendor.DebugUtilsDelegate(gch,result);}catch{gch.Free();throw;}}privatestaticreadonlySharpVk.Multivendor.DebugUtilsMessengerCallbackDelegateDebugUtilsDelegate=DebugUtils;privateunsafestaticSharpVk.Multivendor.DebugUtilsLabelMarshalFrom(SharpVk.Interop.Multivendor.DebugUtilsLabel*pointer){SharpVk.Multivendor.DebugUtilsLabelresult=default(SharpVk.Multivendor.DebugUtilsLabel);result.LabelName=pointer->LabelName==null?null:System.Runtime.InteropServices.Marshal.PtrToStringAnsi(newIntPtr(pointer->LabelName));result.Color=(pointer->Color[0],pointer->Color[1],pointer->Color[2],pointer->Color[3]);returnresult;}privateunsafestaticSharpVk.Multivendor.DebugUtilsObjectNameInfoMarshalFrom(SharpVk.Interop.Multivendor.DebugUtilsObjectNameInfo*pointer){SharpVk.Multivendor.DebugUtilsObjectNameInforesult=default(SharpVk.Multivendor.DebugUtilsObjectNameInfo);result.ObjectType=pointer->ObjectType;result.ObjectHandle=pointer->ObjectHandle;result.ObjectName=pointer->ObjectName==null?null:System.Runtime.InteropServices.Marshal.PtrToStringAnsi(newIntPtr(pointer->ObjectName));returnresult;}privateunsafestaticSharpVk.Multivendor.DebugUtilsMessengerCallbackDataMarshalFrom(SharpVk.Interop.Multivendor.DebugUtilsMessengerCallbackData*pointer){SharpVk.Multivendor.DebugUtilsMessengerCallbackDataresult=default(SharpVk.Multivendor.DebugUtilsMessengerCallbackData);result.Flags=pointer->Flags;result.MessageIdName=pointer->MessageIdName==null?null:System.Runtime.InteropServices.Marshal.PtrToStringAnsi(newIntPtr(pointer->MessageIdName));result.MessageIdNumber=pointer->MessageIdNumber;result.Message=pointer->Message==null?null:System.Runtime.InteropServices.Marshal.PtrToStringAnsi(newIntPtr(pointer->Message));if(pointer->QueueLabels==null){result.QueueLabels=null;}else{result.QueueLabels=newDebugUtilsLabel[pointer->QueueLabelCount];for(intindex=0;index<(uint)(result.QueueLabels.Length);index++){result.QueueLabels[index]=MarshalFrom(&pointer->QueueLabels[index]);}}if(pointer->CommandBufLabels==null){result.CommandBufLabels=null;}else{result.CommandBufLabels=newDebugUtilsLabel[pointer->CommandBufLabelCount];for(intindex=0;index<(uint)(result.CommandBufLabels.Length);index++){result.CommandBufLabels[index]=MarshalFrom(&pointer->CommandBufLabels[index]);}}if(pointer->Objects==null){result.Objects=null;}else{result.Objects=newDebugUtilsObjectNameInfo[pointer->ObjectCount];for(intindex=0;index<(uint)(result.Objects.Length);index++){result.Objects[index]=MarshalFrom(&pointer->Objects[index]);}}returnresult;}privatestaticunsafeBool32DebugUtils(SharpVk.Multivendor.DebugUtilsMessageSeverityFlagsmessageSeverity,SharpVk.Multivendor.DebugUtilsMessageTypeFlagsmessageTypes,IntPtrpCallbackData,IntPtrpUserData){if(pUserData==IntPtr.Zero){returnfalse;}System.Runtime.InteropServices.GCHandlegch=System.Runtime.InteropServices.GCHandle.FromIntPtr(pUserData);IDebugUtilsDelegateidrd=(IDebugUtilsDelegate)gch.Target;if(idrd==null){returnfalse;}SharpVk.Multivendor.DebugUtilsMessengerCallbackDatauserData=MarshalFrom((SharpVk.Interop.Multivendor.DebugUtilsMessengerCallbackData*)pCallbackData.ToPointer());returnidrd.DebugUtilsDelegate(messageSeverity,messageTypes,userData);}}}
I tried to match the generated code style as much as possible, but without being able to use any of the internal HeapUtil methods.
The text was updated successfully, but these errors were encountered:
The filter on "...Info" structs was likely to identify types used purely for input (e.g. CreateInfo types) which are/were not consistently identified in vk.xml; there's no handling for this case of structs as callback parameters. The current implementation of callbacks needs several improvements in any case, but the Debug Utils use case raises the priority a little.
Unless I can find a more intelligent filter to handle the input Info structs case, I'll find a subfilter for Info structs that are passed back out from the API in callback delegates.
This is mainly an issue for
DebugUtilsMessengerCallbackData
, which containsDebugUtilsObjectNameInfo[]
, and thus is transitively not unmarshalled for use inCreateDebugUtilsMessenger
, I'm currently doing this:I tried to match the generated code style as much as possible, but without being able to use any of the internal
HeapUtil
methods.The text was updated successfully, but these errors were encountered: