[Mesa-dev] [PATCH 4/5] compiler/glsl: move list node downcasts after sentinel/counter checks

Nicolai Hähnle nhaehnle at gmail.com
Sat May 7 22:05:07 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/compiler/glsl/ast_function.cpp              | 4 ++--
 src/compiler/glsl/link_uniform_initializers.cpp | 8 +++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index 37fb3e79..65d3be1 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -1670,8 +1670,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'",
@@ -1679,6 +1677,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 c6346d5..eec4e99 100644
--- a/src/compiler/glsl/link_uniform_initializers.cpp
+++ b/src/compiler/glsl/link_uniform_initializers.cpp
@@ -179,17 +179,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 *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() ||
-- 
2.7.4



More information about the mesa-dev mailing list