HLSL: Flatten all input/output structs, regardless of stage.

This is needed because an output structure can contain embedded built-ins
(like SV_Position) which should not get locations assigned.
This commit is contained in:
John Kessenich 2016-09-16 01:52:14 -06:00
parent 7dc630f3da
commit f8e494c18c
7 changed files with 53 additions and 38 deletions

View File

@ -79,7 +79,7 @@ Shader version: 450
0:? 0.000000
0:45 Sequence
0:45 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:45 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:45 Branch: Return
0:? Linker Objects
@ -98,7 +98,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
@ -184,7 +184,7 @@ Shader version: 450
0:? 0.000000
0:45 Sequence
0:45 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:45 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:45 Branch: Return
0:? Linker Objects
@ -203,17 +203,17 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 120
// Id's are bound by 122
Capability Shader
Capability Sampled1D
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 97
EntryPoint Vertex 4 "main" 97 121
Name 4 "main"
Name 9 "txval20"
Name 12 "g_tTex2df4"
@ -240,6 +240,7 @@ Shader version: 450
Name 113 "g_tTex3df4"
Name 116 "g_tTex3di4"
Name 119 "g_tTex3du4"
Name 121 "Pos"
Decorate 12(g_tTex2df4) DescriptorSet 0
Decorate 16(g_sSamp) DescriptorSet 0
Decorate 16(g_sSamp) Binding 0
@ -249,7 +250,6 @@ Shader version: 450
Decorate 70(g_tTexcdi4) DescriptorSet 0
Decorate 80(g_tTexcdu4) DescriptorSet 0
MemberDecorate 90(VS_OUTPUT) 0 BuiltIn Position
Decorate 97(@entryPointOutput) Location 0
Decorate 100(g_sSamp2d) DescriptorSet 0
Decorate 103(g_tTex1df4a) DescriptorSet 0
Decorate 103(g_tTex1df4a) Binding 1
@ -260,6 +260,7 @@ Shader version: 450
Decorate 113(g_tTex3df4) DescriptorSet 0
Decorate 116(g_tTex3di4) DescriptorSet 0
Decorate 119(g_tTex3du4) DescriptorSet 0
Decorate 121(Pos) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -342,6 +343,8 @@ Shader version: 450
117: TypeImage 41(int) 3D sampled format:Unknown
118: TypePointer UniformConstant 117
119(g_tTex3du4): 118(ptr) Variable UniformConstant
120: TypePointer Output 7(fvec4)
121(Pos): 120(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(txval20): 8(ptr) Variable Function

View File

@ -38,13 +38,13 @@ Shader version: 450
0:? 0.000000
0:26 Sequence
0:26 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:26 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:26 Branch: Return
0:? Linker Objects
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
@ -89,24 +89,24 @@ Shader version: 450
0:? 0.000000
0:26 Sequence
0:26 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:26 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:26 Branch: Return
0:? Linker Objects
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 42
// Id's are bound by 44
Capability Shader
Capability Sampled1D
Capability ImageQuery
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 36
EntryPoint Vertex 4 "main" 36 43
Name 4 "main"
Name 8 "sizeQueryTemp"
Name 12 "g_tTex1df4"
@ -118,12 +118,13 @@ Shader version: 450
Name 29 "vsout"
Name 36 "@entryPointOutput"
Name 41 "g_sSamp"
Name 43 "Pos"
Decorate 12(g_tTex1df4) DescriptorSet 0
Decorate 12(g_tTex1df4) Binding 0
MemberDecorate 27(VS_OUTPUT) 0 BuiltIn Position
Decorate 36(@entryPointOutput) Location 0
Decorate 41(g_sSamp) DescriptorSet 0
Decorate 41(g_sSamp) Binding 0
Decorate 43(Pos) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
@ -146,6 +147,8 @@ Shader version: 450
39: TypeSampler
40: TypePointer UniformConstant 39
41(g_sSamp): 40(ptr) Variable UniformConstant
42: TypePointer Output 26(fvec4)
43(Pos): 42(ptr) Variable Output
4(main): 2 Function None 3
5: Label
8(sizeQueryTemp): 7(ptr) Variable Function

View File

@ -133,7 +133,7 @@ Shader version: 450
0:? 0.000000
0:69 Sequence
0:69 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:69 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:69 Branch: Return
0:? Linker Objects
@ -167,7 +167,7 @@ Shader version: 450
0:? 'o2' (uniform 2-component vector of int)
0:? 'o3' (uniform 3-component vector of int)
0:? 'o4' (uniform 4-component vector of int)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
@ -307,7 +307,7 @@ Shader version: 450
0:? 0.000000
0:69 Sequence
0:69 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:69 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:69 Branch: Return
0:? Linker Objects
@ -341,18 +341,18 @@ Shader version: 450
0:? 'o2' (uniform 2-component vector of int)
0:? 'o3' (uniform 3-component vector of int)
0:? 'o4' (uniform 4-component vector of int)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 162
// Id's are bound by 164
Capability Shader
Capability Sampled1D
Capability SampledCubeArray
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 115
EntryPoint Vertex 4 "main" 115 163
Name 4 "main"
Name 9 "g_tTex1df4"
Name 14 "c2"
@ -388,6 +388,7 @@ Shader version: 450
Name 159 "o2"
Name 160 "o3"
Name 161 "o4"
Name 163 "Pos"
Decorate 9(g_tTex1df4) DescriptorSet 0
Decorate 9(g_tTex1df4) Binding 0
Decorate 27(g_tTex1di4) DescriptorSet 0
@ -399,7 +400,6 @@ Shader version: 450
Decorate 90(g_tTex3di4) DescriptorSet 0
Decorate 99(g_tTex3du4) DescriptorSet 0
MemberDecorate 106(VS_OUTPUT) 0 BuiltIn Position
Decorate 115(@entryPointOutput) Location 0
Decorate 120(g_sSamp) DescriptorSet 0
Decorate 120(g_sSamp) Binding 0
Decorate 123(g_tTexcdf4) DescriptorSet 0
@ -414,6 +414,7 @@ Shader version: 450
Decorate 150(g_tTexcdf4a) DescriptorSet 0
Decorate 153(g_tTexcdi4a) DescriptorSet 0
Decorate 156(g_tTexcdu4a) DescriptorSet 0
Decorate 163(Pos) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -514,6 +515,8 @@ Shader version: 450
159(o2): 13(ptr) Variable UniformConstant
160(o3): 50(ptr) Variable UniformConstant
161(o4): 80(ptr) Variable UniformConstant
162: TypePointer Output 23(fvec4)
163(Pos): 162(ptr) Variable Output
4(main): 2 Function None 3
5: Label
108(vsout): 107(ptr) Variable Function

View File

@ -217,7 +217,7 @@ Shader version: 450
0:? 0.000000
0:48 Sequence
0:48 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:48 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:48 Branch: Return
0:? Linker Objects
@ -235,7 +235,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
@ -459,7 +459,7 @@ Shader version: 450
0:? 0.000000
0:48 Sequence
0:48 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:48 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:48 Branch: Return
0:? Linker Objects
@ -477,17 +477,17 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 160
// Id's are bound by 162
Capability Shader
Capability Sampled1D
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 156
EntryPoint Vertex 4 "main" 156 161
Name 4 "main"
Name 9 "txval10"
Name 12 "g_tTex1df4"
@ -519,6 +519,7 @@ Shader version: 450
Name 150 "vsout"
Name 156 "@entryPointOutput"
Name 159 "g_tTex1df4a"
Name 161 "Pos"
Decorate 12(g_tTex1df4) DescriptorSet 0
Decorate 12(g_tTex1df4) Binding 0
Decorate 16(g_sSamp) DescriptorSet 0
@ -535,9 +536,9 @@ Shader version: 450
Decorate 133(g_tTexcdi4) DescriptorSet 0
Decorate 142(g_tTexcdu4) DescriptorSet 0
MemberDecorate 148(VS_OUTPUT) 0 BuiltIn Position
Decorate 156(@entryPointOutput) Location 0
Decorate 159(g_tTex1df4a) DescriptorSet 0
Decorate 159(g_tTex1df4a) Binding 1
Decorate 161(Pos) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -630,6 +631,8 @@ Shader version: 450
155: TypePointer Output 148(VS_OUTPUT)
156(@entryPointOutput): 155(ptr) Variable Output
159(g_tTex1df4a): 11(ptr) Variable UniformConstant
160: TypePointer Output 7(fvec4)
161(Pos): 160(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(txval10): 8(ptr) Variable Function

View File

@ -163,7 +163,7 @@ Shader version: 450
0:? 0.000000
0:48 Sequence
0:48 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:48 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:48 Branch: Return
0:? Linker Objects
@ -181,7 +181,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
@ -351,7 +351,7 @@ Shader version: 450
0:? 0.000000
0:48 Sequence
0:48 move second child to first child (temp structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? '@entryPointOutput' (out structure{temp 4-component vector of float Position Pos})
0:48 'vsout' (temp structure{temp 4-component vector of float Position Pos})
0:48 Branch: Return
0:? Linker Objects
@ -369,17 +369,17 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? '@entryPointOutput' (layout(location=0 ) out structure{temp 4-component vector of float Position Pos})
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 156
// Id's are bound by 158
Capability Shader
Capability Sampled1D
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 152
EntryPoint Vertex 4 "main" 152 157
Name 4 "main"
Name 9 "txval10"
Name 12 "g_tTex1df4"
@ -411,6 +411,7 @@ Shader version: 450
Name 146 "vsout"
Name 152 "@entryPointOutput"
Name 155 "g_tTex1df4a"
Name 157 "Pos"
Decorate 12(g_tTex1df4) DescriptorSet 0
Decorate 12(g_tTex1df4) Binding 0
Decorate 16(g_sSamp) DescriptorSet 0
@ -427,9 +428,9 @@ Shader version: 450
Decorate 129(g_tTexcdi4) DescriptorSet 0
Decorate 138(g_tTexcdu4) DescriptorSet 0
MemberDecorate 144(VS_OUTPUT) 0 BuiltIn Position
Decorate 152(@entryPointOutput) Location 0
Decorate 155(g_tTex1df4a) DescriptorSet 0
Decorate 155(g_tTex1df4a) Binding 1
Decorate 157(Pos) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -518,6 +519,8 @@ Shader version: 450
151: TypePointer Output 144(VS_OUTPUT)
152(@entryPointOutput): 151(ptr) Variable Output
155(g_tTex1df4a): 11(ptr) Variable UniformConstant
156: TypePointer Output 7(fvec4)
157(Pos): 156(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(txval10): 8(ptr) Variable Function

View File

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1486"
#define GLSLANG_REVISION "Overload400-PrecQual.1487"
#define GLSLANG_DATE "16-Sep-2016"

View File

@ -710,8 +710,8 @@ bool HlslParseContext::shouldFlatten(const TType& type)
const TStorageQualifier qualifier = type.getQualifier().storage;
return type.isStruct() &&
((language == EShLangVertex && qualifier == EvqVaryingIn) ||
(language == EShLangFragment && qualifier == EvqVaryingOut));
(qualifier == EvqVaryingIn ||
qualifier == EvqVaryingOut);
}
// Figure out the mapping between a structure's top members and an