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>
This commit is contained in:
Samuel Pitoiset 2025-08-14 18:26:47 +02:00 committed by Marge Bot
parent c221956b68
commit 45c91edd18

View file

@ -5333,7 +5333,7 @@ lookup_ps_epilog(struct radv_cmd_buffer *cmd_buffer)
state.color_write_mask = d->color_write_mask;
for (unsigned i = 0; i < MAX_RTS; i++) {
for (unsigned i = 0; i < render->color_att_count; i++) {
const uint32_t cb_blend_control = d->cb_att[i].cb_blend_control;
const uint32_t src_blend = G_028780_COLOR_SRCBLEND(cb_blend_control);
const uint32_t dst_blend = G_028780_COLOR_DESTBLEND(cb_blend_control);
@ -5383,6 +5383,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++) {