radv: remove radv_remove_color_exports
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

We do this later on lowered IO anyway, in radv_nir_trim_fs_color_exports.
That pass is also per component, and not per output slot.

No Foz-DB changes on Navi48.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40928>
This commit is contained in:
Georg Lehmann 2026-04-12 14:21:56 +02:00 committed by Marge Bot
parent cbeccb0a09
commit 6a2ac18b2b

View file

@ -1163,52 +1163,6 @@ radv_should_export_multiview(const struct radv_shader_stage *stage, const struct
!(stage->nir->info.outputs_written & VARYING_BIT_LAYER);
}
static void
radv_remove_color_exports(const struct radv_graphics_state_key *gfx_state, nir_shader *nir)
{
uint8_t color_remap[MAX_RTS];
bool fixup_derefs = false;
/* Do not remove color exports when a PS epilog is used because the format isn't known and the color write mask can
* be dynamic. */
if (gfx_state->ps.has_epilog)
return;
/* Shader output locations to color attachment mappings. */
memset(color_remap, MESA_VK_ATTACHMENT_UNUSED, sizeof(color_remap));
for (uint32_t i = 0; i < MAX_RTS; i++) {
if (gfx_state->ps.epilog.color_map[i] != MESA_VK_ATTACHMENT_UNUSED)
color_remap[gfx_state->ps.epilog.color_map[i]] = i;
}
nir_foreach_shader_out_variable (var, nir) {
int idx = var->data.location;
idx -= FRAG_RESULT_DATA0;
if (idx < 0)
continue;
const uint8_t cb_idx = color_remap[idx];
unsigned col_format = cb_idx == MESA_VK_ATTACHMENT_UNUSED
? V_028714_SPI_SHADER_ZERO
: (gfx_state->ps.epilog.spi_shader_col_format >> (4 * cb_idx)) & 0xf;
if (col_format == V_028714_SPI_SHADER_ZERO) {
/* Remove the color export if it's unused or in presence of holes. */
nir->info.outputs_written &= ~BITFIELD64_BIT(var->data.location);
var->data.location = 0;
var->data.mode = nir_var_shader_temp;
fixup_derefs = true;
}
}
if (fixup_derefs) {
NIR_PASS(_, nir, nir_fixup_deref_modes);
NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_shader_temp, NULL);
NIR_PASS(_, nir, nir_opt_dce);
}
}
static void
merge_tess_info(struct shader_info *tes_info, struct shader_info *tcs_info)
{
@ -1430,8 +1384,6 @@ radv_link_fs(struct radv_shader_stage *fs_stage, const struct radv_graphics_stat
/* Lower the view index to map on the layer. */
NIR_PASS(_, fs_stage->nir, radv_nir_lower_view_index);
radv_remove_color_exports(gfx_state, fs_stage->nir);
}
static bool