From e6e406b4833a628c31a03c13a3b5842e40a8c460 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 12 Mar 2023 03:18:38 -0400 Subject: [PATCH] nir: add next_stage parameter to nir_remove_varying MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit so that e.g. the POS output is removed if the next stage is not FS. Reviewed-by: Qiang Yu Reviewed-by: Timur Kristóf Part-of: --- src/amd/common/ac_nir_opt_outputs.c | 2 +- src/compiler/nir/nir.c | 4 ++-- src/compiler/nir/nir.h | 2 +- src/gallium/drivers/radeonsi/si_shader.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/amd/common/ac_nir_opt_outputs.c b/src/amd/common/ac_nir_opt_outputs.c index ea382ba..eac9c9d 100644 --- a/src/amd/common/ac_nir_opt_outputs.c +++ b/src/amd/common/ac_nir_opt_outputs.c @@ -58,7 +58,7 @@ static void ac_remove_varying(struct ac_out_info *out) /* Remove the output. (all channels) */ for (unsigned i = 0; i < ARRAY_SIZE(out->chan); i++) { if (out->chan[i].store_intr) { - nir_remove_varying(out->chan[i].store_intr); + nir_remove_varying(out->chan[i].store_intr, MESA_SHADER_FRAGMENT); out->chan[i].store_intr = NULL; out->chan[i].value = NULL; } diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 761f5a0..a67abd4 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -3516,12 +3516,12 @@ nir_slot_is_sysval_output_and_varying(gl_varying_slot slot, * stage. If the instruction has no other use, it's removed. */ bool -nir_remove_varying(nir_intrinsic_instr *intr) +nir_remove_varying(nir_intrinsic_instr *intr, gl_shader_stage next_shader) { nir_io_semantics sem = nir_intrinsic_io_semantics(intr); if ((!sem.no_sysval_output && - nir_slot_is_sysval_output(sem.location, MESA_SHADER_NONE)) || + nir_slot_is_sysval_output(sem.location, next_shader)) || nir_instr_xfb_write_mask(intr)) { /* Demote the store instruction. */ sem.no_varying = true; diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 3784bc6..fcbdedc 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4784,7 +4784,7 @@ bool nir_slot_is_sysval_output(gl_varying_slot slot, bool nir_slot_is_varying(gl_varying_slot slot); bool nir_slot_is_sysval_output_and_varying(gl_varying_slot slot, gl_shader_stage next_shader); -bool nir_remove_varying(nir_intrinsic_instr *intr); +bool nir_remove_varying(nir_intrinsic_instr *intr, gl_shader_stage next_shader); void nir_remove_sysval_output(nir_intrinsic_instr *intr); bool nir_lower_amul(nir_shader *shader, diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 2e1a3d8..a7bfee2 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1490,7 +1490,7 @@ static bool si_nir_kill_outputs(nir_shader *nir, const union si_shader_key *key) if (nir_slot_is_varying(sem.location) && key->ge.opt.kill_outputs & (1ull << si_shader_io_get_unique_index(sem.location, true))) { - nir_remove_varying(intr); + nir_remove_varying(intr, MESA_SHADER_FRAGMENT); progress = true; } -- 2.7.4