HLSL: HS return is arrayed to match SPIR-V semantics

HLSL HS outputs a per ctrl point value, and the DS reads an array
of that type.  (It also has a per patch frequency).  The per-ctrl-pt
frequency is arrayed on just one side, as opposed to SPIR-V which
is arrayed on both.  To match semantics, the compiler creates an
array behind the scenes and indexes it by invocation ID, assigning
the HS return value to it.
This commit is contained in:
steve-lunarg 2017-03-22 18:39:25 -06:00
parent 7afe1344ca
commit e752f463c5
6 changed files with 477 additions and 382 deletions

View File

@ -31,7 +31,9 @@ vertices = 4
0:? 'm_cpid' ( temp uint)
0:? 'm_cpid' ( in uint InvocationID)
0:26 move second child to first child ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:26 indirect index ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( in uint InvocationID)
0:26 Function Call: @main(struct-VS_OUT-vf31[4];u1; ( temp structure{ temp 3-component vector of float cpoint})
0:? 'ip' ( temp 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( temp uint)
@ -100,7 +102,7 @@ vertices = 4
0:38 Branch: Return with expression
0:38 'output' ( temp structure{ temp 2-element array of float edges})
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( in uint InvocationID)
0:? 'pid' ( in uint PrimitiveID)
@ -143,7 +145,9 @@ vertices = 4
0:? 'm_cpid' ( temp uint)
0:? 'm_cpid' ( in uint InvocationID)
0:26 move second child to first child ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:26 indirect index ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( in uint InvocationID)
0:26 Function Call: @main(struct-VS_OUT-vf31[4];u1; ( temp structure{ temp 3-component vector of float cpoint})
0:? 'ip' ( temp 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( temp uint)
@ -212,7 +216,7 @@ vertices = 4
0:38 Branch: Return with expression
0:38 'output' ( temp structure{ temp 2-element array of float edges})
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( in uint InvocationID)
0:? 'pid' ( in uint PrimitiveID)
@ -221,12 +225,12 @@ vertices = 4
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 89
// Id's are bound by 93
Capability Tessellation
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TessellationControl 4 "main" 40 44 47 62 68 88
EntryPoint TessellationControl 4 "main" 40 44 48 66 72 92
ExecutionMode 4 OutputVertices 4
Name 4 "main"
Name 8 "VS_OUT"
@ -245,24 +249,24 @@ vertices = 4
Name 40 "ip"
Name 42 "m_cpid"
Name 44 "m_cpid"
Name 47 "@entryPointOutput"
Name 48 "param"
Name 48 "@entryPointOutput"
Name 50 "param"
Name 61 "@patchConstantResult"
Name 62 "pid"
Name 63 "param"
Name 68 "@patchConstantOutput_edges"
Name 78 "output"
Name 86 "HS_CONSTANT_OUT"
Name 88 "@patchConstantOutput"
Name 52 "param"
Name 65 "@patchConstantResult"
Name 66 "pid"
Name 67 "param"
Name 72 "@patchConstantOutput_edges"
Name 82 "output"
Name 90 "HS_CONSTANT_OUT"
Name 92 "@patchConstantOutput"
Decorate 40(ip) Location 0
Decorate 44(m_cpid) BuiltIn InvocationId
Decorate 47(@entryPointOutput) Location 0
Decorate 62(pid) BuiltIn PrimitiveId
Decorate 68(@patchConstantOutput_edges) Patch
Decorate 68(@patchConstantOutput_edges) BuiltIn TessLevelOuter
Decorate 88(@patchConstantOutput) Patch
Decorate 88(@patchConstantOutput) Location 1
Decorate 48(@entryPointOutput) Location 0
Decorate 66(pid) BuiltIn PrimitiveId
Decorate 72(@patchConstantOutput_edges) Patch
Decorate 72(@patchConstantOutput_edges) BuiltIn TessLevelOuter
Decorate 92(@patchConstantOutput) Patch
Decorate 92(@patchConstantOutput) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -287,62 +291,66 @@ vertices = 4
40(ip): 39(ptr) Variable Input
43: TypePointer Input 9(int)
44(m_cpid): 43(ptr) Variable Input
46: TypePointer Output 14(HS_OUT)
47(@entryPointOutput): 46(ptr) Variable Output
53: 9(int) Constant 1
54: 9(int) Constant 0
56: TypeBool
60: TypePointer Function 22(HS_CONSTANT_OUT)
62(pid): 43(ptr) Variable Input
66: TypeArray 6(float) 10
67: TypePointer Output 66
68(@patchConstantOutput_edges): 67(ptr) Variable Output
69: TypePointer Function 6(float)
72: TypePointer Output 6(float)
74: 29(int) Constant 1
79: 6(float) Constant 1073741824
81: 6(float) Constant 1090519040
86(HS_CONSTANT_OUT): TypeStruct
87: TypePointer Output 86(HS_CONSTANT_OUT)
88(@patchConstantOutput): 87(ptr) Variable Output
46: TypeArray 14(HS_OUT) 10
47: TypePointer Output 46
48(@entryPointOutput): 47(ptr) Variable Output
55: TypePointer Output 14(HS_OUT)
57: 9(int) Constant 1
58: 9(int) Constant 0
60: TypeBool
64: TypePointer Function 22(HS_CONSTANT_OUT)
66(pid): 43(ptr) Variable Input
70: TypeArray 6(float) 10
71: TypePointer Output 70
72(@patchConstantOutput_edges): 71(ptr) Variable Output
73: TypePointer Function 6(float)
76: TypePointer Output 6(float)
78: 29(int) Constant 1
83: 6(float) Constant 1073741824
85: 6(float) Constant 1090519040
90(HS_CONSTANT_OUT): TypeStruct
91: TypePointer Output 90(HS_CONSTANT_OUT)
92(@patchConstantOutput): 91(ptr) Variable Output
4(main): 2 Function None 3
5: Label
38(ip): 12(ptr) Variable Function
42(m_cpid): 13(ptr) Variable Function
48(param): 12(ptr) Variable Function
50(param): 13(ptr) Variable Function
61(@patchConstantResult): 60(ptr) Variable Function
63(param): 13(ptr) Variable Function
50(param): 12(ptr) Variable Function
52(param): 13(ptr) Variable Function
65(@patchConstantResult): 64(ptr) Variable Function
67(param): 13(ptr) Variable Function
41: 11 Load 40(ip)
Store 38(ip) 41
45: 9(int) Load 44(m_cpid)
Store 42(m_cpid) 45
49: 11 Load 38(ip)
Store 48(param) 49
51: 9(int) Load 42(m_cpid)
49: 9(int) Load 44(m_cpid)
51: 11 Load 38(ip)
Store 50(param) 51
52: 14(HS_OUT) FunctionCall 18(@main(struct-VS_OUT-vf31[4];u1;) 48(param) 50(param)
Store 47(@entryPointOutput) 52
ControlBarrier 20 53 54
55: 9(int) Load 44(m_cpid)
57: 56(bool) IEqual 55 30
SelectionMerge 59 None
BranchConditional 57 58 59
58: Label
64: 9(int) Load 62(pid)
Store 63(param) 64
65:22(HS_CONSTANT_OUT) FunctionCall 25(PCF(u1;) 63(param)
Store 61(@patchConstantResult) 65
70: 69(ptr) AccessChain 61(@patchConstantResult) 30 30
71: 6(float) Load 70
73: 72(ptr) AccessChain 68(@patchConstantOutput_edges) 30
Store 73 71
75: 69(ptr) AccessChain 61(@patchConstantResult) 30 74
76: 6(float) Load 75
77: 72(ptr) AccessChain 68(@patchConstantOutput_edges) 74
Store 77 76
Branch 59
59: Label
53: 9(int) Load 42(m_cpid)
Store 52(param) 53
54: 14(HS_OUT) FunctionCall 18(@main(struct-VS_OUT-vf31[4];u1;) 50(param) 52(param)
56: 55(ptr) AccessChain 48(@entryPointOutput) 49
Store 56 54
ControlBarrier 20 57 58
59: 9(int) Load 44(m_cpid)
61: 60(bool) IEqual 59 30
SelectionMerge 63 None
BranchConditional 61 62 63
62: Label
68: 9(int) Load 66(pid)
Store 67(param) 68
69:22(HS_CONSTANT_OUT) FunctionCall 25(PCF(u1;) 67(param)
Store 65(@patchConstantResult) 69
74: 73(ptr) AccessChain 65(@patchConstantResult) 30 30
75: 6(float) Load 74
77: 76(ptr) AccessChain 72(@patchConstantOutput_edges) 30
Store 77 75
79: 73(ptr) AccessChain 65(@patchConstantResult) 30 78
80: 6(float) Load 79
81: 76(ptr) AccessChain 72(@patchConstantOutput_edges) 78
Store 81 80
Branch 63
63: Label
Return
FunctionEnd
18(@main(struct-VS_OUT-vf31[4];u1;): 14(HS_OUT) Function None 15
@ -360,11 +368,11 @@ vertices = 4
25(PCF(u1;):22(HS_CONSTANT_OUT) Function None 23
24(pid): 13(ptr) FunctionParameter
26: Label
78(output): 60(ptr) Variable Function
80: 69(ptr) AccessChain 78(output) 30 30
Store 80 79
82: 69(ptr) AccessChain 78(output) 30 74
Store 82 81
83:22(HS_CONSTANT_OUT) Load 78(output)
ReturnValue 83
82(output): 64(ptr) Variable Function
84: 73(ptr) AccessChain 82(output) 30 30
Store 84 83
86: 73(ptr) AccessChain 82(output) 30 78
Store 86 85
87:22(HS_CONSTANT_OUT) Load 82(output)
ReturnValue 87
FunctionEnd

View File

@ -27,7 +27,9 @@ vertices = 4
0:? 'ip' ( temp 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:26 move second child to first child ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:26 indirect index ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
0:26 Function Call: @main(struct-VS_OUT-vf31[4]; ( temp structure{ temp 3-component vector of float cpoint})
0:? 'ip' ( temp 4-element array of structure{ temp 3-component vector of float cpoint})
0:? Barrier ( temp void)
@ -97,11 +99,11 @@ vertices = 4
0:38 Branch: Return with expression
0:38 'output' ( temp structure{ temp 2-element array of float edges})
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
0:? 'pid' ( in uint PrimitiveID)
0:? 'pos' ( in 4-component vector of float Position)
0:? 'InvocationId' ( in uint InvocationID)
0:? '@patchConstantOutput' (layout( location=1) patch out structure{})
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
@ -137,7 +139,9 @@ vertices = 4
0:? 'ip' ( temp 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:26 move second child to first child ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:26 indirect index ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
0:26 Function Call: @main(struct-VS_OUT-vf31[4]; ( temp structure{ temp 3-component vector of float cpoint})
0:? 'ip' ( temp 4-element array of structure{ temp 3-component vector of float cpoint})
0:? Barrier ( temp void)
@ -207,22 +211,22 @@ vertices = 4
0:38 Branch: Return with expression
0:38 'output' ( temp structure{ temp 2-element array of float edges})
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
0:? 'pid' ( in uint PrimitiveID)
0:? 'pos' ( in 4-component vector of float Position)
0:? 'InvocationId' ( in uint InvocationID)
0:? '@patchConstantOutput' (layout( location=1) patch out structure{})
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 91
// Id's are bound by 95
Capability Tessellation
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TessellationControl 4 "main" 42 45 52 60 62 70 90
EntryPoint TessellationControl 4 "main" 42 46 48 64 66 74 94
ExecutionMode 4 OutputVertices 4
Name 4 "main"
Name 8 "VS_OUT"
@ -239,27 +243,27 @@ vertices = 4
Name 30 "output"
Name 40 "ip"
Name 42 "ip"
Name 45 "@entryPointOutput"
Name 46 "param"
Name 52 "InvocationId"
Name 59 "@patchConstantResult"
Name 60 "pid"
Name 62 "pos"
Name 63 "param"
Name 65 "param"
Name 70 "@patchConstantOutput_edges"
Name 80 "output"
Name 88 "HS_CONSTANT_OUT"
Name 90 "@patchConstantOutput"
Name 46 "@entryPointOutput"
Name 48 "InvocationId"
Name 50 "param"
Name 63 "@patchConstantResult"
Name 64 "pid"
Name 66 "pos"
Name 67 "param"
Name 69 "param"
Name 74 "@patchConstantOutput_edges"
Name 84 "output"
Name 92 "HS_CONSTANT_OUT"
Name 94 "@patchConstantOutput"
Decorate 42(ip) Location 0
Decorate 45(@entryPointOutput) Location 0
Decorate 52(InvocationId) BuiltIn InvocationId
Decorate 60(pid) BuiltIn PrimitiveId
Decorate 62(pos) BuiltIn Position
Decorate 70(@patchConstantOutput_edges) Patch
Decorate 70(@patchConstantOutput_edges) BuiltIn TessLevelOuter
Decorate 90(@patchConstantOutput) Patch
Decorate 90(@patchConstantOutput) Location 1
Decorate 46(@entryPointOutput) Location 0
Decorate 48(InvocationId) BuiltIn InvocationId
Decorate 64(pid) BuiltIn PrimitiveId
Decorate 66(pos) BuiltIn Position
Decorate 74(@patchConstantOutput_edges) Patch
Decorate 74(@patchConstantOutput_edges) BuiltIn TessLevelOuter
Decorate 94(@patchConstantOutput) Patch
Decorate 94(@patchConstantOutput) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -284,63 +288,67 @@ vertices = 4
33: TypePointer Function 7(fvec3)
41: TypePointer Input 11
42(ip): 41(ptr) Variable Input
44: TypePointer Output 13(HS_OUT)
45(@entryPointOutput): 44(ptr) Variable Output
49: 9(int) Constant 1
50: 9(int) Constant 0
51: TypePointer Input 9(int)
52(InvocationId): 51(ptr) Variable Input
54: TypeBool
58: TypePointer Function 23(HS_CONSTANT_OUT)
60(pid): 51(ptr) Variable Input
61: TypePointer Input 19(fvec4)
62(pos): 61(ptr) Variable Input
68: TypeArray 6(float) 10
69: TypePointer Output 68
70(@patchConstantOutput_edges): 69(ptr) Variable Output
71: TypePointer Function 6(float)
74: TypePointer Output 6(float)
76: 31(int) Constant 1
81: 6(float) Constant 1073741824
83: 6(float) Constant 1090519040
88(HS_CONSTANT_OUT): TypeStruct
89: TypePointer Output 88(HS_CONSTANT_OUT)
90(@patchConstantOutput): 89(ptr) Variable Output
44: TypeArray 13(HS_OUT) 10
45: TypePointer Output 44
46(@entryPointOutput): 45(ptr) Variable Output
47: TypePointer Input 9(int)
48(InvocationId): 47(ptr) Variable Input
53: TypePointer Output 13(HS_OUT)
55: 9(int) Constant 1
56: 9(int) Constant 0
58: TypeBool
62: TypePointer Function 23(HS_CONSTANT_OUT)
64(pid): 47(ptr) Variable Input
65: TypePointer Input 19(fvec4)
66(pos): 65(ptr) Variable Input
72: TypeArray 6(float) 10
73: TypePointer Output 72
74(@patchConstantOutput_edges): 73(ptr) Variable Output
75: TypePointer Function 6(float)
78: TypePointer Output 6(float)
80: 31(int) Constant 1
85: 6(float) Constant 1073741824
87: 6(float) Constant 1090519040
92(HS_CONSTANT_OUT): TypeStruct
93: TypePointer Output 92(HS_CONSTANT_OUT)
94(@patchConstantOutput): 93(ptr) Variable Output
4(main): 2 Function None 3
5: Label
40(ip): 12(ptr) Variable Function
46(param): 12(ptr) Variable Function
59(@patchConstantResult): 58(ptr) Variable Function
63(param): 18(ptr) Variable Function
65(param): 20(ptr) Variable Function
50(param): 12(ptr) Variable Function
63(@patchConstantResult): 62(ptr) Variable Function
67(param): 18(ptr) Variable Function
69(param): 20(ptr) Variable Function
43: 11 Load 42(ip)
Store 40(ip) 43
47: 11 Load 40(ip)
Store 46(param) 47
48: 13(HS_OUT) FunctionCall 16(@main(struct-VS_OUT-vf31[4];) 46(param)
Store 45(@entryPointOutput) 48
ControlBarrier 21 49 50
53: 9(int) Load 52(InvocationId)
55: 54(bool) IEqual 53 32
SelectionMerge 57 None
BranchConditional 55 56 57
56: Label
64: 9(int) Load 60(pid)
Store 63(param) 64
66: 19(fvec4) Load 62(pos)
Store 65(param) 66
67:23(HS_CONSTANT_OUT) FunctionCall 27(PCF(u1;vf4;) 63(param) 65(param)
Store 59(@patchConstantResult) 67
72: 71(ptr) AccessChain 59(@patchConstantResult) 32 32
73: 6(float) Load 72
75: 74(ptr) AccessChain 70(@patchConstantOutput_edges) 32
Store 75 73
77: 71(ptr) AccessChain 59(@patchConstantResult) 32 76
78: 6(float) Load 77
79: 74(ptr) AccessChain 70(@patchConstantOutput_edges) 76
Store 79 78
Branch 57
57: Label
49: 9(int) Load 48(InvocationId)
51: 11 Load 40(ip)
Store 50(param) 51
52: 13(HS_OUT) FunctionCall 16(@main(struct-VS_OUT-vf31[4];) 50(param)
54: 53(ptr) AccessChain 46(@entryPointOutput) 49
Store 54 52
ControlBarrier 21 55 56
57: 9(int) Load 48(InvocationId)
59: 58(bool) IEqual 57 32
SelectionMerge 61 None
BranchConditional 59 60 61
60: Label
68: 9(int) Load 64(pid)
Store 67(param) 68
70: 19(fvec4) Load 66(pos)
Store 69(param) 70
71:23(HS_CONSTANT_OUT) FunctionCall 27(PCF(u1;vf4;) 67(param) 69(param)
Store 63(@patchConstantResult) 71
76: 75(ptr) AccessChain 63(@patchConstantResult) 32 32
77: 6(float) Load 76
79: 78(ptr) AccessChain 74(@patchConstantOutput_edges) 32
Store 79 77
81: 75(ptr) AccessChain 63(@patchConstantResult) 32 80
82: 6(float) Load 81
83: 78(ptr) AccessChain 74(@patchConstantOutput_edges) 80
Store 83 82
Branch 61
61: Label
Return
FunctionEnd
16(@main(struct-VS_OUT-vf31[4];): 13(HS_OUT) Function None 14
@ -358,11 +366,11 @@ vertices = 4
25(pid): 18(ptr) FunctionParameter
26(pos): 20(ptr) FunctionParameter
28: Label
80(output): 58(ptr) Variable Function
82: 71(ptr) AccessChain 80(output) 32 32
Store 82 81
84: 71(ptr) AccessChain 80(output) 32 76
Store 84 83
85:23(HS_CONSTANT_OUT) Load 80(output)
ReturnValue 85
84(output): 62(ptr) Variable Function
86: 75(ptr) AccessChain 84(output) 32 32
Store 86 85
88: 75(ptr) AccessChain 84(output) 32 80
Store 88 87
89:23(HS_CONSTANT_OUT) Load 84(output)
ReturnValue 89
FunctionEnd

View File

@ -27,7 +27,9 @@ vertices = 3
0:? 'cpid' ( temp uint)
0:? 'cpid' ( in uint InvocationID)
0:27 move second child to first child ( temp structure{ temp 3-component vector of float val})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float val})
0:27 indirect index ( temp structure{ temp 3-component vector of float val})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float val})
0:? 'cpid' ( in uint InvocationID)
0:27 Function Call: @main(struct-hs_in_t-vf31[3];u1; ( temp structure{ temp 3-component vector of float val})
0:? 'i' ( temp 3-element array of structure{ temp 3-component vector of float val})
0:? 'cpid' ( temp uint)
@ -185,7 +187,7 @@ vertices = 3
0:42 Branch: Return with expression
0:42 'o' ( temp structure{ temp 3-element array of float tfactor, temp float flInFactor})
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float val})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float val})
0:? 'i' (layout( location=0) in 3-element array of structure{ temp 3-component vector of float val})
0:? 'cpid' ( in uint InvocationID)
0:? '@patchConstantOutput' (layout( location=1) patch out structure{})
@ -224,7 +226,9 @@ vertices = 3
0:? 'cpid' ( temp uint)
0:? 'cpid' ( in uint InvocationID)
0:27 move second child to first child ( temp structure{ temp 3-component vector of float val})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float val})
0:27 indirect index ( temp structure{ temp 3-component vector of float val})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float val})
0:? 'cpid' ( in uint InvocationID)
0:27 Function Call: @main(struct-hs_in_t-vf31[3];u1; ( temp structure{ temp 3-component vector of float val})
0:? 'i' ( temp 3-element array of structure{ temp 3-component vector of float val})
0:? 'cpid' ( temp uint)
@ -382,7 +386,7 @@ vertices = 3
0:42 Branch: Return with expression
0:42 'o' ( temp structure{ temp 3-element array of float tfactor, temp float flInFactor})
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float val})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float val})
0:? 'i' (layout( location=0) in 3-element array of structure{ temp 3-component vector of float val})
0:? 'cpid' ( in uint InvocationID)
0:? '@patchConstantOutput' (layout( location=1) patch out structure{})
@ -391,12 +395,12 @@ vertices = 3
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 124
// Id's are bound by 127
Capability Tessellation
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TessellationControl 4 "main" 41 45 48 91 105 123
EntryPoint TessellationControl 4 "main" 41 45 48 94 108 126
ExecutionMode 4 OutputVertices 3
Name 4 "main"
Name 8 "hs_in_t"
@ -417,33 +421,33 @@ vertices = 3
Name 43 "cpid"
Name 45 "cpid"
Name 48 "@entryPointOutput"
Name 49 "param"
Name 51 "param"
Name 63 "pcf_out"
Name 64 "i"
Name 65 "param"
Name 67 "param"
Name 71 "i"
Name 72 "param"
Name 74 "param"
Name 78 "i"
Name 79 "param"
Name 81 "param"
Name 85 "@patchConstantResult"
Name 91 "@patchConstantOutput_tfactor"
Name 105 "@patchConstantOutput_flInFactor"
Name 109 "o"
Name 121 "hs_pcf_t"
Name 123 "@patchConstantOutput"
Name 50 "param"
Name 52 "param"
Name 66 "pcf_out"
Name 67 "i"
Name 68 "param"
Name 70 "param"
Name 74 "i"
Name 75 "param"
Name 77 "param"
Name 81 "i"
Name 82 "param"
Name 84 "param"
Name 88 "@patchConstantResult"
Name 94 "@patchConstantOutput_tfactor"
Name 108 "@patchConstantOutput_flInFactor"
Name 112 "o"
Name 124 "hs_pcf_t"
Name 126 "@patchConstantOutput"
Decorate 41(i) Location 0
Decorate 45(cpid) BuiltIn InvocationId
Decorate 48(@entryPointOutput) Location 0
Decorate 91(@patchConstantOutput_tfactor) Patch
Decorate 91(@patchConstantOutput_tfactor) BuiltIn TessLevelOuter
Decorate 105(@patchConstantOutput_flInFactor) Patch
Decorate 105(@patchConstantOutput_flInFactor) BuiltIn TessLevelInner
Decorate 123(@patchConstantOutput) Patch
Decorate 123(@patchConstantOutput) Location 1
Decorate 94(@patchConstantOutput_tfactor) Patch
Decorate 94(@patchConstantOutput_tfactor) BuiltIn TessLevelOuter
Decorate 108(@patchConstantOutput_flInFactor) Patch
Decorate 108(@patchConstantOutput_flInFactor) BuiltIn TessLevelInner
Decorate 126(@patchConstantOutput) Patch
Decorate 126(@patchConstantOutput) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -468,101 +472,104 @@ vertices = 3
41(i): 40(ptr) Variable Input
44: TypePointer Input 9(int)
45(cpid): 44(ptr) Variable Input
47: TypePointer Output 14(hs_out_t)
47: TypePointer Output 20
48(@entryPointOutput): 47(ptr) Variable Output
54: 9(int) Constant 2
55: 9(int) Constant 1
56: 9(int) Constant 0
58: TypeBool
62: TypePointer Function 20
70: 29(int) Constant 1
77: 29(int) Constant 2
84: TypePointer Function 22(hs_pcf_t)
88: 9(int) Constant 4
89: TypeArray 6(float) 88
90: TypePointer Output 89
91(@patchConstantOutput_tfactor): 90(ptr) Variable Output
92: TypePointer Function 6(float)
95: TypePointer Output 6(float)
103: TypeArray 6(float) 54
104: TypePointer Output 103
105(@patchConstantOutput_flInFactor): 104(ptr) Variable Output
116: 6(float) Constant 1082130432
121(hs_pcf_t): TypeStruct
122: TypePointer Output 121(hs_pcf_t)
123(@patchConstantOutput): 122(ptr) Variable Output
55: TypePointer Output 14(hs_out_t)
57: 9(int) Constant 2
58: 9(int) Constant 1
59: 9(int) Constant 0
61: TypeBool
65: TypePointer Function 20
73: 29(int) Constant 1
80: 29(int) Constant 2
87: TypePointer Function 22(hs_pcf_t)
91: 9(int) Constant 4
92: TypeArray 6(float) 91
93: TypePointer Output 92
94(@patchConstantOutput_tfactor): 93(ptr) Variable Output
95: TypePointer Function 6(float)
98: TypePointer Output 6(float)
106: TypeArray 6(float) 57
107: TypePointer Output 106
108(@patchConstantOutput_flInFactor): 107(ptr) Variable Output
119: 6(float) Constant 1082130432
124(hs_pcf_t): TypeStruct
125: TypePointer Output 124(hs_pcf_t)
126(@patchConstantOutput): 125(ptr) Variable Output
4(main): 2 Function None 3
5: Label
39(i): 12(ptr) Variable Function
43(cpid): 13(ptr) Variable Function
49(param): 12(ptr) Variable Function
51(param): 13(ptr) Variable Function
63(pcf_out): 62(ptr) Variable Function
64(i): 12(ptr) Variable Function
65(param): 12(ptr) Variable Function
67(param): 13(ptr) Variable Function
71(i): 12(ptr) Variable Function
72(param): 12(ptr) Variable Function
74(param): 13(ptr) Variable Function
78(i): 12(ptr) Variable Function
79(param): 12(ptr) Variable Function
81(param): 13(ptr) Variable Function
85(@patchConstantResult): 84(ptr) Variable Function
50(param): 12(ptr) Variable Function
52(param): 13(ptr) Variable Function
66(pcf_out): 65(ptr) Variable Function
67(i): 12(ptr) Variable Function
68(param): 12(ptr) Variable Function
70(param): 13(ptr) Variable Function
74(i): 12(ptr) Variable Function
75(param): 12(ptr) Variable Function
77(param): 13(ptr) Variable Function
81(i): 12(ptr) Variable Function
82(param): 12(ptr) Variable Function
84(param): 13(ptr) Variable Function
88(@patchConstantResult): 87(ptr) Variable Function
42: 11 Load 41(i)
Store 39(i) 42
46: 9(int) Load 45(cpid)
Store 43(cpid) 46
50: 11 Load 39(i)
Store 49(param) 50
52: 9(int) Load 43(cpid)
Store 51(param) 52
53:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 49(param) 51(param)
Store 48(@entryPointOutput) 53
ControlBarrier 54 55 56
57: 9(int) Load 45(cpid)
59: 58(bool) IEqual 57 30
SelectionMerge 61 None
BranchConditional 59 60 61
60: Label
66: 11 Load 64(i)
Store 65(param) 66
Store 67(param) 56
68:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 65(param) 67(param)
69: 27(ptr) AccessChain 63(pcf_out) 30
Store 69 68
73: 11 Load 71(i)
Store 72(param) 73
Store 74(param) 55
75:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 72(param) 74(param)
76: 27(ptr) AccessChain 63(pcf_out) 70
Store 76 75
80: 11 Load 78(i)
Store 79(param) 80
Store 81(param) 54
82:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 79(param) 81(param)
83: 27(ptr) AccessChain 63(pcf_out) 77
Store 83 82
86: 20 Load 63(pcf_out)
87:22(hs_pcf_t) FunctionCall 25(PCF(struct-hs_out_t-vf31[3];) 86
Store 85(@patchConstantResult) 87
93: 92(ptr) AccessChain 85(@patchConstantResult) 30 30
94: 6(float) Load 93
96: 95(ptr) AccessChain 91(@patchConstantOutput_tfactor) 30
Store 96 94
97: 92(ptr) AccessChain 85(@patchConstantResult) 30 70
98: 6(float) Load 97
99: 95(ptr) AccessChain 91(@patchConstantOutput_tfactor) 70
Store 99 98
100: 92(ptr) AccessChain 85(@patchConstantResult) 30 77
49: 9(int) Load 45(cpid)
51: 11 Load 39(i)
Store 50(param) 51
53: 9(int) Load 43(cpid)
Store 52(param) 53
54:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 50(param) 52(param)
56: 55(ptr) AccessChain 48(@entryPointOutput) 49
Store 56 54
ControlBarrier 57 58 59
60: 9(int) Load 45(cpid)
62: 61(bool) IEqual 60 30
SelectionMerge 64 None
BranchConditional 62 63 64
63: Label
69: 11 Load 67(i)
Store 68(param) 69
Store 70(param) 59
71:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 68(param) 70(param)
72: 27(ptr) AccessChain 66(pcf_out) 30
Store 72 71
76: 11 Load 74(i)
Store 75(param) 76
Store 77(param) 58
78:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 75(param) 77(param)
79: 27(ptr) AccessChain 66(pcf_out) 73
Store 79 78
83: 11 Load 81(i)
Store 82(param) 83
Store 84(param) 57
85:14(hs_out_t) FunctionCall 18(@main(struct-hs_in_t-vf31[3];u1;) 82(param) 84(param)
86: 27(ptr) AccessChain 66(pcf_out) 80
Store 86 85
89: 20 Load 66(pcf_out)
90:22(hs_pcf_t) FunctionCall 25(PCF(struct-hs_out_t-vf31[3];) 89
Store 88(@patchConstantResult) 90
96: 95(ptr) AccessChain 88(@patchConstantResult) 30 30
97: 6(float) Load 96
99: 98(ptr) AccessChain 94(@patchConstantOutput_tfactor) 30
Store 99 97
100: 95(ptr) AccessChain 88(@patchConstantResult) 30 73
101: 6(float) Load 100
102: 95(ptr) AccessChain 91(@patchConstantOutput_tfactor) 77
102: 98(ptr) AccessChain 94(@patchConstantOutput_tfactor) 73
Store 102 101
106: 92(ptr) AccessChain 85(@patchConstantResult) 70
107: 6(float) Load 106
108: 95(ptr) AccessChain 105(@patchConstantOutput_flInFactor) 30
Store 108 107
Branch 61
61: Label
103: 95(ptr) AccessChain 88(@patchConstantResult) 30 80
104: 6(float) Load 103
105: 98(ptr) AccessChain 94(@patchConstantOutput_tfactor) 80
Store 105 104
109: 95(ptr) AccessChain 88(@patchConstantResult) 73
110: 6(float) Load 109
111: 98(ptr) AccessChain 108(@patchConstantOutput_flInFactor) 30
Store 111 110
Branch 64
64: Label
Return
FunctionEnd
18(@main(struct-hs_in_t-vf31[3];u1;):14(hs_out_t) Function None 15
@ -581,18 +588,18 @@ vertices = 3
25(PCF(struct-hs_out_t-vf31[3];):22(hs_pcf_t) Function None 23
24(pcf_out): 20 FunctionParameter
26: Label
109(o): 84(ptr) Variable Function
110: 6(float) CompositeExtract 24(pcf_out) 0 0 0
111: 92(ptr) AccessChain 109(o) 30 30
Store 111 110
112: 6(float) CompositeExtract 24(pcf_out) 1 0 0
113: 92(ptr) AccessChain 109(o) 30 70
Store 113 112
114: 6(float) CompositeExtract 24(pcf_out) 2 0 0
115: 92(ptr) AccessChain 109(o) 30 77
Store 115 114
117: 92(ptr) AccessChain 109(o) 70
Store 117 116
118:22(hs_pcf_t) Load 109(o)
ReturnValue 118
112(o): 87(ptr) Variable Function
113: 6(float) CompositeExtract 24(pcf_out) 0 0 0
114: 95(ptr) AccessChain 112(o) 30 30
Store 114 113
115: 6(float) CompositeExtract 24(pcf_out) 1 0 0
116: 95(ptr) AccessChain 112(o) 30 73
Store 116 115
117: 6(float) CompositeExtract 24(pcf_out) 2 0 0
118: 95(ptr) AccessChain 112(o) 30 80
Store 118 117
120: 95(ptr) AccessChain 112(o) 73
Store 120 119
121:22(hs_pcf_t) Load 112(o)
ReturnValue 121
FunctionEnd

View File

@ -27,7 +27,9 @@ vertices = 3
0:? 'ip' ( temp 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 3-element array of structure{ temp 3-component vector of float cpoint})
0:26 move second child to first child ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:26 indirect index ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
0:26 Function Call: @main(struct-VS_OUT-vf31[3]; ( temp structure{ temp 3-component vector of float cpoint})
0:? 'ip' ( temp 3-element array of structure{ temp 3-component vector of float cpoint})
0:? Barrier ( temp void)
@ -43,7 +45,7 @@ vertices = 3
0:33 Function Definition: PCF( ( temp void)
0:33 Function Parameters:
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
@ -79,7 +81,9 @@ vertices = 3
0:? 'ip' ( temp 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 3-element array of structure{ temp 3-component vector of float cpoint})
0:26 move second child to first child ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:26 indirect index ( temp structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
0:26 Function Call: @main(struct-VS_OUT-vf31[3]; ( temp structure{ temp 3-component vector of float cpoint})
0:? 'ip' ( temp 3-element array of structure{ temp 3-component vector of float cpoint})
0:? Barrier ( temp void)
@ -95,18 +99,18 @@ vertices = 3
0:33 Function Definition: PCF( ( temp void)
0:33 Function Parameters:
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out structure{ temp 3-component vector of float cpoint})
0:? '@entryPointOutput' (layout( location=0) out 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'ip' (layout( location=0) in 3-element array of structure{ temp 3-component vector of float cpoint})
0:? 'InvocationId' ( in uint InvocationID)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 51
// Id's are bound by 55
Capability Tessellation
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TessellationControl 4 "main" 33 36 44
EntryPoint TessellationControl 4 "main" 33 37 39
ExecutionMode 4 OutputVertices 3
Name 4 "main"
Name 8 "VS_OUT"
@ -119,12 +123,12 @@ vertices = 3
Name 21 "output"
Name 31 "ip"
Name 33 "ip"
Name 36 "@entryPointOutput"
Name 37 "param"
Name 44 "InvocationId"
Name 37 "@entryPointOutput"
Name 39 "InvocationId"
Name 41 "param"
Decorate 33(ip) Location 0
Decorate 36(@entryPointOutput) Location 0
Decorate 44(InvocationId) BuiltIn InvocationId
Decorate 37(@entryPointOutput) Location 0
Decorate 39(InvocationId) BuiltIn InvocationId
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -142,33 +146,37 @@ vertices = 3
24: TypePointer Function 7(fvec3)
32: TypePointer Input 11
33(ip): 32(ptr) Variable Input
35: TypePointer Output 13(HS_OUT)
36(@entryPointOutput): 35(ptr) Variable Output
40: 9(int) Constant 2
41: 9(int) Constant 1
42: 9(int) Constant 0
43: TypePointer Input 9(int)
44(InvocationId): 43(ptr) Variable Input
46: TypeBool
35: TypeArray 13(HS_OUT) 10
36: TypePointer Output 35
37(@entryPointOutput): 36(ptr) Variable Output
38: TypePointer Input 9(int)
39(InvocationId): 38(ptr) Variable Input
44: TypePointer Output 13(HS_OUT)
46: 9(int) Constant 2
47: 9(int) Constant 1
48: 9(int) Constant 0
50: TypeBool
4(main): 2 Function None 3
5: Label
31(ip): 12(ptr) Variable Function
37(param): 12(ptr) Variable Function
41(param): 12(ptr) Variable Function
34: 11 Load 33(ip)
Store 31(ip) 34
38: 11 Load 31(ip)
Store 37(param) 38
39: 13(HS_OUT) FunctionCall 16(@main(struct-VS_OUT-vf31[3];) 37(param)
Store 36(@entryPointOutput) 39
ControlBarrier 40 41 42
45: 9(int) Load 44(InvocationId)
47: 46(bool) IEqual 45 23
SelectionMerge 49 None
BranchConditional 47 48 49
48: Label
50: 2 FunctionCall 18(PCF()
Branch 49
49: Label
40: 9(int) Load 39(InvocationId)
42: 11 Load 31(ip)
Store 41(param) 42
43: 13(HS_OUT) FunctionCall 16(@main(struct-VS_OUT-vf31[3];) 41(param)
45: 44(ptr) AccessChain 37(@entryPointOutput) 40
Store 45 43
ControlBarrier 46 47 48
49: 9(int) Load 39(InvocationId)
51: 50(bool) IEqual 49 23
SelectionMerge 53 None
BranchConditional 51 52 53
52: Label
54: 2 FunctionCall 18(PCF()
Branch 53
53: Label
Return
FunctionEnd
16(@main(struct-VS_OUT-vf31[3];): 13(HS_OUT) Function None 14

View File

@ -1598,48 +1598,10 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
return paramNodes;
}
//
// Do all special handling for the entry point, including wrapping
// the shader's entry point with the official entry point that will call it.
//
// The following:
//
// retType shaderEntryPoint(args...) // shader declared entry point
// { body }
//
// Becomes
//
// out retType ret;
// in iargs<that are input>...;
// out oargs<that are output> ...;
//
// void shaderEntryPoint() // synthesized, but official, entry point
// {
// args<that are input> = iargs...;
// ret = @shaderEntryPoint(args...);
// oargs = args<that are output>...;
// }
//
// The symbol table will still map the original entry point name to the
// the modified function and it's new name:
//
// symbol table: shaderEntryPoint -> @shaderEntryPoint
//
// Returns nullptr if no entry-point tree was built, otherwise, returns
// a subtree that creates the entry point.
//
TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunction& userFunction, const TAttributeMap& attributes)
// Handle all [attrib] attribute for the shader entry point
void HlslParseContext::handleEntryPointAttributes(const TSourceLoc& loc, TFunction& userFunction, const TAttributeMap& attributes)
{
// if we aren't in the entry point, fix the IO as such and exit
if (userFunction.getName().compare(intermediate.getEntryPointName().c_str()) != 0) {
remapNonEntryPointIO(userFunction);
return nullptr;
}
entryPointFunction = &userFunction; // needed in finish()
// entry point logic...
// Handle entry-point function attributes
const TIntermAggregate* numThreads = attributes[EatNumThreads];
if (numThreads != nullptr) {
@ -1691,8 +1653,12 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
error(loc, "unsupported domain type", domainStr.c_str(), "");
}
if (! intermediate.setInputPrimitive(domain)) {
error(loc, "cannot change previously set domain", TQualifier::getGeometryString(domain), "");
if (language == EShLangTessEvaluation) {
if (! intermediate.setInputPrimitive(domain))
error(loc, "cannot change previously set domain", TQualifier::getGeometryString(domain), "");
} else {
if (! intermediate.setOutputPrimitive(domain))
error(loc, "cannot change previously set domain", TQualifier::getGeometryString(domain), "");
}
}
}
@ -1770,6 +1736,52 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
}
}
}
}
//
// Do all special handling for the entry point, including wrapping
// the shader's entry point with the official entry point that will call it.
//
// The following:
//
// retType shaderEntryPoint(args...) // shader declared entry point
// { body }
//
// Becomes
//
// out retType ret;
// in iargs<that are input>...;
// out oargs<that are output> ...;
//
// void shaderEntryPoint() // synthesized, but official, entry point
// {
// args<that are input> = iargs...;
// ret = @shaderEntryPoint(args...);
// oargs = args<that are output>...;
// }
//
// The symbol table will still map the original entry point name to the
// the modified function and it's new name:
//
// symbol table: shaderEntryPoint -> @shaderEntryPoint
//
// Returns nullptr if no entry-point tree was built, otherwise, returns
// a subtree that creates the entry point.
//
TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunction& userFunction, const TAttributeMap& attributes)
{
// if we aren't in the entry point, fix the IO as such and exit
if (userFunction.getName().compare(intermediate.getEntryPointName().c_str()) != 0) {
remapNonEntryPointIO(userFunction);
return nullptr;
}
entryPointFunction = &userFunction; // needed in finish()
// Handle entry point attributes
handleEntryPointAttributes(loc, userFunction, attributes);
// entry point logic...
// Move parameters and return value to shader in/out
TVariable* entryPointOutput; // gets created in remapEntryPointIO
@ -1838,10 +1850,37 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
currentCaller = userFunction.getMangledName();
// Return value
if (entryPointOutput)
intermediate.growAggregate(synthBody, handleAssign(loc, EOpAssign,
intermediate.addSymbol(*entryPointOutput), callReturn));
else
if (entryPointOutput) {
TIntermTyped* returnAssign;
if (language == EShLangTessControl) {
TIntermSymbol* invocationIdSym = findLinkageSymbol(EbvInvocationId);
// If there is no user declared invocation ID, we must make one.
if (invocationIdSym == nullptr) {
TType invocationIdType(EbtUint, EvqIn, 1);
TString* invocationIdName = NewPoolTString("InvocationId");
invocationIdType.getQualifier().builtIn = EbvInvocationId;
TVariable* variable = makeInternalVariable(*invocationIdName, invocationIdType);
globalQualifierFix(loc, variable->getWritableType().getQualifier());
trackLinkage(*variable);
invocationIdSym = intermediate.addSymbol(*variable);
}
TIntermTyped* element = intermediate.addIndex(EOpIndexIndirect, intermediate.addSymbol(*entryPointOutput),
invocationIdSym, loc);
element->setType(callReturn->getType());
returnAssign = handleAssign(loc, EOpAssign, element, callReturn);
} else {
returnAssign = handleAssign(loc, EOpAssign, intermediate.addSymbol(*entryPointOutput), callReturn);
}
intermediate.growAggregate(synthBody, returnAssign);
} else
intermediate.growAggregate(synthBody, callReturn);
// Output copies
@ -1914,10 +1953,29 @@ void HlslParseContext::remapEntryPointIO(TFunction& function, TVariable*& return
};
// return value is actually a shader-scoped output (out)
if (function.getType().getBasicType() == EbtVoid)
if (function.getType().getBasicType() == EbtVoid) {
returnValue = nullptr;
else
returnValue = makeIoVariable("@entryPointOutput", function.getWritableType(), EvqVaryingOut);
} else {
if (language == EShLangTessControl) {
// tessellation evaluation in HLSL writes a per-ctrl-pt value, but it needs to be an
// array in SPIR-V semantics. We'll write to it indexed by invocation ID.
returnValue = makeIoVariable("@entryPointOutput", function.getWritableType(), EvqVaryingOut);
TType outputType;
outputType.shallowCopy(function.getType());
// vertices has necessarily already been set when handling entry point attributes.
TArraySizes arraySizes;
arraySizes.addInnerSize(intermediate.getVertices());
outputType.newArraySizes(arraySizes);
clearUniformInputOutput(function.getWritableType().getQualifier());
returnValue = makeIoVariable("@entryPointOutput", outputType, EvqVaryingOut);
} else {
returnValue = makeIoVariable("@entryPointOutput", function.getWritableType(), EvqVaryingOut);
}
}
// parameters are actually shader-scoped inputs and outputs (in or out)
for (int i = 0; i < function.getParamCount(); i++) {
@ -7410,6 +7468,17 @@ void HlslParseContext::clearUniformInputOutput(TQualifier& qualifier)
correctUniform(qualifier);
}
// Return a symbol for the linkage variable of the given TBuiltInVariable type
TIntermSymbol* HlslParseContext::findLinkageSymbol(TBuiltInVariable biType) const
{
const auto it = builtInLinkageSymbols.find(biType);
if (it == builtInLinkageSymbols.end()) // if it wasn't declared by the user, return nullptr
return nullptr;
return intermediate.addSymbol(*it->second->getAsVariable());
}
// Add patch constant function invocation
void HlslParseContext::addPatchConstantInvocation()
{
@ -7481,15 +7550,6 @@ void HlslParseContext::addPatchConstantInvocation()
}
};
// Return a symbol for the linkage variable of the given TBuiltInVariable type
const auto findLinkageSymbol = [this](TBuiltInVariable biType) -> TIntermSymbol* {
const auto it = builtInLinkageSymbols.find(biType);
if (it == builtInLinkageSymbols.end()) // if it wasn't declared by the user, return nullptr
return nullptr;
return intermediate.addSymbol(*it->second->getAsVariable());
};
const auto isPerCtrlPt = [this](const TType& type) {
// TODO: this is not sufficient to reject all such cases in malformed shaders.
return type.isArray() && !type.isRuntimeSizedArray();

View File

@ -80,6 +80,7 @@ public:
void handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&, const TAttributeMap&, TIntermNode*& entryPointTree);
TIntermNode* transformEntryPoint(const TSourceLoc&, TFunction&, const TAttributeMap&);
void handleEntryPointAttributes(const TSourceLoc&, TFunction&, const TAttributeMap&);
void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
void remapEntryPointIO(TFunction& function, TVariable*& returnValue, TVector<TVariable*>& inputs, TVector<TVariable*>& outputs);
void remapNonEntryPointIO(TFunction& function);
@ -283,6 +284,9 @@ protected:
void finish() override; // post-processing
// Linkage symbol helpers
TIntermSymbol* findLinkageSymbol(TBuiltInVariable biType) const;
// Current state of parsing
struct TPragma contextPragma;
int loopNestingLevel; // 0 if outside all loops