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 <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Ian Romanick
2014-07-16 15:40:32 -07:00
parent 47c6fc5b04
commit 7f731340d2
3 changed files with 25 additions and 3 deletions

View File

@@ -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:
*