GL_ARB_enhanced_layouts, part 6: Numerical side of uniform offset and align semantics. Included

- moving offset calculations for std140/std430 from reflection to linkValidate.cpp
 - applying the offset/align rules on top of std140/std430
 - removing caching the structure's number of components (and correcting that this is components, not size)


git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@25174 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich
2014-01-31 02:40:19 +00:00
parent 04b1c6ed4c
commit ac1e188f3b
15 changed files with 367 additions and 219 deletions

View File

@@ -79,13 +79,58 @@ uniform ubl11 {
layout(std140) uniform block {
vec4 a; // a takes offsets 0-15
layout(offset = 20) vec3 b; // b takes offsets 32-43
layout(offset = 32) vec3 b; // b takes offsets 32-43
layout(offset = 40) vec2 c; // ERROR, lies within previous member
layout(align = 6) double g; // ERROR, 6 is not a power of 2
layout(offset=68) double h; // ERROR, offset not aligned
} specExampleErrors;
layout(std140) uniform block2 {
vec4 a; // a takes offsets 0-15
layout(offset = 32) vec3 b; // b takes offsets 32-43
layout(offset = 48) vec2 d; // d takes offsets 48-55
layout(align = 16) float e; // e takes offsets 64-67
layout(align = 2) double f; // f takes offsets 72-79
layout(align = 6) double g; // ERROR, 6 is not a power of 2
layout(offset = 80) float h; // h takes offsets 80-83
layout(align = 64) dvec3 i; // i takes offsets 128-151
layout(offset = 153, align = 8) float j; // j takes offsets 160-163
layout(offset = 164, align = 8) float j; // j takes offsets 168-171
} specExample;
layout(std430) uniform block430 {
vec4 a; // a takes offsets 0-15
layout(offset = 32) vec3 b; // b takes offsets 32-43
layout(offset = 40) vec2 c; // ERROR, lies within previous member
layout(align = 6) double g; // ERROR, 6 is not a power of 2
layout(offset=68) double h; // ERROR, offset not aligned
} specExampleErrors430;
layout(std430) uniform block2430 {
vec4 a; // a takes offsets 0-15
layout(offset = 32) vec3 b; // b takes offsets 32-43
layout(offset = 48) vec2 d; // d takes offsets 48-55
layout(align = 16) float e; // e takes offsets 64-67
layout(align = 2) double f; // f takes offsets 72-79
layout(offset = 80) float h; // h takes offsets 80-83
layout(align = 64) dvec3 i; // i takes offsets 128-151
layout(offset = 164, align = 8) float j; // j takes offsets 168-171
} specExample430;
layout(std430, align = 128) uniform block24300 {
vec4 a;
vec3 b;
vec2 d;
float e;
double f;
float h;
dvec3 i;
} specExample4300;
layout(std430, align = 128) uniform block24301 {
vec4 a;
vec3 b;
vec2 d;
layout(offset=388) float e;
layout(align=8) double f;
float h;
dvec3 i;
} specExample4301;

View File

@@ -32,12 +32,12 @@ ERROR: node is still EOpNull!
0:46 add (highp 4X4 matrix of float)
0:46 add (highp 4X4 matrix of float)
0:46 add (highp 4X4 matrix of float)
0:46 M1: direct index for structure (layout(row_major std140 ) uniform highp 4X4 matrix of float)
0:46 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 ) centroid uniform highp float badf, layout(row_major std140 ) uniform highp float badg, layout(row_major std140 ) uniform highp float bad1, layout(row_major shared ) uniform highp float bad2, layout(row_major packed ) uniform highp float bad3})
0:46 M1: direct index for structure (layout(row_major std140 offset=0 ) uniform highp 4X4 matrix of float)
0:46 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 offset=0 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 offset=64 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 offset=128 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 offset=176 ) centroid uniform highp float badf, layout(row_major std140 offset=180 ) uniform highp float badg, layout(row_major std140 offset=184 ) uniform highp float bad1, layout(row_major shared offset=188 ) uniform highp float bad2, layout(row_major packed offset=192 ) uniform highp float bad3})
0:46 Constant:
0:46 0 (const int)
0:46 M2: direct index for structure (layout(column_major std140 ) uniform highp 4X4 matrix of float)
0:46 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 ) centroid uniform highp float badf, layout(row_major std140 ) uniform highp float badg, layout(row_major std140 ) uniform highp float bad1, layout(row_major shared ) uniform highp float bad2, layout(row_major packed ) uniform highp float bad3})
0:46 M2: direct index for structure (layout(column_major std140 offset=64 ) uniform highp 4X4 matrix of float)
0:46 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 offset=0 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 offset=64 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 offset=128 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 offset=176 ) centroid uniform highp float badf, layout(row_major std140 offset=180 ) uniform highp float badg, layout(row_major std140 offset=184 ) uniform highp float bad1, layout(row_major shared offset=188 ) uniform highp float bad2, layout(row_major packed offset=192 ) uniform highp float bad3})
0:46 Constant:
0:46 1 (const int)
0:46 M4: direct index for structure (layout(row_major shared ) uniform highp 4X4 matrix of float)
@@ -56,8 +56,8 @@ ERROR: node is still EOpNull!
0:47 'color' (smooth out highp 3-component vector of float)
0:47 vector-times-matrix (highp 3-component vector of float)
0:47 'c' (layout(location=7 ) in highp 3-component vector of float)
0:47 N1: direct index for structure (layout(row_major std140 ) uniform highp 3X3 matrix of float)
0:47 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 ) centroid uniform highp float badf, layout(row_major std140 ) uniform highp float badg, layout(row_major std140 ) uniform highp float bad1, layout(row_major shared ) uniform highp float bad2, layout(row_major packed ) uniform highp float bad3})
0:47 N1: direct index for structure (layout(row_major std140 offset=128 ) uniform highp 3X3 matrix of float)
0:47 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 offset=0 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 offset=64 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 offset=128 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 offset=176 ) centroid uniform highp float badf, layout(row_major std140 offset=180 ) uniform highp float badg, layout(row_major std140 offset=184 ) uniform highp float bad1, layout(row_major shared offset=188 ) uniform highp float bad2, layout(row_major packed offset=192 ) uniform highp float bad3})
0:47 Constant:
0:47 2 (const int)
0:? Linker Objects
@@ -68,7 +68,7 @@ ERROR: node is still EOpNull!
0:? 'pos' (smooth out highp 4-component vector of float)
0:? 'color' (smooth out highp 3-component vector of float)
0:? 'badm4' (layout(column_major shared ) uniform highp 4X4 matrix of float)
0:? 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 ) centroid uniform highp float badf, layout(row_major std140 ) uniform highp float badg, layout(row_major std140 ) uniform highp float bad1, layout(row_major shared ) uniform highp float bad2, layout(row_major packed ) uniform highp float bad3})
0:? 'tblock' (layout(row_major std140 ) uniform block{layout(row_major std140 offset=0 ) uniform highp 4X4 matrix of float M1, layout(column_major std140 offset=64 ) uniform highp 4X4 matrix of float M2, layout(row_major std140 offset=128 ) uniform highp 3X3 matrix of float N1, layout(row_major std140 offset=176 ) centroid uniform highp float badf, layout(row_major std140 offset=180 ) uniform highp float badg, layout(row_major std140 offset=184 ) uniform highp float bad1, layout(row_major shared offset=188 ) uniform highp float bad2, layout(row_major packed offset=192 ) uniform highp float bad3})
0:? '__anon__0' (layout(row_major shared ) uniform block{layout(row_major shared ) uniform bool b, layout(row_major shared ) uniform highp 4X4 matrix of float t2m})
0:? '__anon__2' (out block{out highp float f})
0:? 'badoutA' (layout(location=10 ) smooth out highp 4-component vector of float)

