vulkan-renderer: Fix stages for sync in read_pixels

When we're reading back from a framebuffer, we need to sync from
fragment-shader output (i.e. after the final pixels are written to the
framebuffer) before we copy away from it, and sync to fragment-shader
(i.e. before any output touches the framebuffer) before we reuse it
after the copy. The latter is a no-op as we currently do a complete
vkQueueWaitIdle() after read_pixels(), but it removes a future footgun.

Fixes occasional fixes seen in screenshot testing.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2026-05-06 15:06:02 +01:00
parent f4ba4f49bb
commit ca54443b2c

View file

@ -1349,8 +1349,8 @@ vulkan_renderer_do_read_pixels(struct vulkan_renderer *vr,
transition_image_layout(cmd_buffer, color_attachment,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, VK_ACCESS_TRANSFER_WRITE_BIT);
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT);
copy_sub_image_to_buffer(cmd_buffer,
dst_buffer, color_attachment,
@ -1362,8 +1362,8 @@ vulkan_renderer_do_read_pixels(struct vulkan_renderer *vr,
transition_image_layout(cmd_buffer, color_attachment,
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, VK_ACCESS_TRANSFER_WRITE_BIT);
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_ACCESS_TRANSFER_READ_BIT, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
// TODO: async implementation of this, remove wait
vulkan_renderer_cmd_end_wait(vr, &cmd_buffer);