summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_uniform_blocks.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2014-07-16 15:40:32 -0700
committerIan Romanick <[email protected]>2014-08-04 14:40:07 -0700
commit7f731340d25b0c4a86ec3cc7b9a33f66c4818c2b (patch)
tree566febb63703c9ee54540c7d2e6ff8cf6f79d0d3 /src/glsl/link_uniform_blocks.cpp
parent47c6fc5b04774737404b55b01cbab5c3baf1c183 (diff)
linker: Add padding after the last field of a structure
This causes the thing following the structure to be vec4-aligned. Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.random.nested_structs.2 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.5 Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/glsl/link_uniform_blocks.cpp')
-rw-r--r--src/glsl/link_uniform_blocks.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp
index ddd134a348a..3768205ee1f 100644
--- a/src/glsl/link_uniform_blocks.cpp
+++ b/src/glsl/link_uniform_blocks.cpp
@@ -104,7 +104,20 @@ private:
this->offset = glsl_align(this->offset, alignment);
v->Offset = this->offset;
+
+ /* If this is the last field of a structure, apply rule #9. The
+ * GL_ARB_uniform_buffer_object spec says:
+ *
+ * "The structure may have padding at the end; the base offset of
+ * the member following the sub-structure is rounded up to the next
+ * multiple of the base alignment of the structure."
+ *
+ * last_field won't be set if this is the last field of a UBO that is
+ * not a named instance.
+ */
this->offset += size;
+ if (last_field)
+ this->offset = glsl_align(this->offset, 16);
/* From the GL_ARB_uniform_buffer_object spec:
*