From dbdb297b3d0194947751eaff1453b53c1989b456 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 14 Aug 2025 18:26:47 +0200 Subject: [PATCH] radv: fix color attachment remapping with fast-GPL/ESO If vkCmdSetRenderingAttachmentLocations() isn't setting all color attachment locations (ie. MAX_RTS), the remapping might be wrong because MESA_VK_ATTACHMENT_UNUSED is used to trim the unused locations Found by inspection while implementing a new extension. Cc: mesa-stable Signed-off-by: Samuel Pitoiset Part-of: (cherry picked from commit 45c91edd1814618dbafd849acdb382e9b263fda9) --- .pick_status.json | 2 +- src/amd/vulkan/radv_cmd_buffer.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3765c19b41c..5a1b03956ca 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1354,7 +1354,7 @@ "description": "radv: fix color attachment remapping with fast-GPL/ESO", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index eb0a47680c7..b4948534510 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -5401,7 +5401,7 @@ lookup_ps_epilog(struct radv_cmd_buffer *cmd_buffer) state.color_attachment_formats[i] = render->color_att[i].format; } - for (unsigned i = 0; i < MAX_RTS; i++) { + for (unsigned i = 0; i < render->color_att_count; i++) { VkBlendOp eqRGB = d->vk.cb.attachments[i].color_blend_op; VkBlendFactor srcRGB = d->vk.cb.attachments[i].src_color_blend_factor; VkBlendFactor dstRGB = d->vk.cb.attachments[i].dst_color_blend_factor; @@ -5454,6 +5454,14 @@ lookup_ps_epilog(struct radv_cmd_buffer *cmd_buffer) struct radv_ps_epilog_key key = radv_generate_ps_epilog_key(device, &state); + /* Adjust the remapping for alpha-to-coverage without any color attachment and dual-source + * blending to make sure colors written aren't cleared. + */ + if (!state.color_attachment_count && state.need_src_alpha) + color_remap[0] = 0; + if (state.mrt0_is_dual_src) + color_remap[1] = 1; + /* Determine the actual colors written if outputs are remapped. */ uint32_t colors_written = 0; for (uint32_t i = 0; i < MAX_RTS; i++) {