/// <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> public static unsafe SharpVk.Multivendor.DebugReportCallback CreateDebugReportCallback(this SharpVk.Instance extendedHandle, SharpVk.Multivendor.DebugReportCallbackDelegate callback, SharpVk.Multivendor.DebugReportFlags?flags = default(SharpVk.Multivendor.DebugReportFlags?), IntPtr?userData = default(IntPtr?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Multivendor.DebugReportCallback result = default(SharpVk.Multivendor.DebugReportCallback); CommandCache commandCache = default(CommandCache); SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *); void *nextPointer = default(void *); SharpVk.Interop.AllocationCallbacks * marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Multivendor.DebugReportCallback marshalledCallback = default(SharpVk.Interop.Multivendor.DebugReportCallback); commandCache = extendedHandle.commandCache; marshalledCreateInfo = (SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo>()); marshalledCreateInfo->SType = StructureType.DebugReportCallbackCreateInfo; marshalledCreateInfo->Next = nextPointer; if (flags != null) { marshalledCreateInfo->Flags = flags.Value; } else { marshalledCreateInfo->Flags = default(SharpVk.Multivendor.DebugReportFlags); } marshalledCreateInfo->Callback = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(callback); if (userData != null) { marshalledCreateInfo->UserData = userData.Value.ToPointer(); } else { marshalledCreateInfo->UserData = default(void *); } if (allocator != null) { marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>()); allocator.Value.MarshalTo(marshalledAllocator); } else { marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); } SharpVk.Interop.Multivendor.VkInstanceCreateDebugReportCallbackDelegate commandDelegate = commandCache.Cache.vkCreateDebugReportCallbackEXT; Result methodResult = commandDelegate(extendedHandle.handle, marshalledCreateInfo, marshalledAllocator, &marshalledCallback); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } result = new SharpVk.Multivendor.DebugReportCallback(extendedHandle, marshalledCallback); return(result); } finally { Interop.HeapUtil.FreeAll(); } }
internal DebugReportCallback(SharpVk.Instance parent, SharpVk.Interop.Multivendor.DebugReportCallback handle) { this.handle = handle; this.parent = parent; this.commandCache = parent.commandCache; }