I know this is not optimal, and a better solution is to use a single renderpass with multiple subpasses…
But let’s say I’m executing two renderpasses back-to-back that write to the same color attachment.
I’m assuming this will introduce a write-after-write hazard, so I need to add a pipeline barrier to guarantee the first renderpass finishes writing to the attachment before the second writes to it.
Problem is I’m not sure what the correct barrier would be, and I can’t really find anything in the spec or online.
// pseudo-code
vkCmdBeginRenderPass(cmdBuffer, renderPassbeginInfo1, VK_SUBPASS_CONTENTS_INLINE); // renderpass #1
// several vkCmdDraws…
vkCmdEndRenderPass(cmdBuffer);
vkCmdPipelineBarrier(cmdBuffer,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, // wait for renderpass #1 finishes writing to color attachment
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, // wait at VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
0, 0, 0, 0, 0, 0, 0); // Do not need any layout transitions. Do we need VkMemoryBarrier? If so, what srcAccess/dstAccess ?
vkCmdBeginRenderPass(cmdBuffer, renderPassbeginInfo2, VK_SUBPASS_CONTENTS_INLINE); // renderpass #2
// more vkCmdDraws…
vkCmdEndRenderPass(cmdBuffer);
… Or is this pipeline barrier actually not needed due to implicit rasterization order rules? Although from the spec it seems that only applies for commands within the same subpass…
Thanks