Open dschuechter opened 4 months ago
Thank you for pointing this out. It looks like I forgot to add a barrier to be 100% correct when it comes to synchronization. There are 2 options to add this barrier: Either you could add the barrier as a vkCmdPipelineBarrier before beginning the renderpass or you could add it as a subpass dependency in the renderpass creation. The latter would look like this:
VkSubpassDependency dependencies[] = {
{.srcSubpass = VK_SUBPASS_EXTERNAL, .dstSubpass = 0,
.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, .dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
.srcAccessMask = 0, .dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, .dependencyFlags = 0},
};
// Then add this dependency as part of the VkRenderPassCreateInfo
createInfo.pDependencies = dependencies;
createInfo.dependencyCount = ARRAY_COUNT(dependencies);
The subpass external dependency makes sure that the image is actually available to be written into with 'VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT' by waiting at our 'VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT'
Hey, I am currently following your great tutorial series. Thanks for your great work!
I ran into validation errors in Vulkan Tutorial #018 and Vulkan Tutorial #024. Since I am quiet new to Vulkan and C++ I am a bit lost.
In Episode 18:
Validation errors:
[.../Vulkan/src/vulkan_base/vulkan_device.cpp:5]: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-READ ] Object 0: handle = 0x557fb8f85db0, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0x376bc9df | vkQueueSubmit(): Hazard WRITE_AFTER_READ for entry 0, VkCommandBuffer 0x557fbb2bba00[], Submitted access info (submitted_usage: SYNC_IMAGE_LAYOUT_TRANSITION, command: vkCmdBeginRenderPass, seq_no: 1, renderpass: VkRenderPass 0xd5b26f0000000010[], reset_no: 88). Access info (prior_usage: SYNC_PRESENT_ENGINE_SYNCVAL_PRESENT_ACQUIRE_READ_SYNCVAL, read_barriers: VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT|VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT, , batch_tag: 693, vkAcquireNextImageKHR aquire_tag:693: VkSwapchainKHR 0xee647e0000000009[], image_index: 2image: VkImage 0xe88693000000000c[])
I identified the problem to be this line:
If you change it to
the validation errors disappear.
In Episode 24
The same validation errors are reproducable with your code.
I am running an up-to-date Arch Linux with Vulkan (Instance Version 1.3.279).