I trying to create a bloom effect for my vulkan game-engine. To implement this I use several bulring pass, in each one I read from one image and render/write a slightly more blurry picture to a other. After each draw pass i swap the role of these images(And using barriers), That means - the one was a render target became a shader resource and the one used as a shader resource became a target. I bind both of these images on same descriptor set to save unnecessary 'VkBindDescriptorSet' calls, but the validation layer tell me that if I want to bind a descriptors of images those all image's layout must be 'VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL' even if the shader used/read only from one of them at any given time(The shader read only from The one that currently in the 'VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL' state). Is this over-caution of the validationlayer? or the bindung is actually failed.
When i worked with DirectX12 I not had this debuger isue!
I would be happy for an answer or an idea for a solution, and I am sorry about my English.
Assuming your shader actually doesn't use the sampler when its image is bound to it, the validation layer is incorrect (not that it can know). The Vulkan standard only requires that the attached image subresources are not used:
Image subresources used as attachments in the current render pass must not be accessed in any way other than as an attachment by [a rendering command], ...
"Access" is defined by the Vulkan memory model, which for a bound image, involves invoking an image access command. So long as you don't do that to the descriptor, it is not "accessed", and thus does not violate this rule.
That being said, ping-ponging between images without using input attachments requires stopping and starting a render pass, not to mention the execution barriers between each pass. The cost of VkBindDescriptorSet
will be a rounding error in your GPU profiling data next to all of that.
So you should just change descriptor sets and shut the validation layer up.