glsl: Add ir_variable::is_in_uniform_block predicate

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>
This commit is contained in:
Ian Romanick
2012-12-14 12:00:14 -08:00
parent 17e6f19044
commit 13be1f4a10
8 changed files with 16 additions and 8 deletions

View File

@@ -349,6 +349,14 @@ public:
*/ */
glsl_interp_qualifier determine_interpolation_mode(bool flat_shade); 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 * Declared type of the variable
*/ */

View File

@@ -228,7 +228,7 @@ public:
ir_variable *var) ir_variable *var)
{ {
ubo_var = NULL; ubo_var = NULL;
if (var->uniform_block != -1) { if (var->is_in_uniform_block()) {
struct gl_uniform_block *block = struct gl_uniform_block *block =
&shader->UniformBlocks[var->uniform_block]; &shader->UniformBlocks[var->uniform_block];
@@ -442,7 +442,7 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
foreach_list(node, shader->ir) { foreach_list(node, shader->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable(); 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; continue;
assert(var->mode == ir_var_uniform); assert(var->mode == ir_var_uniform);

View File

@@ -1077,7 +1077,7 @@ update_array_sizes(struct gl_shader_program *prog)
* will not be eliminated. Since we always do std140, just * will not be eliminated. Since we always do std140, just
* don't resize arrays in UBOs. * don't resize arrays in UBOs.
*/ */
if (var->uniform_block != -1) if (var->is_in_uniform_block())
continue; continue;
unsigned int size = var->max_array_access; unsigned int size = var->max_array_access;

View File

@@ -78,7 +78,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
return; return;
ir_variable *var = deref->variable_referenced(); ir_variable *var = deref->variable_referenced();
if (!var || var->uniform_block == -1) if (!var || !var->is_in_uniform_block())
return; return;
mem_ctx = ralloc_parent(*rvalue); mem_ctx = ralloc_parent(*rvalue);

View File

@@ -106,7 +106,7 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
if (entry->var->mode == ir_var_uniform && if (entry->var->mode == ir_var_uniform &&
(uniform_locations_assigned || (uniform_locations_assigned ||
entry->var->constant_value || entry->var->constant_value ||
entry->var->uniform_block != -1)) entry->var->is_in_uniform_block()))
continue; continue;
entry->var->remove(); entry->var->remove();

View File

@@ -107,7 +107,7 @@ fs_visitor::visit(ir_variable *ir)
* ir_binop_ubo_load expressions and not ir_dereference_variable for UBO * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO
* variables, so no need for them to be in variable_ht. * variables, so no need for them to be in variable_ht.
*/ */
if (ir->uniform_block != -1) if (ir->is_in_uniform_block())
return; return;
if (dispatch_width == 16) { if (dispatch_width == 16) {

View File

@@ -1052,7 +1052,7 @@ vec4_visitor::visit(ir_variable *ir)
* ir_binop_ubo_load expressions and not ir_dereference_variable for UBO * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO
* variables, so no need for them to be in variable_ht. * variables, so no need for them to be in variable_ht.
*/ */
if (ir->uniform_block != -1) if (ir->is_in_uniform_block())
return; return;
/* Track how big the whole uniform variable is, in case we need to put a /* Track how big the whole uniform variable is, in case we need to put a

View File

@@ -2470,7 +2470,7 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
ir_variable *var = ((ir_instruction *) node)->as_variable(); ir_variable *var = ((ir_instruction *) node)->as_variable();
if ((var == NULL) || (var->mode != ir_var_uniform) 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; continue;
add.process(var); add.process(var);