diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2013-08-17 00:27:43 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2013-08-19 16:39:04 -0700 |
commit | 574e4843e9e26aa6affa31c80ac42f745b68268b (patch) | |
tree | 6ce82887a557f927b81c3393d49aac2d29e2d44b /src/glsl/link_uniforms.cpp | |
parent | 5ac884fd9f213baed1de52eb7d17b86455c48a02 (diff) | |
download | external_mesa3d-574e4843e9e26aa6affa31c80ac42f745b68268b.zip external_mesa3d-574e4843e9e26aa6affa31c80ac42f745b68268b.tar.gz external_mesa3d-574e4843e9e26aa6affa31c80ac42f745b68268b.tar.bz2 |
glsl: Use alignment of container record for its first field
The first field of a record in a UBO has the aligment of the record
itself.
Fixes piglit vs-struct-pad, fs-struct-pad, and (with the patch posted to
the piglit list that extends the test) layout-std140.
NOTE: The bit of strangeness with the version of visit_field without the
record_type poitner is because that method is pure virtual in the base
class. The original implementation of the class did this to ensure
derived classes remembered to implement that flavor. Now they can
implement either flavor but not both. I don't know a C++ way to enforce
that.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68195
Cc: "9.2 9.1" mesa-stable@lists.freedesktop.org
Diffstat (limited to 'src/glsl/link_uniforms.cpp')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 095895b..fa77157 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -402,6 +402,15 @@ private: virtual void visit_field(const glsl_type *type, const char *name, bool row_major) { + (void) type; + (void) name; + (void) row_major; + assert(!"Should not get here."); + } + + virtual void visit_field(const glsl_type *type, const char *name, + bool row_major, const glsl_type *record_type) + { assert(!type->is_record()); assert(!(type->is_array() && type->fields.array->is_record())); assert(!type->is_interface()); @@ -446,7 +455,9 @@ private: if (this->ubo_block_index != -1) { this->uniforms[id].block_index = this->ubo_block_index; - unsigned alignment = type->std140_base_alignment(ubo_row_major); + const unsigned alignment = record_type + ? record_type->std140_base_alignment(ubo_row_major) + : type->std140_base_alignment(ubo_row_major); this->ubo_byte_offset = glsl_align(this->ubo_byte_offset, alignment); this->uniforms[id].offset = this->ubo_byte_offset; this->ubo_byte_offset += type->std140_size(ubo_row_major); |