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

@@ -47,7 +47,7 @@ vertices = 4
0:? Sequence
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 0 (const int)
0:? direct index ( temp float)
@@ -59,7 +59,7 @@ vertices = 4
0:? 0 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 1 (const int)
0:? direct index ( temp float)
@@ -103,7 +103,7 @@ vertices = 4
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 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
Linked tessellation control stage:
@@ -157,7 +157,7 @@ vertices = 4
0:? Sequence
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 0 (const int)
0:? direct index ( temp float)
@@ -169,7 +169,7 @@ vertices = 4
0:? 0 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
0:? Constant:
0:? 1 (const int)
0:? direct index ( temp float)
@@ -213,16 +213,16 @@ vertices = 4
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 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 4-element array of float TessLevelOuter)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 90
// Id's are bound by 91
Capability Tessellation
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TessellationControl 4 "main" 42 45 52 60 62 69 89
EntryPoint TessellationControl 4 "main" 42 45 52 60 62 70 90
ExecutionMode 4 OutputVertices 4
Name 4 "main"
Name 8 "VS_OUT"
@@ -247,19 +247,19 @@ vertices = 4
Name 62 "pos"
Name 63 "param"
Name 65 "param"
Name 69 "@patchConstantOutput_edges"
Name 79 "output"
Name 87 "HS_CONSTANT_OUT"
Name 89 "@patchConstantOutput"
Name 70 "@patchConstantOutput_edges"
Name 80 "output"
Name 88 "HS_CONSTANT_OUT"
Name 90 "@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 69(@patchConstantOutput_edges) Patch
Decorate 69(@patchConstantOutput_edges) BuiltIn TessLevelOuter
Decorate 89(@patchConstantOutput) Patch
Decorate 89(@patchConstantOutput) Location 1
Decorate 70(@patchConstantOutput_edges) Patch
Decorate 70(@patchConstantOutput_edges) BuiltIn TessLevelOuter
Decorate 90(@patchConstantOutput) Patch
Decorate 90(@patchConstantOutput) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -295,16 +295,17 @@ vertices = 4
60(pid): 51(ptr) Variable Input
61: TypePointer Input 19(fvec4)
62(pos): 61(ptr) Variable Input
68: TypePointer Output 22
69(@patchConstantOutput_edges): 68(ptr) Variable Output
70: TypePointer Function 6(float)
73: TypePointer Output 6(float)
75: 31(int) Constant 1
80: 6(float) Constant 1073741824
82: 6(float) Constant 1090519040
87(HS_CONSTANT_OUT): TypeStruct
88: TypePointer Output 87(HS_CONSTANT_OUT)
89(@patchConstantOutput): 88(ptr) Variable Output
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
4(main): 2 Function None 3
5: Label
40(ip): 12(ptr) Variable Function
@@ -330,14 +331,14 @@ vertices = 4
Store 65(param) 66
67:23(HS_CONSTANT_OUT) FunctionCall 27(PCF(u1;vf4;) 63(param) 65(param)
Store 59(@patchConstantResult) 67
71: 70(ptr) AccessChain 59(@patchConstantResult) 32 32
72: 6(float) Load 71
74: 73(ptr) AccessChain 69(@patchConstantOutput_edges) 32
Store 74 72
76: 70(ptr) AccessChain 59(@patchConstantResult) 32 75
77: 6(float) Load 76
78: 73(ptr) AccessChain 69(@patchConstantOutput_edges) 75
Store 78 77
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
Return
@@ -357,11 +358,11 @@ vertices = 4
25(pid): 18(ptr) FunctionParameter
26(pos): 20(ptr) FunctionParameter
28: Label
79(output): 58(ptr) Variable Function
81: 70(ptr) AccessChain 79(output) 32 32
Store 81 80
83: 70(ptr) AccessChain 79(output) 32 75
Store 83 82
84:23(HS_CONSTANT_OUT) Load 79(output)
ReturnValue 84
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
FunctionEnd