Skip to content

Commit bf80843

Browse files
Fix incorrect link errors when multiple compilation units don't declare layouts
when using multiple compilation units, input/output layouts don't need to be declared in every unit. In the same spirit as 6f723eb
1 parent 77799ad commit bf80843

7 files changed

+76
-16
lines changed

Test/baseResults/150.tesc.out

-2
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,6 @@ ERROR: Linking tessellation evaluation stage: can't handle multiple entry points
962962
ERROR: Linking tessellation evaluation stage: Multiple function bodies in multiple compilation units for the same signature in the same stage:
963963
main(
964964
ERROR: Linking tessellation evaluation stage: can't handle multiple entry points per stage
965-
ERROR: Linking tessellation evaluation stage: Contradictory input vertex spacing
966-
ERROR: Linking tessellation evaluation stage: Contradictory triangle ordering
967965
ERROR: Linking tessellation evaluation stage: Multiple function bodies in multiple compilation units for the same signature in the same stage:
968966
main(
969967
ERROR: Linking tessellation evaluation stage: Multiple function bodies in multiple compilation units for the same signature in the same stage:

Test/baseResults/link.multiUnitSingleLayout.0.frag.out

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Shader version: 450
3434

3535
Linked fragment stage:
3636

37-
ERROR: Linking fragment stage: Contradictory depth layouts
3837

3938
Shader version: 450
4039
using depth_greater

Test/baseResults/link.multiUnitSingleLayout.0.mesh.out

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ ERROR: node is still EOpNull!
5555

5656
Linked mesh stage:
5757

58-
ERROR: Linking mesh stage: Contradictory layout max_primitives values
5958

6059
Shader version: 460
6160
Requested GL_EXT_mesh_shader

Test/baseResults/link.multiUnitSingleLayout.0.tese.out

-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ triangle order = none
8686

8787
Linked tessellation evaluation stage:
8888

89-
ERROR: Linking tessellation evaluation stage: Contradictory input vertex spacing
90-
ERROR: Linking tessellation evaluation stage: Contradictory triangle ordering
9189

9290
Shader version: 410
9391
input primitive = triangles

Test/baseResults/link.multiUnitSingleLayout.0.vert.out

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Shader version: 450
4343

4444
Linked vertex stage:
4545

46-
ERROR: Linking vertex stage: Contradictory xfb_stride
4746

4847
Shader version: 450
4948
in xfb mode

Test/baseResults/link.vk.multiUnitSingleLayout.0.comp.out

+70-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ local_size = (1, 1, 1)
4343

4444
Linked compute stage:
4545

46-
ERROR: Linking compute stage: Contradictory local size specialization ids
4746

4847
Shader version: 450
4948
local_size = (1, 1, 1)
@@ -80,5 +79,73 @@ local_size ids = (0, -1, -1)
8079
0:? 1 (const uint)
8180
0:? 'dataBuf' (layout( set=0 binding=0 column_major std430) buffer block{layout( column_major std430) buffer runtime-sized array of highp 4-component vector of float data})
8281

83-
Validation failed
84-
SPIR-V is not generated for failed compile or link
82+
// Module Version 10000
83+
// Generated by (magic number): 8000b
84+
// Id's are bound by 40
85+
86+
Capability Shader
87+
1: ExtInstImport "GLSL.std.450"
88+
MemoryModel Logical GLSL450
89+
EntryPoint GLCompute 4 "main" 14
90+
ExecutionMode 4 LocalSize 1 1 1
91+
Source GLSL 450
92+
Name 4 "main"
93+
Name 10 "do_compute(u1;"
94+
Name 9 "index"
95+
Name 14 "gl_GlobalInvocationID"
96+
Name 15 "param"
97+
Name 24 "DataBuf"
98+
MemberName 24(DataBuf) 0 "data"
99+
Name 26 "dataBuf"
100+
Decorate 14(gl_GlobalInvocationID) BuiltIn GlobalInvocationId
101+
Decorate 23 ArrayStride 16
102+
Decorate 24(DataBuf) BufferBlock
103+
MemberDecorate 24(DataBuf) 0 Offset 0
104+
Decorate 26(dataBuf) Binding 0
105+
Decorate 26(dataBuf) DescriptorSet 0
106+
Decorate 37 SpecId 0
107+
Decorate 39 BuiltIn WorkgroupSize
108+
2: TypeVoid
109+
3: TypeFunction 2
110+
6: TypeInt 32 0
111+
7: TypePointer Function 6(int)
112+
8: TypeFunction 2 7(ptr)
113+
12: TypeVector 6(int) 3
114+
13: TypePointer Input 12(ivec3)
115+
14(gl_GlobalInvocationID): 13(ptr) Variable Input
116+
16: 6(int) Constant 0
117+
17: TypePointer Input 6(int)
118+
21: TypeFloat 32
119+
22: TypeVector 21(float) 4
120+
23: TypeRuntimeArray 22(fvec4)
121+
24(DataBuf): TypeStruct 23
122+
25: TypePointer Uniform 24(DataBuf)
123+
26(dataBuf): 25(ptr) Variable Uniform
124+
27: TypeInt 32 1
125+
28: 27(int) Constant 0
126+
30: 21(float) Constant 1065353216
127+
31: 22(fvec4) ConstantComposite 30 30 30 30
128+
32: TypePointer Uniform 22(fvec4)
129+
37: 6(int) SpecConstant 1
130+
38: 6(int) Constant 1
131+
39: 12(ivec3) SpecConstantComposite 37 38 38
132+
4(main): 2 Function None 3
133+
5: Label
134+
15(param): 7(ptr) Variable Function
135+
18: 17(ptr) AccessChain 14(gl_GlobalInvocationID) 16
136+
19: 6(int) Load 18
137+
Store 15(param) 19
138+
20: 2 FunctionCall 10(do_compute(u1;) 15(param)
139+
Return
140+
FunctionEnd
141+
10(do_compute(u1;): 2 Function None 8
142+
9(index): 7(ptr) FunctionParameter
143+
11: Label
144+
29: 6(int) Load 9(index)
145+
33: 32(ptr) AccessChain 26(dataBuf) 28 29
146+
34: 22(fvec4) Load 33
147+
35: 22(fvec4) FAdd 34 31
148+
36: 32(ptr) AccessChain 26(dataBuf) 28 29
149+
Store 36 35
150+
Return
151+
FunctionEnd

glslang/MachineIndependent/linkValidate.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
344344
}
345345
if (primitives == TQualifier::layoutNotSet)
346346
primitives = unit.primitives;
347-
else if (primitives != unit.primitives) {
347+
else if (unit.primitives != TQualifier::layoutNotSet && primitives != unit.primitives) {
348348
if (language == EShLangMesh)
349349
error(infoSink, "Contradictory layout max_primitives values");
350350
else
@@ -366,12 +366,12 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
366366

367367
if (vertexSpacing == EvsNone)
368368
vertexSpacing = unit.vertexSpacing;
369-
else if (vertexSpacing != unit.vertexSpacing)
369+
else if (unit.vertexSpacing != EvsNone && vertexSpacing != unit.vertexSpacing)
370370
error(infoSink, "Contradictory input vertex spacing");
371371

372372
if (vertexOrder == EvoNone)
373373
vertexOrder = unit.vertexOrder;
374-
else if (vertexOrder != unit.vertexOrder)
374+
else if (unit.vertexOrder != EvoNone && vertexOrder != unit.vertexOrder)
375375
error(infoSink, "Contradictory triangle ordering");
376376

377377
MERGE_TRUE(pointMode);
@@ -388,7 +388,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
388388

389389
if (localSizeSpecId[i] == TQualifier::layoutNotSet)
390390
localSizeSpecId[i] = unit.localSizeSpecId[i];
391-
else if (localSizeSpecId[i] != unit.localSizeSpecId[i])
391+
else if (unit.localSizeSpecId[i] != TQualifier::layoutNotSet && localSizeSpecId[i] != unit.localSizeSpecId[i])
392392
error(infoSink, "Contradictory local size specialization ids");
393393
}
394394

@@ -400,7 +400,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
400400

401401
if (depthLayout == EldNone)
402402
depthLayout = unit.depthLayout;
403-
else if (depthLayout != unit.depthLayout)
403+
else if (unit.depthLayout != EldNone && depthLayout != unit.depthLayout)
404404
error(infoSink, "Contradictory depth layouts");
405405

406406
MERGE_TRUE(depthReplacing);
@@ -413,7 +413,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
413413
for (size_t b = 0; b < xfbBuffers.size(); ++b) {
414414
if (xfbBuffers[b].stride == TQualifier::layoutXfbStrideEnd)
415415
xfbBuffers[b].stride = unit.xfbBuffers[b].stride;
416-
else if (xfbBuffers[b].stride != unit.xfbBuffers[b].stride)
416+
else if (unit.xfbBuffers[b].stride != TQualifier::layoutXfbStrideEnd && xfbBuffers[b].stride != unit.xfbBuffers[b].stride)
417417
error(infoSink, "Contradictory xfb_stride");
418418
xfbBuffers[b].implicitStride = std::max(xfbBuffers[b].implicitStride, unit.xfbBuffers[b].implicitStride);
419419
if (unit.xfbBuffers[b].contains64BitType)

0 commit comments

Comments
 (0)