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>
This commit is contained in:
@@ -2205,7 +2205,7 @@ nir_src *nir_get_io_vertex_index_src(nir_intrinsic_instr *instr);
|
||||
|
||||
void nir_lower_vars_to_ssa(nir_shader *shader);
|
||||
|
||||
bool nir_remove_dead_variables(nir_shader *shader);
|
||||
bool nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes);
|
||||
|
||||
void nir_move_vec_src_uses_to_dest(nir_shader *shader);
|
||||
bool nir_lower_vec_to_movs(nir_shader *shader);
|
||||
|
@@ -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,8 +128,22 @@ nir_remove_dead_variables(nir_shader *shader)
|
||||
|
||||
add_var_use_shader(shader, live);
|
||||
|
||||
if (modes & nir_var_uniform)
|
||||
progress = remove_dead_vars(&shader->uniforms, live) || progress;
|
||||
|
||||
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)) {
|
||||
@@ -140,6 +154,7 @@ nir_remove_dead_variables(nir_shader *shader)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_mesa_set_destroy(live, NULL);
|
||||
return progress;
|
||||
|
@@ -142,7 +142,7 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
|
||||
|
||||
} while (progress);
|
||||
|
||||
OPT_V(s, nir_remove_dead_variables);
|
||||
OPT_V(s, nir_remove_dead_variables, nir_var_local);
|
||||
|
||||
if (fd_mesa_debug & FD_DBG_DISASM) {
|
||||
debug_printf("----------------------\n");
|
||||
|
@@ -1910,7 +1910,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
|
||||
|
||||
vc4_optimize_nir(c->s);
|
||||
|
||||
NIR_PASS_V(c->s, nir_remove_dead_variables);
|
||||
NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_local);
|
||||
NIR_PASS_V(c->s, nir_convert_from_ssa, true);
|
||||
|
||||
if (vc4_debug & VC4_DEBUG_SHADERDB) {
|
||||
|
@@ -473,7 +473,7 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)
|
||||
/* Get rid of split copies */
|
||||
nir = nir_optimize(nir, is_scalar);
|
||||
|
||||
OPT(nir_remove_dead_variables);
|
||||
OPT(nir_remove_dead_variables, nir_var_local);
|
||||
|
||||
return nir;
|
||||
}
|
||||
|
Reference in New Issue
Block a user