radv: add radv_remove_color_exports() helper
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18255>
This commit is contained in:

committed by
Marge Bot

parent
baf3924631
commit
b5e25e3a30
@@ -2190,6 +2190,39 @@ radv_remove_point_size(const struct radv_pipeline_key *pipeline_key,
|
||||
NIR_PASS(_, producer, nir_opt_dce);
|
||||
}
|
||||
|
||||
static void
|
||||
radv_remove_color_exports(const struct radv_pipeline_key *pipeline_key, nir_shader *nir)
|
||||
{
|
||||
bool fixup_derefs = false;
|
||||
|
||||
nir_foreach_shader_out_variable(var, nir) {
|
||||
int idx = var->data.location;
|
||||
idx -= FRAG_RESULT_DATA0;
|
||||
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
unsigned col_format = (pipeline_key->ps.col_format >> (4 * idx)) & 0xf;
|
||||
unsigned cb_target_mask = (pipeline_key->ps.cb_target_mask >> (4 * idx)) & 0xf;
|
||||
|
||||
if (col_format == V_028714_SPI_SHADER_ZERO ||
|
||||
(col_format == V_028714_SPI_SHADER_32_R && !cb_target_mask &&
|
||||
!pipeline_key->ps.mrt0_is_dual_src)) {
|
||||
/* 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_V(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)
|
||||
{
|
||||
@@ -2539,34 +2572,7 @@ radv_pipeline_link_fs(struct radv_pipeline_stage *fs_stage,
|
||||
{
|
||||
assert(fs_stage->nir->info.stage == MESA_SHADER_FRAGMENT);
|
||||
|
||||
bool fixup_derefs = false;
|
||||
|
||||
nir_foreach_shader_out_variable(var, fs_stage->nir) {
|
||||
int idx = var->data.location;
|
||||
idx -= FRAG_RESULT_DATA0;
|
||||
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
unsigned col_format = (pipeline_key->ps.col_format >> (4 * idx)) & 0xf;
|
||||
unsigned cb_target_mask = (pipeline_key->ps.cb_target_mask >> (4 * idx)) & 0xf;
|
||||
|
||||
if (col_format == V_028714_SPI_SHADER_ZERO ||
|
||||
(col_format == V_028714_SPI_SHADER_32_R && !cb_target_mask &&
|
||||
!pipeline_key->ps.mrt0_is_dual_src)) {
|
||||
/* Remove the color export if it's unused or in presence of holes. */
|
||||
fs_stage->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_V(fs_stage->nir, nir_fixup_deref_modes);
|
||||
NIR_PASS(_, fs_stage->nir, nir_remove_dead_variables, nir_var_shader_temp, NULL);
|
||||
NIR_PASS(_, fs_stage->nir, nir_opt_dce);
|
||||
}
|
||||
radv_remove_color_exports(pipeline_key, fs_stage->nir);
|
||||
|
||||
nir_foreach_shader_out_variable(var, fs_stage->nir) {
|
||||
var->data.driver_location = var->data.location + var->data.index;
|
||||
|
Reference in New Issue
Block a user