glsl: don't set uniform block as used when its not
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 3 Dec 2019 13:14:03 +0000 (00:14 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 5 Dec 2019 02:18:23 +0000 (13:18 +1100)
The spec requires unused uniform block to be set as active in the
program resource list. To support this we tell opt dead code not to
remove them. However we can mark them as unused internally and
avoid unnecessarily state changes.

This change is also required for the folowing clean-up patch.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/opt_dead_code.cpp

index c7ca7034a513b9e0c7d307db4df30fa009febd06..6518ec10f34f9b27ad0e8fecbd603a0be6fe0ee5 100644 (file)
@@ -1059,7 +1059,8 @@ private:
       this->uniforms[id].opaque[shader_type].index = ~0;
       this->uniforms[id].opaque[shader_type].active = false;
 
-      this->uniforms[id].active_shader_mask |= 1 << shader_type;
+      if (current_var->data.used || base_type->is_subroutine())
+         this->uniforms[id].active_shader_mask |= 1 << shader_type;
 
       /* This assigns uniform indices to sampler and image uniforms. */
       handle_samplers(base_type, &this->uniforms[id], name);
index 1eff3f2fd143c2da2603c0381c5fd6aab80ebe01..3e571fc7dd03cb42c98984690d11b9976fc7923b 100644 (file)
@@ -144,8 +144,15 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
              */
             if (entry->var->is_in_buffer_block()) {
                if (entry->var->get_interface_type_packing() !=
-                   GLSL_INTERFACE_PACKING_PACKED)
+                   GLSL_INTERFACE_PACKING_PACKED) {
+                  /* Set used to false so it doesn't get set as referenced by
+                   * the shader in the program resource list. This will also
+                   * help avoid the state being unnecessarily flushed for the
+                   * shader stage.
+                   */
+                  entry->var->data.used = false;
                   continue;
+               }
             }
 
             if (entry->var->type->is_subroutine())