glsl: Do not kill dead assignments to buffer variables or SSBO declarations.
authorIago Toral Quiroga <itoral@igalia.com>
Mon, 6 Apr 2015 08:19:50 +0000 (10:19 +0200)
committerSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Tue, 14 Jul 2015 05:04:04 +0000 (07:04 +0200)
If we kill dead assignments we lose the buffer writes.

Also, we never kill UBO declarations even if they are never referenced
by the shader, they are always considered active. Although the spec
does not seem say this specifically for SSBOs, it is probably implied
since SSBOs are pretty much the same as UBOs, only that you can write
to them.

v2:
- Fix the comment (Jordan)

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/glsl/opt_dead_code.cpp

index 7b4730a39bb78f84e63fca084e60338d65205ea2..04e4d5673d2be0a213f5aab929c0c46211a99a18 100644 (file)
@@ -77,11 +77,13 @@ 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 or function output, though.
+         * Don't do so if it's a shader or function output or a shader
+         * storage variable though.
          */
         if (entry->var->data.mode != ir_var_function_out &&
             entry->var->data.mode != ir_var_function_inout &&
-             entry->var->data.mode != ir_var_shader_out) {
+             entry->var->data.mode != ir_var_shader_out &&
+             entry->var->data.mode != ir_var_shader_storage) {
            entry->assign->remove();
            progress = true;
 
@@ -99,7 +101,8 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
          * stage.  Also, once uniform locations have been assigned, the
          * declaration cannot be deleted.
          */
-         if (entry->var->data.mode == ir_var_uniform) {
+         if (entry->var->data.mode == ir_var_uniform ||
+             entry->var->data.mode == ir_var_shader_storage) {
             if (uniform_locations_assigned || entry->var->constant_value)
                continue;