From 2f5a3705ab8cf56ba37b79835a05d9da23c3db3d Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sat, 13 Aug 2016 18:47:11 +0200 Subject: [PATCH] Synchronization semaphore for offscreen pass --- debugmarker/debugmarker.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/debugmarker/debugmarker.cpp b/debugmarker/debugmarker.cpp index 5c6bd6e3..c9759aeb 100644 --- a/debugmarker/debugmarker.cpp +++ b/debugmarker/debugmarker.cpp @@ -1074,18 +1074,28 @@ public: { VulkanExampleBase::prepareFrame(); - std::vector submitCmdBuffers; - - // Submit offscreen rendering command buffer - // todo : use event to ensure that offscreen result is finished bfore render command buffer is started + // Offscreen rendering if (glow) { - submitCmdBuffers.push_back(offscreenPass.commandBuffer); - } - submitCmdBuffers.push_back(drawCmdBuffers[currentBuffer]); + // Wait for swap chain presentation to finish + submitInfo.pWaitSemaphores = &semaphores.presentComplete; + // Signal ready with offscreen semaphore + submitInfo.pSignalSemaphores = &offscreenPass.semaphore; - submitInfo.commandBufferCount = submitCmdBuffers.size(); - submitInfo.pCommandBuffers = submitCmdBuffers.data(); + // Submit work + submitInfo.commandBufferCount = 1; + submitInfo.pCommandBuffers = &offscreenPass.commandBuffer; + VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); + } + + // Scene rendering + // Wait for offscreen semaphore + submitInfo.pWaitSemaphores = &offscreenPass.semaphore; + // Signal ready with render complete semaphpre + submitInfo.pSignalSemaphores = &semaphores.renderComplete; + + // Submit work + submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); VulkanExampleBase::submitFrame();