[Mesa-dev] [PATCH 11/32] glsl: Add ir_variable::is_in_uniform_block predicate
Ian Romanick
idr at freedesktop.org
Tue Jan 22 00:52:02 PST 2013
From: Ian Romanick <ian.d.romanick at intel.com>
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 at intel.com>
---
src/glsl/ir.h | 8 ++++++++
src/glsl/link_uniforms.cpp | 4 ++--
src/glsl/linker.cpp | 2 +-
src/glsl/lower_ubo_reference.cpp | 2 +-
src/glsl/opt_dead_code.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 +-
src/mesa/program/ir_to_mesa.cpp | 2 +-
8 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 85fc5ce..a7eb9c1 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -348,6 +348,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
*/
const struct glsl_type *type;
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 25bba15..c639a3d 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -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);
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 63548e0..ffb476e 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1078,7 +1078,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;
diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index e8d2c47..1d08009 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -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);
diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp
index 47247e2..ac0ffc3 100644
--- a/src/glsl/opt_dead_code.cpp
+++ b/src/glsl/opt_dead_code.cpp
@@ -105,7 +105,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();
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 1186291..98006a3 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -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) {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 8aa67c2..f9d00c8 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -937,7 +937,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
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 637ab07..36d0bdc 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2463,7 +2463,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);
--
1.7.11.7
More information about the mesa-dev
mailing list