Submit post present barrier after acquiring next swap chain image (old spot was wrong due to missing image ownership)
This commit is contained in:
parent
8107a0ace8
commit
30fc2ae77b
1 changed files with 33 additions and 36 deletions
|
|
@ -181,7 +181,7 @@ public:
|
||||||
prePresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
prePresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
prePresentBarrier.pNext = NULL;
|
prePresentBarrier.pNext = NULL;
|
||||||
prePresentBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
prePresentBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
prePresentBarrier.dstAccessMask = 0;
|
prePresentBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||||
prePresentBarrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
prePresentBarrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
prePresentBarrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
prePresentBarrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
prePresentBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
prePresentBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||||
|
|
@ -193,7 +193,7 @@ public:
|
||||||
vkCmdPipelineBarrier(
|
vkCmdPipelineBarrier(
|
||||||
drawCmdBuffers[i],
|
drawCmdBuffers[i],
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||||
VK_FLAGS_NONE,
|
VK_FLAGS_NONE,
|
||||||
0, nullptr,
|
0, nullptr,
|
||||||
0, nullptr,
|
0, nullptr,
|
||||||
|
|
@ -211,43 +211,10 @@ public:
|
||||||
err = swapChain.acquireNextImage(semaphores.presentComplete, ¤tBuffer);
|
err = swapChain.acquireNextImage(semaphores.presentComplete, ¤tBuffer);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
// The submit infor strcuture contains a list of
|
|
||||||
// command buffers and semaphores to be submitted to a queue
|
|
||||||
// If you want to submit multiple command buffers, pass an array
|
|
||||||
VkPipelineStageFlags pipelineStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
|
||||||
VkSubmitInfo submitInfo = {};
|
|
||||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
|
||||||
submitInfo.pWaitDstStageMask = &pipelineStages;
|
|
||||||
// The wait semaphore ensures that the image is presented
|
|
||||||
// before we start submitting command buffers agein
|
|
||||||
submitInfo.waitSemaphoreCount = 1;
|
|
||||||
submitInfo.pWaitSemaphores = &semaphores.presentComplete;
|
|
||||||
// Submit the currently active command buffer
|
|
||||||
submitInfo.commandBufferCount = 1;
|
|
||||||
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
|
||||||
// The signal semaphore is used during queue presentation
|
|
||||||
// to ensure that the image is not rendered before all
|
|
||||||
// commands have been submitted
|
|
||||||
submitInfo.signalSemaphoreCount = 1;
|
|
||||||
submitInfo.pSignalSemaphores = &semaphores.renderComplete;
|
|
||||||
|
|
||||||
// Submit to the graphics queue
|
|
||||||
err = vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
|
|
||||||
assert(!err);
|
|
||||||
|
|
||||||
// Present the current buffer to the swap chain
|
|
||||||
// We pass the signal semaphore from the submit info
|
|
||||||
// to ensure that the image is not rendered until
|
|
||||||
// all commands have been submitted
|
|
||||||
err = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
|
|
||||||
assert(!err);
|
|
||||||
|
|
||||||
// Add a post present image memory barrier
|
// Add a post present image memory barrier
|
||||||
// This will transform the frame buffer color attachment back
|
// This will transform the frame buffer color attachment back
|
||||||
// to it's initial layout after it has been presented to the
|
// to it's initial layout after it has been presented to the
|
||||||
// windowing system
|
// windowing system
|
||||||
// See buildCommandBuffers for the pre present barrier that
|
|
||||||
// does the opposite transformation
|
|
||||||
VkImageMemoryBarrier postPresentBarrier = {};
|
VkImageMemoryBarrier postPresentBarrier = {};
|
||||||
postPresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
postPresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
postPresentBarrier.pNext = NULL;
|
postPresentBarrier.pNext = NULL;
|
||||||
|
|
@ -288,9 +255,39 @@ public:
|
||||||
|
|
||||||
err = vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
|
err = vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
err = vkQueueWaitIdle(queue);
|
err = vkQueueWaitIdle(queue);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
|
// The submit infor strcuture contains a list of
|
||||||
|
// command buffers and semaphores to be submitted to a queue
|
||||||
|
// If you want to submit multiple command buffers, pass an array
|
||||||
|
VkPipelineStageFlags pipelineStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||||
|
VkSubmitInfo submitInfo = {};
|
||||||
|
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||||
|
submitInfo.pWaitDstStageMask = &pipelineStages;
|
||||||
|
// The wait semaphore ensures that the image is presented
|
||||||
|
// before we start submitting command buffers agein
|
||||||
|
submitInfo.waitSemaphoreCount = 1;
|
||||||
|
submitInfo.pWaitSemaphores = &semaphores.presentComplete;
|
||||||
|
// Submit the currently active command buffer
|
||||||
|
submitInfo.commandBufferCount = 1;
|
||||||
|
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||||
|
// The signal semaphore is used during queue presentation
|
||||||
|
// to ensure that the image is not rendered before all
|
||||||
|
// commands have been submitted
|
||||||
|
submitInfo.signalSemaphoreCount = 1;
|
||||||
|
submitInfo.pSignalSemaphores = &semaphores.renderComplete;
|
||||||
|
|
||||||
|
// Submit to the graphics queue
|
||||||
|
err = vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
|
||||||
|
assert(!err);
|
||||||
|
|
||||||
|
// Present the current buffer to the swap chain
|
||||||
|
// We pass the signal semaphore from the submit info
|
||||||
|
// to ensure that the image is not rendered until
|
||||||
|
// all commands have been submitted
|
||||||
|
err = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
|
||||||
|
assert(!err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create synchronzation semaphores
|
// Create synchronzation semaphores
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue