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

@@ -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