diff options
author | Eric Anholt <eric@anholt.net> | 2012-07-25 12:45:13 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2012-08-07 13:54:51 -0700 |
commit | e45f1b11c081a7b965bf58539d2dbcc231d543f4 (patch) | |
tree | 5a3f2ba1dd48d719c7d6948843582154b6ad3b09 /src/glsl | |
parent | 86e0045578cd8d8be7736a8f56e2b51d61bda32a (diff) | |
download | external_mesa3d-e45f1b11c081a7b965bf58539d2dbcc231d543f4.zip external_mesa3d-e45f1b11c081a7b965bf58539d2dbcc231d543f4.tar.gz external_mesa3d-e45f1b11c081a7b965bf58539d2dbcc231d543f4.tar.bz2 |
glsl: Align GL_UNIFORM_BLOCK_DATA_SIZE according to std140 rules.
Fixes piglit GL_ARB_uniform_buffer_object/data-size test.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 4f21a41..25dc1d7 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -500,7 +500,19 @@ link_assign_uniform_block_offsets(struct gl_shader *shader) ubo_var->Offset = offset; offset += size; } - block->UniformBufferSize = offset; + + /* From the GL_ARB_uniform_buffer_object spec: + * + * "For uniform blocks laid out according to [std140] rules, + * the minimum buffer object size returned by the + * UNIFORM_BLOCK_DATA_SIZE query is derived by taking the + * offset of the last basic machine unit consumed by the + * last uniform of the uniform block (including any + * end-of-array or end-of-structure padding), adding one, + * and rounding up to the next multiple of the base + * alignment required for a vec4." + */ + block->UniformBufferSize = align(offset, 16); } } |