nir: add next_stage parameter to nir_remove_varying
authorMarek Olšák <marek.olsak@amd.com>
Sun, 12 Mar 2023 07:18:38 +0000 (03:18 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 19 Apr 2023 21:42:11 +0000 (21:42 +0000)
so that e.g. the POS output is removed if the next stage is not FS.

Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21861>

src/amd/common/ac_nir_opt_outputs.c
src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/gallium/drivers/radeonsi/si_shader.c

index ea382ba..eac9c9d 100644 (file)
@@ -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;
       }
index 761f5a0..a67abd4 100644 (file)
@@ -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;
index 3784bc6..fcbdedc 100644 (file)
@@ -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,
index 2e1a3d8..a7bfee2 100644 (file)
@@ -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;
          }