In Vulkan, when using an image as both a color attachment and an input attachment, you need to ensure that the image is not modified after it has been used as an input attachment. To do this, you need to specify the correct dependency ordering between the subpasses.
In your case, since you don't care about the layout of the image after the render pass has ended, you should use the VK_DEPENDENCY_BY_REGION dependency type for the input attachment. This will ensure that the input attachment is only accessed after the color attachment has been written, and will prevent any writes to the input attachment from being visible to the color attachment.
Here's an example of how you could specify the dependencies for your render pass:
VkRenderPass renderPass = ...;
VkSubpassDescription subpass = ...;
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.inputAttachmentCount = 1;
subpass.pInputAttachments = &inputAttachment;
subpass.outputAttachmentCount = 1;
subpass.pOutputAttachments = &colorAttachment;
VkSubpassDependency dependency = ...;
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
dependency.dstSubpass = 0;
dependency.dependencyType = VK_DEPENDENCY_BY_REGION;
dependency.sourceStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
dependency.destinationStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
dependency.srcAccessMask = VK_ACCESS_READ_BIT;
dependency.dstAccessMask = VK_ACCESS_READ_BIT;
vkCreateRenderPass(device, &renderPass, NULL, &result);
In this example, the input attachment inputAttachment is used in subpass 1, and the color attachment colorAttachment is used in subpass 0. The VK_DEPENDENCY_BY_REGION dependency type ensures that the input attachment is only accessed after the color attachment has been