glsl: Add ir_variable::is_in_uniform_block predicate
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 14 Dec 2012 20:00:14 +0000 (12:00 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 25 Jan 2013 14:07:34 +0000 (09:07 -0500)
The way a variable is tested for this property is about to change, and
this makes the code easier to modify.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ir.h
src/glsl/link_uniforms.cpp
src/glsl/linker.cpp
src/glsl/lower_ubo_reference.cpp
src/glsl/opt_dead_code.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/program/ir_to_mesa.cpp

index 9fdfb18e25b14c448e621ab300d0c5e08456eee2..14212dfb7a276db9f0d0018da887a482d87a5a3f 100644 (file)
@@ -349,6 +349,14 @@ public:
     */
    glsl_interp_qualifier determine_interpolation_mode(bool flat_shade);
 
+   /**
+    * Determine whether or not a variable is part of a uniform block.
+    */
+   inline bool is_in_uniform_block() const
+   {
+      return this->mode == ir_var_uniform && this->uniform_block != -1;
+   }
+
    /**
     * Declared type of the variable
     */
index 25bba15bdbe397f5d281badd3221e3b868d2e0b1..c639a3d16a415f3239fab6e955ff3a11ceed8de7 100644 (file)
@@ -228,7 +228,7 @@ public:
                        ir_variable *var)
    {
       ubo_var = NULL;
-      if (var->uniform_block != -1) {
+      if (var->is_in_uniform_block()) {
         struct gl_uniform_block *block =
            &shader->UniformBlocks[var->uniform_block];
 
@@ -442,7 +442,7 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
    foreach_list(node, shader->ir) {
       ir_variable *const var = ((ir_instruction *) node)->as_variable();
 
-      if ((var == NULL) || (var->uniform_block == -1))
+      if ((var == NULL) || !var->is_in_uniform_block())
         continue;
 
       assert(var->mode == ir_var_uniform);
index 1d4e2f6e79352a7c4958bfe24a8f6745be127c24..a480dd0523fe4c9211578d6040542348a3eb6ca5 100644 (file)
@@ -1077,7 +1077,7 @@ update_array_sizes(struct gl_shader_program *prog)
          * will not be eliminated.  Since we always do std140, just
          * don't resize arrays in UBOs.
          */
-        if (var->uniform_block != -1)
+        if (var->is_in_uniform_block())
            continue;
 
         unsigned int size = var->max_array_access;
index e8d2c4742d6d72abc05d52554bb77b428fa15dfd..1d08009a34ec4c6d5fa231dd1218d9e2e2027591 100644 (file)
@@ -78,7 +78,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
       return;
 
    ir_variable *var = deref->variable_referenced();
-   if (!var || var->uniform_block == -1)
+   if (!var || !var->is_in_uniform_block())
       return;
 
    mem_ctx = ralloc_parent(*rvalue);
index dad307af779f210d091e3fe89c3acce14fcc5f13..78d31cfcb3fd5eed8b57f251216564cee7348697 100644 (file)
@@ -106,7 +106,7 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
         if (entry->var->mode == ir_var_uniform &&
             (uniform_locations_assigned ||
              entry->var->constant_value ||
-             entry->var->uniform_block != -1))
+             entry->var->is_in_uniform_block()))
            continue;
 
         entry->var->remove();
index 29ad60212a674f2ec3cd468fcc60e17c75547789..7646d597e0172e08f5fb83007da6a29343385285 100644 (file)
@@ -107,7 +107,7 @@ fs_visitor::visit(ir_variable *ir)
        * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO
        * variables, so no need for them to be in variable_ht.
        */
-      if (ir->uniform_block != -1)
+      if (ir->is_in_uniform_block())
          return;
 
       if (dispatch_width == 16) {
index 642675351559fe6349beeaf5045bf04ee4150dc4..3a2f1d317fc801846c1e8f3039e96f66fd33b865 100644 (file)
@@ -1052,7 +1052,7 @@ vec4_visitor::visit(ir_variable *ir)
        * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO
        * variables, so no need for them to be in variable_ht.
        */
-      if (ir->uniform_block != -1)
+      if (ir->is_in_uniform_block())
          return;
 
       /* Track how big the whole uniform variable is, in case we need to put a
index 4160caa9b7a7ef71f3be2e215898a2c009ccb55c..03a1dc402c39123d51e10bbf4c69b27a0bb05b4c 100644 (file)
@@ -2470,7 +2470,7 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
       ir_variable *var = ((ir_instruction *) node)->as_variable();
 
       if ((var == NULL) || (var->mode != ir_var_uniform)
-         || var->uniform_block != -1 || (strncmp(var->name, "gl_", 3) == 0))
+         || var->is_in_uniform_block() || (strncmp(var->name, "gl_", 3) == 0))
         continue;
 
       add.process(var);