Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.06k stars 511 forks source link

Page 25 (sampler) fails synchronization validation #341

Open gelvinp opened 1 year ago

gelvinp commented 1 year ago

When I saw the "best practices" validation feature, I also saw that there was a "synchronization validation" feature, so I enabled both. I saw that my project thus far had two errors reported every frame:

validation layer: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x5c0ec5d6 | vkCmdBeginRenderPass: Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 0 aspect color during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR.
validation layer: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x5c0ec5d6 | vkCmdEndRenderPass: Hazard WRITE_AFTER_WRITE vs. store/resolve operations in subpass 0 for attachment 0 final image layout transition (old_layout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, new_layout: VK_IMAGE_LAYOUT_PRESENT_SRC_KHR).

I copied the source from here exactly as is, and simply added the synchronization validation feature, and found that it also had these errors every frame. I've spent several hours trying to figure out what is happening here, and as far as I know, the VkSubpassDependency should prevent this but also I have absolutely no idea what is going on.

Any thoughts on how to fix this?

(to enable the feature, I added this block in between populateDebugMessengerCreateInfo(...) and createInfo.pNext = ...:

            VkValidationFeatureEnableEXT enabled[] = {
                VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT
            };

            VkValidationFeaturesEXT features{};
            features.sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT;
            features.enabledValidationFeatureCount = 1;
            features.pEnabledValidationFeatures = enabled;
            debugCreateInfo.pNext = &features;