Example #1
0
        public VkResult Submit(int submitCount, VkSubmitInfo[] pSubmits, VkFence fence)
        {
            for (int i = 0; i < submitCount; i++)
            {
                var submit = pSubmits[i];

                if (submit.waitSemaphoreCount > 0)
                {
                    SoftwareSemaphore.WaitAll(submit.waitSemaphoreCount, submit.pWaitSemaphores);
                }

                for (int cmdIndex = 0; cmdIndex < submit.commandBufferCount; cmdIndex++)
                {
                    var cmdBuffer = (SoftwareCommandBuffer)submit.pCommandBuffers[cmdIndex];
                    cmdBuffer.Execute();
                }

                if (submit.signalSemaphoreCount > 0)
                {
                    SoftwareSemaphore.SignalAll(submit.signalSemaphoreCount, submit.pSignalSemaphores);
                }
            }

            ((SoftwareFence)fence)?.Signal();

            return(VkResult.VK_SUCCESS);
        }
Example #2
0
        public VkResult Present(VkPresentInfoKHR pPresentInfo)
        {
            if (pPresentInfo.waitSemaphoreCount > 0)
            {
                SoftwareSemaphore.WaitAll(pPresentInfo.waitSemaphoreCount, pPresentInfo.pWaitSemaphores);
            }

            if (pPresentInfo.pResults == null)
            {
                pPresentInfo.pResults = new VkResult[] { }
            }
            ;

            while (pPresentInfo.pResults.Length < pPresentInfo.swapchainCount)
            {
                pPresentInfo.pResults = new VkResult[] { VkResult.VK_SUCCESS }
            }
            ;

            VkResult result = VkResult.VK_SUCCESS;

            for (int i = 0; i < pPresentInfo.swapchainCount; i++)
            {
                int      imageIndex = pPresentInfo.pImageIndices[i];
                var      swapChain  = (SoftwareSwapchain)pPresentInfo.pSwapchains[i];
                VkResult subResult  = swapChain.PresentImage(imageIndex);
                pPresentInfo.pResults[i] = subResult;
                if (subResult != VkResult.VK_SUCCESS)
                {
                    result = subResult;
                }
            }

            return(result);
        }
Example #3
0
        public VkResult AcquireNextImage(long timeout, SoftwareSemaphore semaphore, SoftwareFence fence, out int pImageIndex)
        {
            // TODO: SoftwareSwapchain.AcquireNextImage()

            pImageIndex      = m_NextImageIndex;
            m_NextImageIndex = (m_NextImageIndex + 1) % m_Images.Count;

            semaphore?.Signal();
            fence?.Signal();

            return(VkResult.VK_SUCCESS);
        }
Example #4
0
 public static VkResult Create(SoftwareDevice device, VkSemaphoreCreateInfo semaphoreCreateInfo, out VkSemaphore semaphore)
 {
     semaphore = new SoftwareSemaphore(device, semaphoreCreateInfo);
     return(VkResult.VK_SUCCESS);
 }
Example #5
0
 public override VkResult CreateSemaphore(VkSemaphoreCreateInfo semaphoreCreateInfo, out VkSemaphore semaphore)
 {
     return(SoftwareSemaphore.Create(this, semaphoreCreateInfo, out semaphore));
 }