summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-06-22 14:34:33 -0700
committerEric Anholt <[email protected]>2012-07-31 12:06:20 -0700
commitbbd1d6124d8d59d7b3f8585505ce3c01aa062e28 (patch)
tree5812e08160f03f4ecb6ab8ecca8e7b95f50fe915 /src
parent551bdf25bc4e57bea51c54da7e31c44c507e6c9f (diff)
glsl: Assign array and matrix stride values according to std140 layout.
Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/link_uniforms.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index d7ef5d4d281..1baa46c5d52 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -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;