[Mesa-dev] [PATCH] glsl: Dont call mark_whole_array_access() unless we are dealing with arrays

Timothy Arceri t_arceri at yahoo.com.au
Tue Dec 17 22:00:25 PST 2013


Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
 src/glsl/ast_to_hir.cpp | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 3bc181e..a7aa4c7 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -805,33 +805,36 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
    if (new_rhs != NULL) {
       rhs = new_rhs;
 
-      /* If the LHS array was not declared with a size, it takes it size from
-       * the RHS.  If the LHS is an l-value and a whole array, it must be a
-       * dereference of a variable.  Any other case would require that the LHS
-       * is either not an l-value or not a whole array.
-       */
-      if (lhs->type->is_unsized_array()) {
-	 ir_dereference *const d = lhs->as_dereference();
+      if (lhs->type->is_array()) {
+         /* If the LHS array was not declared with a size, it takes it size
+          * from the RHS.  If the LHS is an l-value and a whole array, it must
+          * be a dereference of a variable.  Any other case would require that
+          * the LHS is either not an l-value or not a whole array.
+          */
+         if (lhs->type->is_unsized_array()) {
+	    ir_dereference *const d = lhs->as_dereference();
 
-	 assert(d != NULL);
+	    assert(d != NULL);
 
-	 ir_variable *const var = d->variable_referenced();
+	    ir_variable *const var = d->variable_referenced();
 
-	 assert(var != NULL);
+	    assert(var != NULL);
 
-	 if (var->data.max_array_access >= unsigned(rhs->type->array_size())) {
-	    /* FINISHME: This should actually log the location of the RHS. */
-	    _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to "
-			     "previous access",
-			     var->data.max_array_access);
-	 }
+	    if (var->data.max_array_access >=
+                unsigned(rhs->type->array_size())) {
+	       /* FINISHME: This should actually log the location of the RHS.*/
+	       _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due"
+			        " to previous access",
+			        var->data.max_array_access);
+	    }
 
-	 var->type = glsl_type::get_array_instance(lhs->type->element_type(),
-						   rhs->type->array_size());
-	 d->type = var->type;
+	    var->type = glsl_type::get_array_instance(lhs->type->element_type(),
+						      rhs->type->array_size());
+	    d->type = var->type;
+         }
+         mark_whole_array_access(rhs);
+         mark_whole_array_access(lhs);
       }
-      mark_whole_array_access(rhs);
-      mark_whole_array_access(lhs);
    }
 
    /* Most callers of do_assignment (assign, add_assign, pre_inc/dec,
-- 
1.8.3.1



More information about the mesa-dev mailing list