summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2016-05-02 12:45:08 -0500
committerNicolai Hähnle <nicolai.haehnle@amd.com>2016-06-15 10:39:49 +0200
commit28ea45bbebab37b0653bf85a3842183ede09fb99 (patch)
tree9361efaa1a268194a4ca6c83c038a9fbcad2deb9
parent9b67f0468cabedc332b97c58ba15d9f5788734c7 (diff)
compiler/glsl: move list node downcasts after sentinel/counter checks (v2)
v2: make variable const + style change Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r--src/compiler/glsl/ast_function.cpp4
-rw-r--r--src/compiler/glsl/link_uniform_initializers.cpp8
2 files changed, 5 insertions, 7 deletions
diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index f74394fe1d..9aea470f71 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -1708,8 +1708,6 @@ process_record_constructor(exec_list *instructions,
exec_node *node = actual_parameters.head;
for (unsigned i = 0; i < constructor_type->length; i++) {
- ir_rvalue *ir = (ir_rvalue *) node;
-
if (node->is_tail_sentinel()) {
_mesa_glsl_error(loc, state,
"insufficient parameters to constructor for `%s'",
@@ -1717,6 +1715,8 @@ process_record_constructor(exec_list *instructions,
return ir_rvalue::error_value(ctx);
}
+ ir_rvalue *ir = (ir_rvalue *) node;
+
if (apply_implicit_conversion(constructor_type->fields.structure[i].type,
ir, state)) {
node->replace_with(ir);
diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp
index acf8222079..c3da07887b 100644
--- a/src/compiler/glsl/link_uniform_initializers.cpp
+++ b/src/compiler/glsl/link_uniform_initializers.cpp
@@ -181,17 +181,15 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
{
const glsl_type *t_without_array = type->without_array();
if (type->is_record()) {
- ir_constant *field_constant;
+ exec_node *node = val->components.get_head();
- field_constant = (ir_constant *)val->components.get_head();
-
- for (unsigned int i = 0; i < type->length; i++) {
+ for (unsigned int i = 0; i < type->length; i++, node = node->next) {
+ ir_constant * const field_constant = (ir_constant *) node;
const glsl_type *field_type = type->fields.structure[i].type;
const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name,
type->fields.structure[i].name);
set_uniform_initializer(mem_ctx, prog, field_name,
field_type, field_constant, boolean_true);
- field_constant = (ir_constant *)field_constant->next;
}
return;
} else if (t_without_array->is_record() ||