Additional semaphore to synchronize offscreen and final render (Refs #70)

This commit is contained in:
saschawillems 2016-06-05 18:01:53 +02:00
parent 046d0f2c42
commit 1b32af6997

View file

@ -1185,18 +1185,38 @@ public:
{ {
VulkanExampleBase::prepareFrame(); VulkanExampleBase::prepareFrame();
// Gather command buffers to be sumitted to the queue // The scene render command buffer has to wait for the offscreen
std::vector<VkCommandBuffer> submitCmdBuffers; // rendering to be finished before we can use the framebuffer
// Submit offscreen rendering command buffer // color image for sampling during final rendering
// todo : use event to ensure that offscreen result is finished bfore render command buffer is started // To ensure this we use a dedicated offscreen synchronization
if (bloom) // semaphore that will be signaled when offscreen renderin
{ // has been finished
submitCmdBuffers.push_back(offScreenCmdBuffer); // This is necessary as an implementation may start both
} // command buffers at the same time, there is no guarantee
submitCmdBuffers.push_back(drawCmdBuffers[currentBuffer]); // that command buffers will be executed in the order they
submitInfo.commandBufferCount = submitCmdBuffers.size(); // have been submitted by the application
submitInfo.pCommandBuffers = submitCmdBuffers.data();
// Offscreen rendering
// Wait for swap chain presentation to finish
submitInfo.pWaitSemaphores = &semaphores.presentComplete;
// Signal ready with offscreen semaphore
submitInfo.pSignalSemaphores = &offscreenSemaphore;
// Submit work
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &offScreenCmdBuffer;
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
// Scene rendering
// Wait for offscreen semaphore
submitInfo.pWaitSemaphores = &offscreenSemaphore;
// 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)); VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
VulkanExampleBase::submitFrame(); VulkanExampleBase::submitFrame();