X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Fopt_dead_code.cpp;h=b65e5c2ce333af7baefa594d41e763eb1dc2e598;hb=c0e4a4adb7c034c93b258620a5b357ad91229629;hp=5b9546ad40984708217f6eb7db907cfb22807659;hpb=1d5d67f8adac9f94715de9804adb536d9a7ec5ee;p=mesa.git diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp index 5b9546ad409..b65e5c2ce33 100644 --- a/src/glsl/opt_dead_code.cpp +++ b/src/glsl/opt_dead_code.cpp @@ -31,6 +31,7 @@ #include "ir_visitor.h" #include "ir_variable_refcount.h" #include "glsl_types.h" +#include "main/hash_table.h" static bool debug = false; @@ -49,8 +50,9 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned) v.run(instructions); - foreach_iter(exec_list_iterator, iter, v.variable_list) { - variable_entry *entry = (variable_entry *)iter.get(); + struct hash_entry *e; + hash_table_foreach(v.ht, e) { + ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)e->data; /* Since each assignment is a reference, the refereneced count must be * greater than or equal to the assignment count. If they are equal, @@ -75,11 +77,11 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned) if (entry->assign) { /* Remove a single dead assignment to the variable we found. - * Don't do so if it's a shader output, though. + * Don't do so if it's a shader or function output, though. */ - if (entry->var->mode != ir_var_out && - entry->var->mode != ir_var_inout && - !ir_has_call(entry->assign)) { + if (entry->var->mode != ir_var_function_out && + entry->var->mode != ir_var_function_inout && + entry->var->mode != ir_var_shader_out) { entry->assign->remove(); progress = true; @@ -98,7 +100,8 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned) * declaration cannot be deleted. */ if (entry->var->mode == ir_var_uniform && - (uniform_locations_assigned || entry->var->constant_value)) + (uniform_locations_assigned || + entry->var->constant_value)) continue; entry->var->remove();