HLSL: require tessellation factors to be fixed size arrays

SPIR-V requires that tessellation factor arrays be size 4 (outer) or 2 (inner).
HLSL allows other sizes such as 3, or even scalars.  This commit converts
between them by forcing the IO types to be the SPIR-V size, and allowing
copies between the internal and IO types to handle these cases.
This commit is contained in:
steve-lunarg
2017-03-17 18:51:05 -06:00
parent 9cee73e028
commit 194f0f39ec
6 changed files with 216 additions and 162 deletions

View File

@@ -74,7 +74,7 @@ vertices = 3
0:? Sequence
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 0 (const int)
0:? direct index ( temp float)
@@ -86,7 +86,7 @@ vertices = 3
0:? 0 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 1 (const int)
0:? direct index ( temp float)
@@ -98,7 +98,7 @@ vertices = 3
0:? 1 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 2 (const int)
0:? direct index ( temp float)
@@ -109,7 +109,10 @@ vertices = 3
0:? Constant:
0:? 2 (const int)
0:? move second child to first child ( temp float)
0:? '@patchConstantOutput_flInFactor' ( patch out float TessLevelInner)
0:? direct index ( patch out float TessLevelInner)
0:? '@patchConstantOutput_flInFactor' ( patch out 2-element array of float TessLevelInner)
0:? Constant:
0:? 0 (const int)
0:? flInFactor: direct index for structure ( temp float)
0:? '@patchConstantResult' ( temp structure{ temp 3-element array of float tfactor, temp float flInFactor})
0:? Constant:
@@ -186,8 +189,8 @@ vertices = 3
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{})
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_flInFactor' ( patch out float TessLevelInner)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? '@patchConstantOutput_flInFactor' ( patch out 2-element array of float TessLevelInner)
Linked tessellation control stage:
@@ -268,7 +271,7 @@ vertices = 3
0:? Sequence
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 0 (const int)
0:? direct index ( temp float)
@@ -280,7 +283,7 @@ vertices = 3
0:? 0 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 1 (const int)
0:? direct index ( temp float)
@@ -292,7 +295,7 @@ vertices = 3
0:? 1 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 2 (const int)
0:? direct index ( temp float)
@@ -303,7 +306,10 @@ vertices = 3
0:? Constant:
0:? 2 (const int)
0:? move second child to first child ( temp float)
0:? '@patchConstantOutput_flInFactor' ( patch out float TessLevelInner)
0:? direct index ( patch out float TessLevelInner)
0:? '@patchConstantOutput_flInFactor' ( patch out 2-element array of float TessLevelInner)
0:? Constant:
0:? 0 (const int)
0:? flInFactor: direct index for structure ( temp float)
0:? '@patchConstantResult' ( temp structure{ temp 3-element array of float tfactor, temp float flInFactor})
0:? Constant:
@@ -380,17 +386,17 @@ vertices = 3
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{})
0:? '@patchConstantOutput_tfactor' ( patch out 3-element array of float TessLevelOuter)
0:? '@patchConstantOutput_flInFactor' ( patch out float TessLevelInner)
0:? '@patchConstantOutput_tfactor' ( patch out 4-element array of float TessLevelOuter)
0:? '@patchConstantOutput_flInFactor' ( patch out 2-element array of float TessLevelInner)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 119
// Id's are bound by 124
Capability Tessellation
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TessellationControl 4 "main" 41 45 48 89 101 118
EntryPoint TessellationControl 4 "main" 41 45 48 91 105 123
ExecutionMode 4 OutputVertices 3
Name 4 "main"
Name 8 "hs_in_t"
@@ -424,20 +430,20 @@ vertices = 3
Name 79 "param"
Name 81 "param"
Name 85 "@patchConstantResult"
Name 89 "@patchConstantOutput_tfactor"
Name 101 "@patchConstantOutput_flInFactor"
Name 104 "o"
Name 116 "hs_pcf_t"
Name 118 "@patchConstantOutput"
Name 91 "@patchConstantOutput_tfactor"
Name 105 "@patchConstantOutput_flInFactor"
Name 109 "o"
Name 121 "hs_pcf_t"
Name 123 "@patchConstantOutput"
Decorate 41(i) Location 0
Decorate 45(cpid) BuiltIn InvocationId
Decorate 48(@entryPointOutput) Location 0
Decorate 89(@patchConstantOutput_tfactor) Patch
Decorate 89(@patchConstantOutput_tfactor) BuiltIn TessLevelOuter
Decorate 101(@patchConstantOutput_flInFactor) Patch
Decorate 101(@patchConstantOutput_flInFactor) BuiltIn TessLevelInner
Decorate 118(@patchConstantOutput) Patch
Decorate 118(@patchConstantOutput) Location 1
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
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -472,15 +478,19 @@ vertices = 3
70: 29(int) Constant 1
77: 29(int) Constant 2
84: TypePointer Function 22(hs_pcf_t)
88: TypePointer Output 21
89(@patchConstantOutput_tfactor): 88(ptr) Variable Output
90: TypePointer Function 6(float)
93: TypePointer Output 6(float)
101(@patchConstantOutput_flInFactor): 93(ptr) Variable Output
111: 6(float) Constant 1082130432
116(hs_pcf_t): TypeStruct
117: TypePointer Output 116(hs_pcf_t)
118(@patchConstantOutput): 117(ptr) Variable Output
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
4(main): 2 Function None 3
5: Label
39(i): 12(ptr) Variable Function
@@ -535,21 +545,22 @@ vertices = 3
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
91: 90(ptr) AccessChain 85(@patchConstantResult) 30 30
92: 6(float) Load 91
94: 93(ptr) AccessChain 89(@patchConstantOutput_tfactor) 30
Store 94 92
95: 90(ptr) AccessChain 85(@patchConstantResult) 30 70
96: 6(float) Load 95
97: 93(ptr) AccessChain 89(@patchConstantOutput_tfactor) 70
Store 97 96
98: 90(ptr) AccessChain 85(@patchConstantResult) 30 77
99: 6(float) Load 98
100: 93(ptr) AccessChain 89(@patchConstantOutput_tfactor) 77
Store 100 99
102: 90(ptr) AccessChain 85(@patchConstantResult) 70
103: 6(float) Load 102
Store 101(@patchConstantOutput_flInFactor) 103
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
101: 6(float) Load 100
102: 95(ptr) AccessChain 91(@patchConstantOutput_tfactor) 77
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
Return
@@ -570,18 +581,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
104(o): 84(ptr) Variable Function
105: 6(float) CompositeExtract 24(pcf_out) 0 0 0
106: 90(ptr) AccessChain 104(o) 30 30
Store 106 105
107: 6(float) CompositeExtract 24(pcf_out) 1 0 0
108: 90(ptr) AccessChain 104(o) 30 70
Store 108 107
109: 6(float) CompositeExtract 24(pcf_out) 2 0 0
110: 90(ptr) AccessChain 104(o) 30 77
Store 110 109
112: 90(ptr) AccessChain 104(o) 70
Store 112 111
113:22(hs_pcf_t) Load 104(o)
ReturnValue 113
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
FunctionEnd