Skip to content

Commit 478b232

Browse files
authored
8. io mapping refine & qualifier member check & resolver expand (KhronosGroup#2396)
* Code refine and adding missing features 1. Add new level for built in symbols. 2. Fix issues for structure members' qualifiers. 3. Global qualifier fix. 4. IO Mapper refine. Add support for checking with mangle names. * Additional missing features * Invariant member. (Only check non-interface). * Split block nesting level and struct nesting level. To fix issues of checking 'invariant' qualifier. Current grammar would check block/struct member without its parent class's information. So we split nesting level, and 'invariant' would only be checked within a struct. * Format anonymous block names. Refine codes for symbols from all kinds of resouces. * Fix writeonly check. * Use LValueBase to find operator. * Fix random null ptr issue. * invariant check, stage in io mapping, reference parameter should be used and remove wrong codes introduced with ordering vector. * Remained: to be fixed with double check link.vk.multiblocksValid * Fix version error. invariant * Revert loc modification.
1 parent d550beb commit 478b232

25 files changed

+565
-149
lines changed

SPIRV/GlslangToSpv.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3959,6 +3959,8 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
39593959
// Name and decorate the non-hidden members
39603960
int offset = -1;
39613961
int locationOffset = 0; // for use within the members of this struct
3962+
bool memberLocationInvalid = type.isArrayOfArrays() ||
3963+
(type.isArray() && (type.getQualifier().isArrayedIo(glslangIntermediate->getStage()) == false));
39623964
for (int i = 0; i < (int)glslangMembers->size(); i++) {
39633965
glslang::TType& glslangMember = *(*glslangMembers)[i].type;
39643966
int member = i;
@@ -4011,7 +4013,7 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
40114013
// just track whether a member needs to be decorated.
40124014
// Ignore member locations if the container is an array, as that's
40134015
// ill-specified and decisions have been made to not allow this.
4014-
if (! type.isArray() && memberQualifier.hasLocation())
4016+
if (!memberLocationInvalid && memberQualifier.hasLocation())
40154017
builder.addMemberDecoration(spvType, member, spv::DecorationLocation, memberQualifier.layoutLocation);
40164018

40174019
if (qualifier.hasLocation()) // track for upcoming inheritance

Test/baseResults/300layout.vert.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
300layout.vert
22
ERROR: 0:7: 'vertex input arrays' : not supported with this profile: es
33
ERROR: 0:8: 'in' : cannot be a structure or array
4+
ERROR: 0:8: 's' : A structure containing an array is not allowed as input in ES
45
ERROR: 0:8: 'vertex input arrays' : not supported with this profile: es
56
ERROR: 0:8: 'location' : overlapping use of location 10
67
ERROR: 0:12: 'layout' : cannot specify matrix layout on a variable declaration
@@ -18,7 +19,7 @@ ERROR: 0:50: 'shared' : not supported for this version or the enabled extensions
1819
ERROR: 0:50: 'shared' : not supported in this stage: vertex
1920
ERROR: 0:54: 'layout' : cannot specify packing on a variable declaration
2021
ERROR: 0:57: 'location' : overlapping use of location 40
21-
ERROR: 19 compilation errors. No code generated.
22+
ERROR: 20 compilation errors. No code generated.
2223

2324

2425
Shader version: 300

Test/baseResults/310.frag.out

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ ERROR: 0:112: 'out' : cannot be a matrix
4040
ERROR: 0:114: 'in' : cannot be bool
4141
ERROR: 0:115: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: ino
4242
ERROR: 0:117: 'fragment-shader array-of-array input' : not supported with this profile: es
43+
ERROR: 0:120: 'S' : A structure containing an array is not allowed as input in ES
4344
ERROR: 0:120: 'fragment-shader array-of-struct input' : not supported with this profile: es
45+
ERROR: 0:121: 'S' : A structure containing an array is not allowed as input in ES
4446
ERROR: 0:121: 'fragment-shader array-of-struct input' : not supported with this profile: es
4547
ERROR: 0:123: 'fragment-shader struct input containing an array' : not supported with this profile: es
48+
ERROR: 0:123: 'SA' : A structure containing an array is not allowed as input in ES
4649
ERROR: 0:125: 'fragment-shader struct input containing structure' : not supported with this profile: es
50+
ERROR: 0:125: 'SS' : A structure containing an struct is not allowed as input in ES
4751
ERROR: 0:133: 'output block' : not supported in this stage: fragment
4852
ERROR: 0:138: '' : cannot nest a structure definition inside a structure or block
4953
ERROR: 0:146: 'location' : overlapping use of location 13
@@ -139,7 +143,7 @@ ERROR: 0:461: 'func' : function already has a body
139143
ERROR: 0:463: 'return' : void function cannot return a value
140144
ERROR: 0:472: '=' : cannot convert from ' temp mediump uint' to ' temp mediump int'
141145
ERROR: 0:485: '=' : cannot convert from ' global mediump int' to ' temp mediump uint'
142-
ERROR: 132 compilation errors. No code generated.
146+
ERROR: 136 compilation errors. No code generated.
143147

144148

145149
Shader version: 310

Test/baseResults/310.vert.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ERROR: 0:105: 'location' : overlapping use of location 12
2121
ERROR: 0:107: 'input block' : not supported in this stage: vertex
2222
ERROR: 0:109: 'gl_PerVertex' : block redeclaration has extra members
2323
ERROR: 0:119: 'gl_PointSize' : member of nameless block was not redeclared
24+
ERROR: 0:119: 'assign' : l-value required "gl_PerVertex" (can't modify void)
2425
ERROR: 0:119: 'assign' : cannot convert from ' const float' to ' gl_PointSize highp void PointSize'
2526
ERROR: 0:122: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
2627
ERROR: 0:127: 'flat/smooth/noperspective' : cannot use interpolation qualifiers on an interface block
@@ -96,7 +97,7 @@ ERROR: 0:389: 'sample' : Reserved word.
9697
ERROR: 0:400: 'interpolateAtCentroid' : no matching overloaded function found
9798
ERROR: 0:401: 'interpolateAtSample' : no matching overloaded function found
9899
ERROR: 0:402: 'interpolateAtOffset' : no matching overloaded function found
99-
ERROR: 93 compilation errors. No code generated.
100+
ERROR: 94 compilation errors. No code generated.
100101

101102

102103
Shader version: 310

Test/baseResults/320.vert.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ERROR: 0:14: 'location' : overlapping use of location 12
44
ERROR: 0:16: 'input block' : not supported in this stage: vertex
55
ERROR: 0:18: 'gl_PerVertex' : block redeclaration has extra members
66
ERROR: 0:28: 'gl_PointSize' : member of nameless block was not redeclared
7+
ERROR: 0:28: 'assign' : l-value required "gl_PerVertex" (can't modify void)
78
ERROR: 0:28: 'assign' : cannot convert from ' const float' to ' gl_PointSize highp void PointSize'
89
ERROR: 0:31: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
910
ERROR: 0:36: 'flat/smooth/noperspective' : cannot use interpolation qualifiers on an interface block
@@ -33,7 +34,7 @@ ERROR: 0:211: '=' : cannot convert from ' const float' to ' temp highp 3-compon
3334
ERROR: 0:252: 'interpolateAtCentroid' : no matching overloaded function found
3435
ERROR: 0:253: 'interpolateAtSample' : no matching overloaded function found
3536
ERROR: 0:254: 'interpolateAtOffset' : no matching overloaded function found
36-
ERROR: 34 compilation errors. No code generated.
37+
ERROR: 35 compilation errors. No code generated.
3738

3839

3940
Shader version: 320

Test/baseResults/410.geom.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ ERROR: 0:20: 'gl_PerVertex' : can only redeclare a built-in block once, and befo
55
ERROR: 0:32: 'gl_Position' : no such field in structure
66
ERROR: 0:32: '=' : cannot convert from ' temp block{ in float PointSize gl_PointSize}' to ' temp 4-component vector of float'
77
ERROR: 0:33: 'gl_Position' : member of nameless block was not redeclared
8+
ERROR: 0:33: 'assign' : l-value required "gl_PerVertex" (can't modify void)
89
ERROR: 0:33: 'assign' : cannot convert from ' const 4-component vector of float' to 'layout( stream=0) gl_Position void Position'
910
WARNING: 0:38: 'return' : type conversion on return values was not explicitly allowed until version 420
10-
ERROR: 7 compilation errors. No code generated.
11+
ERROR: 8 compilation errors. No code generated.
1112

1213

1314
Shader version: 410

Test/baseResults/hlsl.structbuffer.append.fn.frag.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ Validation failed
190190
Decorate 9 BufferBlock
191191
Decorate 12 BufferBlock
192192
Decorate 49(sbuf_a) DescriptorSet 0
193-
Decorate 49(sbuf_a) Binding 4
193+
Decorate 49(sbuf_a) Binding 0
194194
Decorate 50(sbuf_a@count) DescriptorSet 0
195-
Decorate 50(sbuf_a@count) Binding 6
195+
Decorate 50(sbuf_a@count) Binding 0
196196
Decorate 51(sbuf_c) DescriptorSet 0
197-
Decorate 51(sbuf_c) Binding 5
197+
Decorate 51(sbuf_c) Binding 1
198198
Decorate 52(sbuf_c@count) DescriptorSet 0
199-
Decorate 52(sbuf_c@count) Binding 7
199+
Decorate 52(sbuf_c@count) Binding 0
200200
Decorate 58(pos) Flat
201201
Decorate 58(pos) Location 0
202202
Decorate 61(@entryPointOutput) Location 0

Test/baseResults/hlsl.structbuffer.fn.frag.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ Validation failed
191191
Decorate 18 BufferBlock
192192
Decorate 20 BufferBlock
193193
Decorate 47(sbuf2) DescriptorSet 0
194-
Decorate 47(sbuf2) Binding 2
194+
Decorate 47(sbuf2) Binding 0
195195
Decorate 48(sbuf2@count) DescriptorSet 0
196-
Decorate 48(sbuf2@count) Binding 3
196+
Decorate 48(sbuf2@count) Binding 0
197197
Decorate 50(sbuf) DescriptorSet 0
198198
Decorate 50(sbuf) Binding 10
199199
Decorate 63(pos) Flat

Test/baseResults/link.vk.multiBlocksValid.0.0.vert.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Shader version: 430
211211
Name 70 "BufferBlock"
212212
MemberName 70(BufferBlock) 0 "p"
213213
Name 72 "uBuf"
214-
Decorate 14(oColor) Location 4
214+
Decorate 14(oColor) Location 2
215215
MemberDecorate 16(ColorBlock) 0 Offset 0
216216
MemberDecorate 16(ColorBlock) 1 Offset 16
217217
MemberDecorate 16(ColorBlock) 2 Offset 32
@@ -224,7 +224,7 @@ Shader version: 430
224224
Decorate 28(uColorBuf) DescriptorSet 0
225225
Decorate 28(uColorBuf) Binding 0
226226
Decorate 32(Vertex) Block
227-
Decorate 34(oV) Location 2
227+
Decorate 34(oV) Location 0
228228
MemberDecorate 40(gl_PerVertex) 0 BuiltIn Position
229229
MemberDecorate 40(gl_PerVertex) 1 BuiltIn PointSize
230230
MemberDecorate 40(gl_PerVertex) 2 BuiltIn ClipDistance

Test/baseResults/link.vk.multiBlocksValid.1.0.geom.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ output primitive = triangle_strip
304304
MemberName 95(BufferBlock) 0 "p"
305305
Name 97 "uBuf"
306306
Name 100 "P"
307-
Decorate 18(oColor) Location 2
307+
Decorate 18(oColor) Location 1
308308
MemberDecorate 20(ColorBlock) 0 Offset 0
309309
MemberDecorate 20(ColorBlock) 1 Offset 16
310310
MemberDecorate 20(ColorBlock) 2 Offset 32
@@ -326,16 +326,16 @@ output primitive = triangle_strip
326326
Decorate 50(uM) DescriptorSet 0
327327
Decorate 50(uM) Binding 0
328328
Decorate 59(Vertex) Block
329-
Decorate 61(oV) Location 1
329+
Decorate 61(oV) Location 0
330330
Decorate 64(Vertex) Block
331-
Decorate 68(iV) Location 0
331+
Decorate 68(iV) Location 1
332332
MemberDecorate 95(BufferBlock) 0 ColMajor
333333
MemberDecorate 95(BufferBlock) 0 Offset 0
334334
MemberDecorate 95(BufferBlock) 0 MatrixStride 16
335335
Decorate 95(BufferBlock) BufferBlock
336336
Decorate 97(uBuf) DescriptorSet 0
337337
Decorate 97(uBuf) Binding 1
338-
Decorate 100(P) Location 4
338+
Decorate 100(P) Location 0
339339
2: TypeVoid
340340
3: TypeFunction 2
341341
6: TypeFloat 32

0 commit comments

Comments
 (0)