glsl: Assign array and matrix stride values according to std140 layout.
authorEric Anholt <eric@anholt.net>
Fri, 22 Jun 2012 21:34:33 +0000 (14:34 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 31 Jul 2012 19:06:20 +0000 (12:06 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/link_uniforms.cpp

index d7ef5d4d2811b84293954ddcb4109b6e41625ee7..1baa46c5d52c7098529ae0984c605f25c9a1bdc4 100644 (file)
@@ -328,10 +328,21 @@ private:
         this->uniforms[id].offset = this->ubo_byte_offset;
         this->ubo_byte_offset += type->std140_size(ubo_var->RowMajor);
 
-        this->uniforms[id].array_stride = 0;
-        this->uniforms[id].matrix_stride = 0;
-        this->uniforms[id].row_major = base_type->is_matrix() &&
-           ubo_var->RowMajor;
+        if (type->is_array()) {
+           this->uniforms[id].array_stride =
+              align(type->fields.array->std140_size(ubo_var->RowMajor), 16);
+        } else {
+           this->uniforms[id].array_stride = 0;
+        }
+
+        if (type->is_matrix() ||
+            (type->is_array() && type->fields.array->is_matrix())) {
+           this->uniforms[id].matrix_stride = 16;
+           this->uniforms[id].row_major = ubo_var->RowMajor;
+        } else {
+           this->uniforms[id].matrix_stride = 0;
+           this->uniforms[id].row_major = false;
+        }
       } else {
         this->uniforms[id].block_index = -1;
         this->uniforms[id].offset = -1;