Example #1
0
        /// <summary>
        /// Submit an executable command buffer with optional wait and signal semaphores, and an optional fence to be signaled when the commands have been completed.
        /// </summary>
        /// <param name="queue">Queue.</param>
        /// <param name="wait">Wait.</param>
        /// <param name="signal">Signal.</param>
        /// <param name="fence">Fence.</param>
        public void Submit(VkQueue queue, VkSemaphore wait = default, VkSemaphore signal = default, Fence fence = null)
        {
            VkSubmitInfo submit_info = VkSubmitInfo.New();

            IntPtr dstStageMask = Marshal.AllocHGlobal(sizeof(uint));

            Marshal.WriteInt32(dstStageMask, (int)VkPipelineStageFlags.ColorAttachmentOutput);

            using (PinnedObjects pctx = new PinnedObjects()) {
                submit_info.pWaitDstStageMask = dstStageMask;
                if (signal != VkSemaphore.Null)
                {
                    submit_info.signalSemaphoreCount = 1;
                    submit_info.pSignalSemaphores    = signal.Pin(pctx);
                }
                if (wait != VkSemaphore.Null)
                {
                    submit_info.waitSemaphoreCount = 1;
                    submit_info.pWaitSemaphores    = wait.Pin(pctx);
                }

                submit_info.commandBufferCount = 1;
                submit_info.pCommandBuffers    = handle.Pin(pctx);

                Utils.CheckResult(vkQueueSubmit(queue, 1, ref submit_info, fence));
            }
            Marshal.FreeHGlobal(dstStageMask);
        }
Example #2
0
        public void Present(SwapChain swapChain, VkSemaphore wait)
        {
            VkPresentInfoKHR present = VkPresentInfoKHR.New();

            uint           idx = swapChain.currentImageIndex;
            VkSwapchainKHR sc  = swapChain.handle;

            present.swapchainCount     = 1;
            present.pSwapchains        = sc.Pin();
            present.waitSemaphoreCount = 1;
            present.pWaitSemaphores    = wait.Pin();
            present.pImageIndices      = idx.Pin();

            Utils.CheckResult(vkQueuePresentKHR(handle, ref present));

            sc.Unpin();
            wait.Unpin();
            idx.Unpin();
        }