Track whether whole-arrays are assignable
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 3 Apr 2010 00:17:47 +0000 (17:17 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 3 Apr 2010 00:17:47 +0000 (17:17 -0700)
In GLSL 1.10 this was not allowed, but in GLSL 1.20 and later it is.

This causes the following tests to pass:

    glslparsertest/glsl2/array-09.vert
    glslparsertest/glsl2/array-13.vert

ast_to_hir.cpp
ir.cpp
ir.h

index cc98581..c0266e9 100644 (file)
@@ -1283,6 +1283,10 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
       var->interpolation = ir_var_noperspective;
    else
       var->interpolation = ir_var_smooth;
+
+   if (var->type->is_array() && (state->language_version >= 120)) {
+      var->array_lvalue = true;
+   }
 }
 
 
diff --git a/ir.cpp b/ir.cpp
index ef93c40..c900a28 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -200,18 +200,14 @@ ir_dereference::is_lvalue()
    if (var == NULL)
       return false;
 
-   /* Arrays are not assignable in GLSL 1.10, but in GLSL 1.20 and later they
-    * are.
-    */
-   /* FINISHME: Handle GLSL 1.10 vs 1.20 differences. */
-   if (this->type->base_type == GLSL_TYPE_ARRAY)
-      return false;
-
    if (mode == ir_reference_variable) {
       ir_variable *const as_var = var->as_variable();
       if (as_var == NULL)
         return false;
 
+      if (as_var->type->is_array() && !as_var->array_lvalue)
+        return false;
+
       return !as_var->read_only;
    } else if (mode == ir_reference_array) {
       /* FINISHME: Walk up the dereference chain and figure out if
diff --git a/ir.h b/ir.h
index 3caff36..5267d2b 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -146,6 +146,14 @@ public:
 
    unsigned mode:3;
    unsigned interpolation:2;
+
+   /**
+    * Flag that the whole array is assignable
+    *
+    * In GLSL 1.20 and later whole arrays are assignable (and comparable for
+    * equality).  This flag enables this behavior.
+    */
+   unsigned array_lvalue:1;
 };