View File

@@ -39,8 +39,13 @@ ERROR: 0:58: 'align' : can only be used with std140 or std430 layout packing
ERROR: 0:63: 'align' : can only be used with std140 or std430 layout packing
ERROR: 0:62: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:63: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:87: 'align' : must be a power of 2
ERROR: 40 compilation errors. No code generated.
ERROR: 0:84: 'align' : must be a power of 2
ERROR: 0:83: 'offset' : cannot lie in previous members
ERROR: 0:85: 'offset' : must be a multiple of the member's alignment
ERROR: 0:103: 'align' : must be a power of 2
ERROR: 0:102: 'offset' : cannot lie in previous members
ERROR: 0:104: 'offset' : must be a multiple of the member's alignment
ERROR: 45 compilation errors. No code generated.
ERROR: node is still EOpNull!
@@ -56,7 +61,7 @@ ERROR: node is still EOpNull!
0:? 'inst1' (layout(column_major shared offset=12 ) uniform block{layout(column_major shared ) uniform int a})
0:? 'inst2' (layout(offset=12 ) in block{in int a})
0:? 'inst3' (layout(offset=12 ) out block{out int a})
0:? 'inst4' (layout(column_major std140 align=16 ) uniform block{layout(column_major std140 align=16 ) uniform int a})
0:? 'inst4' (layout(column_major std140 align=16 ) uniform block{layout(column_major std140 offset=0 align=16 ) uniform int a})
0:? 'inst8' (layout(column_major shared align=16 ) uniform block{layout(column_major shared ) uniform int a})
0:? 'inst5' (layout(align=16 ) in block{in int a})
0:? 'inst6' (layout(align=16 ) out block{out int a})
@@ -71,7 +76,12 @@ ERROR: node is still EOpNull!
0:? 'inst10' (in block{layout(offset=12 ) in float f, layout(align=4 ) in float g})
0:? 'inst9' (layout(column_major std430 align=32 ) uniform block{layout(column_major std430 align=32 ) uniform float e, layout(column_major std430 offset=12 align=4 ) uniform float f, layout(column_major std430 offset=20 align=32 ) uniform float g, layout(column_major std430 align=32 ) uniform float h})
0:? 'inst11' (layout(column_major std430 ) uniform block{layout(column_major std430 offset=12 align=4 ) uniform float f, layout(column_major std430 ) uniform float g})
0:? 'specExample' (layout(column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float a, layout(column_major std140 offset=20 ) uniform 3-component vector of float b, layout(column_major std140 offset=40 ) uniform 2-component vector of float c, layout(column_major std140 offset=48 ) uniform 2-component vector of float d, layout(column_major std140 align=16 ) uniform float e, layout(column_major std140 align=2 ) uniform double f, layout(column_major std140 ) uniform double g, layout(column_major std140 offset=80 ) uniform float h, layout(column_major std140 align=64 ) uniform 3-component vector of double i, layout(column_major std140 offset=153 align=8 ) uniform float j})
0:? 'specExampleErrors' (layout(column_major std140 ) uniform block{layout(column_major std140 offset=0 ) uniform 4-component vector of float a, layout(column_major std140 offset=32 ) uniform 3-component vector of float b, layout(column_major std140 offset=48 ) uniform 2-component vector of float c, layout(column_major std140 offset=56 ) uniform double g, layout(column_major std140 offset=72 ) uniform double h})
0:? 'specExample' (layout(column_major std140 ) uniform block{layout(column_major std140 offset=0 ) uniform 4-component vector of float a, layout(column_major std140 offset=32 ) uniform 3-component vector of float b, layout(column_major std140 offset=48 ) uniform 2-component vector of float d, layout(column_major std140 offset=64 align=16 ) uniform float e, layout(column_major std140 offset=72 align=2 ) uniform double f, layout(column_major std140 offset=80 ) uniform float h, layout(column_major std140 offset=128 align=64 ) uniform 3-component vector of double i, layout(column_major std140 offset=168 align=8 ) uniform float j})
0:? 'specExampleErrors430' (layout(column_major std430 ) uniform block{layout(column_major std430 offset=0 ) uniform 4-component vector of float a, layout(column_major std430 offset=32 ) uniform 3-component vector of float b, layout(column_major std430 offset=48 ) uniform 2-component vector of float c, layout(column_major std430 offset=56 ) uniform double g, layout(column_major std430 offset=72 ) uniform double h})
0:? 'specExample430' (layout(column_major std430 ) uniform block{layout(column_major std430 offset=0 ) uniform 4-component vector of float a, layout(column_major std430 offset=32 ) uniform 3-component vector of float b, layout(column_major std430 offset=48 ) uniform 2-component vector of float d, layout(column_major std430 offset=64 align=16 ) uniform float e, layout(column_major std430 offset=72 align=2 ) uniform double f, layout(column_major std430 offset=80 ) uniform float h, layout(column_major std430 offset=128 align=64 ) uniform 3-component vector of double i, layout(column_major std430 offset=168 align=8 ) uniform float j})
0:? 'specExample4300' (layout(column_major std430 align=128 ) uniform block{layout(column_major std430 offset=0 align=128 ) uniform 4-component vector of float a, layout(column_major std430 offset=128 align=128 ) uniform 3-component vector of float b, layout(column_major std430 offset=256 align=128 ) uniform 2-component vector of float d, layout(column_major std430 offset=384 align=128 ) uniform float e, layout(column_major std430 offset=512 align=128 ) uniform double f, layout(column_major std430 offset=640 align=128 ) uniform float h, layout(column_major std430 offset=768 align=128 ) uniform 3-component vector of double i})
0:? 'specExample4301' (layout(column_major std430 align=128 ) uniform block{layout(column_major std430 offset=0 align=128 ) uniform 4-component vector of float a, layout(column_major std430 offset=128 align=128 ) uniform 3-component vector of float b, layout(column_major std430 offset=256 align=128 ) uniform 2-component vector of float d, layout(column_major std430 offset=512 align=128 ) uniform float e, layout(column_major std430 offset=520 align=8 ) uniform double f, layout(column_major std430 offset=640 align=128 ) uniform float h, layout(column_major std430 offset=768 align=128 ) uniform 3-component vector of double i})
Linked fragment stage:

View File

@@ -289,7 +289,7 @@ ERROR: node is still EOpNull!
0:? 'var5' (smooth out 4-component vector of float)
0:? '__anon__2' (out block{out 4-component vector of float var6})
0:? 'var7' (smooth out 4-component vector of float)
0:? '__anon__3' (layout(row_major std140 ) uniform block{layout(row_major std140 ) uniform 4X4 matrix of float M1, layout(column_major std140 ) uniform 4X4 matrix of float M2, layout(row_major std140 ) uniform 3X3 matrix of float N1})
0:? '__anon__3' (layout(row_major std140 ) uniform block{layout(row_major std140 offset=0 ) uniform 4X4 matrix of float M1, layout(column_major std140 offset=64 ) uniform 4X4 matrix of float M2, layout(row_major std140 offset=128 ) uniform 3X3 matrix of float N1})
0:? '__anon__4' (layout(column_major shared ) uniform block{layout(column_major shared ) uniform 4X4 matrix of float M13, layout(row_major shared ) uniform 4X4 matrix of float m14, layout(column_major shared ) uniform 3X3 matrix of float N12})
0:? 's17' (layout(binding=3 ) uniform sampler2D)
0:? 'a2' (layout(binding=2 offset=4 ) uniform int)