Mesa (master): st/nir: Call nir_remove_unused_variables() in the opt loop

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Sep 5 11:48:58 UTC 2019


Module: Mesa
Branch: master
Commit: 7d2d7b5d5f3b2eb5fd5d49b1f26989f0c358c3c8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d2d7b5d5f3b2eb5fd5d49b1f26989f0c358c3c8

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Wed Sep  4 13:54:13 2019 +0200

st/nir: Call nir_remove_unused_variables() in the opt loop

This prevents regressions when disabling indirect lowering. Sometimes
the only use of an input array was copying it to the array created by
nir_lower_io_to_temporaries, and without lowering indirects we wouldn't
have eliminated the temporary array until after linking, which was too
late to remove unused code in the producer.

No shader-db changes with radeonsi NIR.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/mesa/state_tracker/st_glsl_to_nir.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 2b4c45f5f55..081f85edf53 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -232,6 +232,16 @@ st_nir_opts(nir_shader *nir, bool scalar)
       progress = false;
 
       NIR_PASS_V(nir, nir_lower_vars_to_ssa);
+      
+      /* Linking deals with unused inputs/outputs, but here we can remove
+       * things local to the shader in the hopes that we can cleanup other
+       * things. This pass will also remove variables with only stores, so we
+       * might be able to make progress after it.
+       */
+      NIR_PASS(progress, nir, nir_remove_dead_variables,
+               (nir_variable_mode)(nir_var_function_temp |
+                                   nir_var_shader_temp |
+                                   nir_var_mem_shared));
 
       NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
       NIR_PASS(progress, nir, nir_opt_dead_write_vars);




More information about the mesa-commit mailing list