glsl: add std140 layout support for AoA
authorTimothy Arceri <t_arceri@yahoo.com.au>
Fri, 18 Sep 2015 12:51:40 +0000 (22:51 +1000)
committerTimothy Arceri <t_arceri@yahoo.com.au>
Thu, 15 Oct 2015 09:44:33 +0000 (20:44 +1100)
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/glsl_types.cpp

index 575ff0e1c2bc85e0af3909c98d75113b6b310fcf..27934478e2dafb945fec37c1bb31581f30e721ac 100644 (file)
@@ -1330,8 +1330,8 @@ glsl_type::std140_size(bool row_major) const
       unsigned int array_len;
 
       if (this->is_array()) {
-         element_type = this->fields.array;
-         array_len = this->length;
+         element_type = this->without_array();
+         array_len = this->arrays_of_arrays_size();
       } else {
          element_type = this;
          array_len = 1;
@@ -1364,12 +1364,13 @@ glsl_type::std140_size(bool row_major) const
     *      the array are laid out in order, according to rule (9).
     */
    if (this->is_array()) {
-      if (this->fields.array->is_record()) {
-         return this->length * this->fields.array->std140_size(row_major);
+      if (this->without_array()->is_record()) {
+        return this->arrays_of_arrays_size() *
+            this->without_array()->std140_size(row_major);
       } else {
-         unsigned element_base_align =
-            this->fields.array->std140_base_alignment(row_major);
-         return this->length * MAX2(element_base_align, 16);
+        unsigned element_base_align =
+           this->without_array()->std140_base_alignment(row_major);
+        return this->arrays_of_arrays_size() * MAX2(element_base_align, 16);
       }
    }