diff options
author | Niklas Haas <[email protected]> | 2018-12-16 05:40:14 +0100 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2019-01-27 03:00:03 -0500 |
commit | d9bd3b1cb874c44e4250c28605031ddf1c520cd1 (patch) | |
tree | c92eb84e37d30fe4dad577267be8e74ba712abcd /src/compiler/glsl/ast_array_index.cpp | |
parent | 86e5f76d3d5a5608861813c051af2af4c075e814 (diff) |
glsl: fix block member alignment validation for vec3
Section 7.6.2.2 (Standard Uniform Block Layout) of the GL spec says:
The base offset of the first member of a structure is taken from the
aligned offset of the structure itself. The base offset of all other
structure members is derived by taking the offset of the last basic
machine unit consumed by the previous member and adding one.
The current code does not reflect this last sentence - it effectively
instead aligns up the next offset up to the alignment of the previous
member. This causes an issue in exactly one case:
layout(std140) uniform block {
layout(offset=0) vec3 var1;
layout(offset=12) float var2;
};
As per section 7.6.2.1 (Uniform Buffer Object Storage) and elsewhere, a
vec3 consumes 3 floats, i.e. 12 basic machine units. Therefore, `var1`
in the example above consumes units 0-11, with 12 being the first
available offset afterwards. However, before this commit, mesa
incorrectly assumes `var2` must start at offset=16 when using explicit
offsets, which results in a compile-time error. Without explicit
offsets, the shaders actually work fine, indicating that mesa is already
correctly aligning these fields internally. (Just not in the code that
handles explicit buffer offset parsing)
This patch should fix piglit tests:
ssbo-explicit-offset-vec3.vert
ubo-explicit-offset-vec3.vert
Signed-off-by: Niklas Haas <[email protected]>
Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/compiler/glsl/ast_array_index.cpp')
0 files changed, 0 insertions, 0 deletions