[QUOTE=krOoze;41188]There should probably also be semaphore between the usage and the presentation.
I hope you are using validation layers.
BTW If you mean PIPELINE_STAGE_ALL use PIPELINE_STAGE_ALL, not PIPELINE_STAGE_BOTTOM. It is nicer to read and less easier to confuse (TOP and BOTTOM must be swiched for src and dst). Besides it is not very obvious to me from the spec that all previous stages will be included in the memory dependency automatically if there happens to be one.[/QUOTE]
Of course i am using validation layers
Would be horrific if not.
There is a semaphore between the usage and the presentation of the swapchain-image:
// Copy the given renderedImage into the appropriate
// swapchain-image and present it finally on screen
void VulkanBase::submitFrame(const VkImage& renderedImage)
{
Swapchain* swapchain = window->getSwapchain();
FrameData& frameData = frameResources[frameDataIndex];
// Next image in the swapchain used for presenting
uint32_t nextImage;
// Aquire next image. Present-Complete Semaphore gets signaled when presentation is complete.
swapchain->aquireNextImageIndex(UINT64_MAX, frameData.presentCompleteSem, NULL, &nextImage);
// Copy the rendered image into the appropriate swapchain-image
CommandBuffer& blitCmd = frameData.blitCmd;
blitCmd.begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
{
VkImageSubresourceRange subResourceRange = {};
subResourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
subResourceRange.layerCount = 1;
subResourceRange.levelCount = 1;
blitCmd.setImageLayout(renderedImage, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, subResourceRange);
blitCmd.setImageLayout(swapchain->getImage(nextImage), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subResourceRange);
blitCmd.copyImage({ Window::getWidth(), Window::getHeight(), 1 },
renderedImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
swapchain->getImage(nextImage), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
blitCmd.setImageLayout(renderedImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, subResourceRange);
blitCmd.setImageLayout(swapchain->getImage(nextImage), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, subResourceRange);
}
blitCmd.end();
// Submit the copying command, wait until the image has been presented
// This is the last submit before presenting so signal the fence in the frame-data struct
blitCmd.submit(graphicQueue, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
frameData.presentCompleteSem, NULL, frameData.fence);
// Submit swapchain-image to the presentation engine
swapchain->queuePresent(presentingQueue, {}, nextImage);
After reading this i noticed something. In my mind the rendering itself and the following copy into the swapchain image is synchronized by a subpass-dependency. But are Subpass-Dependency only synchronize commands in the same command buffer? I cant be sure that the blit-cmd is already doing his work, when the rendering is still in process, can i? Than i would need definetely a semaphore here.