Mesa (master): glsl: Assign array and matrix stride values according to std140 layout.
Eric Anholt
anholt at kemper.freedesktop.org
Tue Jul 31 19:21:42 UTC 2012
Module: Mesa
Branch: master
Commit: bbd1d6124d8d59d7b3f8585505ce3c01aa062e28
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bbd1d6124d8d59d7b3f8585505ce3c01aa062e28
Author: Eric Anholt <eric at anholt.net>
Date: Fri Jun 22 14:34:33 2012 -0700
glsl: Assign array and matrix stride values according to std140 layout.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glsl/link_uniforms.cpp | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index d7ef5d4..1baa46c 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;
More information about the mesa-commit
mailing list