summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_remove_dead_variables.c
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2016-03-25 14:26:11 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2016-04-13 15:45:10 -0700
commitb63a98b1211d22f759ae9c80b2270fe2d3b2639e (patch)
tree7f1e411c91ee2ad01b0df3fdddf48a3168d9f2ac /src/compiler/nir/nir_remove_dead_variables.c
parent505a8fbdf8f2b6d2aaab5a04244cd3329f9dbe97 (diff)
downloadexternal_mesa3d-b63a98b1211d22f759ae9c80b2270fe2d3b2639e.zip
external_mesa3d-b63a98b1211d22f759ae9c80b2270fe2d3b2639e.tar.gz
external_mesa3d-b63a98b1211d22f759ae9c80b2270fe2d3b2639e.tar.bz2
nir/dead_variables: Configurably work with any variable mode
The old version of the pass only worked on globals and locals and always left inputs, outputs, uniforms, etc. alone. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/compiler/nir/nir_remove_dead_variables.c')
-rw-r--r--src/compiler/nir/nir_remove_dead_variables.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/compiler/nir/nir_remove_dead_variables.c b/src/compiler/nir/nir_remove_dead_variables.c
index 6519268..7395805 100644
--- a/src/compiler/nir/nir_remove_dead_variables.c
+++ b/src/compiler/nir/nir_remove_dead_variables.c
@@ -120,7 +120,7 @@ remove_dead_vars(struct exec_list *var_list, struct set *live)
}
bool
-nir_remove_dead_variables(nir_shader *shader)
+nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes)
{
bool progress = false;
struct set *live =
@@ -128,15 +128,30 @@ nir_remove_dead_variables(nir_shader *shader)
add_var_use_shader(shader, live);
- progress = remove_dead_vars(&shader->globals, live) || progress;
+ if (modes & nir_var_uniform)
+ progress = remove_dead_vars(&shader->uniforms, live) || progress;
- nir_foreach_function(shader, function) {
- if (function->impl) {
- if (remove_dead_vars(&function->impl->locals, live)) {
- nir_metadata_preserve(function->impl, nir_metadata_block_index |
- nir_metadata_dominance |
- nir_metadata_live_ssa_defs);
- progress = true;
+ if (modes & nir_var_shader_in)
+ progress = remove_dead_vars(&shader->inputs, live) || progress;
+
+ if (modes & nir_var_shader_out)
+ progress = remove_dead_vars(&shader->outputs, live) || progress;
+
+ if (modes & nir_var_global)
+ progress = remove_dead_vars(&shader->globals, live) || progress;
+
+ if (modes & nir_var_system_value)
+ progress = remove_dead_vars(&shader->system_values, live) || progress;
+
+ if (modes & nir_var_local) {
+ nir_foreach_function(shader, function) {
+ if (function->impl) {
+ if (remove_dead_vars(&function->impl->locals, live)) {
+ nir_metadata_preserve(function->impl, nir_metadata_block_index |
+ nir_metadata_dominance |
+ nir_metadata_live_ssa_defs);
+ progress = true;
+ }
}
}
}