public Result QueuePresentKHR(MgPresentInfoKHR pPresentInfo) { if (pPresentInfo == null) { throw new ArgumentNullException(nameof(pPresentInfo)); } var attachedItems = new List <IntPtr>(); try { uint waitSemaphoreCount; var pWaitSemaphores = ExtractSemaphores(attachedItems, pPresentInfo.WaitSemaphores, out waitSemaphoreCount); IntPtr pSwapchains; IntPtr pImageIndices; uint swapchainCount = ExtractSwapchains(attachedItems, pPresentInfo.Images, out pSwapchains, out pImageIndices); var pResults = ExtractResults(attachedItems, pPresentInfo.Results); var presentInfo = new VkPresentInfoKHR { sType = VkStructureType.StructureTypePresentInfoKhr, pNext = IntPtr.Zero, waitSemaphoreCount = waitSemaphoreCount, pWaitSemaphores = pWaitSemaphores, swapchainCount = swapchainCount, pSwapchains = pSwapchains, pImageIndices = pImageIndices, pResults = pResults, }; var result = Interops.vkQueuePresentKHR(Handle, ref presentInfo); // MUST ABLE TO RETURN if (pResults != IntPtr.Zero) { var stride = Marshal.SizeOf(typeof(Result)); var swapChains = new Result[swapchainCount]; var offset = 0; for (var i = 0; i < swapchainCount; ++i) { var src = IntPtr.Add(pResults, offset); swapChains[i] = (Magnesium.Result)Marshal.PtrToStructure(src, typeof(Magnesium.Result)); offset += stride; } pPresentInfo.Results = swapChains; } return(result); } finally { foreach (var item in attachedItems) { Marshal.FreeHGlobal(item); } } }
internal extern static Result vkQueuePresentKHR(IntPtr queue, ref VkPresentInfoKHR pPresentInfo);