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 <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36778>
(cherry picked from commit 45c91edd18)
This commit is contained in:
Samuel Pitoiset 2025-08-14 18:26:47 +02:00 committed by Eric Engestrom
parent 1f4ae92921
commit e246a3d966
2 changed files with 10 additions and 2 deletions

View file

@ -6494,7 +6494,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

View file

@ -5400,7 +5400,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;
@ -5453,6 +5453,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++) {