I made a render pass using Vulkan which contains multiple subpasses. We can assume it has 2 subpasses, subpass A and B. In subpass A, I render to an image I want to use in subpass B as a combined image sampler (i. e. NOT as an input attachment). My question is how should I do the image transition from VK_IMAGE_LAYOUT_COLOR_ATTACHMENT to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL?
I think the subpass dependency mechanism is not good by itself, because I don't use the image in subpass B as an attachment (I guess it doesn't make sense to use it either as input, color, or preserve attachment.) I wanted to use a simple image barrier with a self-dependency, and I was surprised when the validation layer told me that if an image barrier is used inside a render pass, the new and old layout fields should be equal!
This image layout transition pattern seems kind of natural to me, but I haven't found any solution yet. Maybe I misunderstand the concept of subpasses and render passes and I should use different render passes for A and B? (Although in that case I would have to process my G-buffer in two render pass, and I wouldn't be able to use the "input attachment mechanism" of Vulkan.)