Commit 132d3318 by steve-lunarg

HLSL: struct splitting: assignments of hierarchical split types

This commit adds support for copying nested hierarchical types of split types. E.g, a struct of a struct containing both user and builtin interstage IO variables. When copying split types, if any subtree does NOT contain builtin interstage IO, we can copy the whole subtree with one assignment, which saves a bunch of AST verbosity for memberwise copies of that subtree.
parent a2e75310
hlsl.gather.basic.dx10.vert
Shader version: 450
0:? Sequence
0:28 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:28 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:28 Function Parameters:
0:? Sequence
0:33 Sequence
......@@ -87,7 +87,6 @@ Shader version: 450
0:45 0 (const int)
0:45 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_sSamp2d' (uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
......@@ -103,6 +102,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
......@@ -110,7 +110,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
0:28 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:28 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:28 Function Parameters:
0:? Sequence
0:33 Sequence
......@@ -196,7 +196,6 @@ Shader version: 450
0:45 0 (const int)
0:45 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_sSamp2d' (uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
......@@ -212,6 +211,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
......
hlsl.getdimensions.dx10.vert
Shader version: 450
0:? Sequence
0:11 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:11 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:11 Function Parameters:
0:? Sequence
0:21 Sequence
......@@ -46,9 +46,9 @@ Shader version: 450
0:26 0 (const int)
0:26 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
......@@ -56,7 +56,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
0:11 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:11 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:11 Function Parameters:
0:? Sequence
0:21 Sequence
......@@ -101,9 +101,9 @@ Shader version: 450
0:26 0 (const int)
0:26 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
......
hlsl.load.basic.dx10.vert
Shader version: 450
0:? Sequence
0:47 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:47 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:47 Function Parameters:
0:? Sequence
0:51 textureFetch (temp 4-component vector of float)
......@@ -195,7 +195,6 @@ Shader version: 450
0:69 0 (const int)
0:69 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? 'g_tTex1di4' (uniform itexture1D)
......@@ -219,6 +218,7 @@ Shader version: 450
0:? 'g_tTexcdi4a' (uniform itextureCubeArray)
0:? 'g_tTexcdu4a' (uniform utextureCubeArray)
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int c1, layout(offset=8 ) uniform 2-component vector of int c2, layout(offset=16 ) uniform 3-component vector of int c3, layout(offset=32 ) uniform 4-component vector of int c4, layout(offset=48 ) uniform int o1, layout(offset=56 ) uniform 2-component vector of int o2, layout(offset=64 ) uniform 3-component vector of int o3, layout(offset=80 ) uniform 4-component vector of int o4})
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
......@@ -226,7 +226,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
0:47 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:47 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:47 Function Parameters:
0:? Sequence
0:51 textureFetch (temp 4-component vector of float)
......@@ -420,7 +420,6 @@ Shader version: 450
0:69 0 (const int)
0:69 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? 'g_tTex1di4' (uniform itexture1D)
......@@ -444,6 +443,7 @@ Shader version: 450
0:? 'g_tTexcdi4a' (uniform itextureCubeArray)
0:? 'g_tTexcdu4a' (uniform utextureCubeArray)
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int c1, layout(offset=8 ) uniform 2-component vector of int c2, layout(offset=16 ) uniform 3-component vector of int c3, layout(offset=32 ) uniform 4-component vector of int c4, layout(offset=48 ) uniform int o1, layout(offset=56 ) uniform 2-component vector of int o2, layout(offset=64 ) uniform 3-component vector of int o3, layout(offset=80 ) uniform 4-component vector of int o4})
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
......
hlsl.samplegrad.basic.dx10.vert
Shader version: 450
0:? Sequence
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
......@@ -225,7 +225,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
......@@ -240,6 +239,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
......@@ -247,7 +247,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
......@@ -471,7 +471,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
......@@ -486,6 +485,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
......
hlsl.samplelevel.basic.dx10.vert
Shader version: 450
0:? Sequence
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
......@@ -171,7 +171,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
......@@ -186,6 +185,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
......@@ -193,7 +193,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
......@@ -363,7 +363,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
......@@ -378,6 +377,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
......
hlsl.struct.split.trivial.geom
Shader version: 450
invocations = -1
max_vertices = 3
input primitive = triangles
output primitive = triangle_strip
0:? Sequence
0:14 Function Definition: main(struct-PS_IN-vf41[3];struct-GS_OUT-vf41; (temp void)
0:14 Function Parameters:
0:14 'i' (in 3-element array of structure{temp 4-component vector of float Position pos})
0:14 'ts' (out structure{temp 4-component vector of float Position pos})
0:? Sequence
0:17 Sequence
0:17 move second child to first child (temp int)
0:17 'x' (temp int)
0:17 Constant:
0:17 0 (const int)
0:17 Loop with condition tested first
0:17 Loop Condition
0:17 Compare Less Than (temp bool)
0:17 'x' (temp int)
0:17 Constant:
0:17 3 (const int)
0:17 Loop Body
0:? Sequence
0:18 move second child to first child (temp 4-component vector of float)
0:18 pos: direct index for structure (temp 4-component vector of float)
0:18 'o' (temp structure{temp 4-component vector of float pos})
0:18 Constant:
0:18 0 (const int)
0:18 indirect index (temp 4-component vector of float Position)
0:18 'i.pos' (in 3-element array of 4-component vector of float Position)
0:18 'x' (temp int)
0:19 Sequence
0:19 Sequence
0:19 move second child to first child (temp 4-component vector of float)
0:? 'ts.pos' (out 4-component vector of float Position)
0:19 pos: direct index for structure (temp 4-component vector of float)
0:19 'o' (temp structure{temp 4-component vector of float pos})
0:19 Constant:
0:19 0 (const int)
0:19 EmitVertex (temp void)
0:17 Loop Terminal Expression
0:17 Pre-Increment (temp int)
0:17 'x' (temp int)
0:? Linker Objects
0:? 'i.pos' (in 3-element array of 4-component vector of float Position)
0:? 'ts.pos' (out 4-component vector of float Position)
Linked geometry stage:
Shader version: 450
invocations = 1
max_vertices = 3
input primitive = triangles
output primitive = triangle_strip
0:? Sequence
0:14 Function Definition: main(struct-PS_IN-vf41[3];struct-GS_OUT-vf41; (temp void)
0:14 Function Parameters:
0:14 'i' (in 3-element array of structure{temp 4-component vector of float Position pos})
0:14 'ts' (out structure{temp 4-component vector of float Position pos})
0:? Sequence
0:17 Sequence
0:17 move second child to first child (temp int)
0:17 'x' (temp int)
0:17 Constant:
0:17 0 (const int)
0:17 Loop with condition tested first
0:17 Loop Condition
0:17 Compare Less Than (temp bool)
0:17 'x' (temp int)
0:17 Constant:
0:17 3 (const int)
0:17 Loop Body
0:? Sequence
0:18 move second child to first child (temp 4-component vector of float)
0:18 pos: direct index for structure (temp 4-component vector of float)
0:18 'o' (temp structure{temp 4-component vector of float pos})
0:18 Constant:
0:18 0 (const int)
0:18 indirect index (temp 4-component vector of float Position)
0:18 'i.pos' (in 3-element array of 4-component vector of float Position)
0:18 'x' (temp int)
0:19 Sequence
0:19 Sequence
0:19 move second child to first child (temp 4-component vector of float)
0:? 'ts.pos' (out 4-component vector of float Position)
0:19 pos: direct index for structure (temp 4-component vector of float)
0:19 'o' (temp structure{temp 4-component vector of float pos})
0:19 Constant:
0:19 0 (const int)
0:19 EmitVertex (temp void)
0:17 Loop Terminal Expression
0:17 Pre-Increment (temp int)
0:17 'x' (temp int)
0:? Linker Objects
0:? 'i.pos' (in 3-element array of 4-component vector of float Position)
0:? 'ts.pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 42
Capability Geometry
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Geometry 4 "main" 28 36
ExecutionMode 4 Triangles
ExecutionMode 4 Invocations 1
ExecutionMode 4 OutputTriangleStrip
ExecutionMode 4 OutputVertices 3
Name 4 "main"
Name 8 "x"
Name 21 "GS_OUT"
MemberName 21(GS_OUT) 0 "pos"
Name 23 "o"
Name 28 "i.pos"
Name 36 "ts.pos"
Decorate 28(i.pos) BuiltIn Position
Decorate 36(ts.pos) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
9: 6(int) Constant 0
16: 6(int) Constant 3
17: TypeBool
19: TypeFloat 32
20: TypeVector 19(float) 4
21(GS_OUT): TypeStruct 20(fvec4)
22: TypePointer Function 21(GS_OUT)
24: TypeInt 32 0
25: 24(int) Constant 3
26: TypeArray 20(fvec4) 25
27: TypePointer Input 26
28(i.pos): 27(ptr) Variable Input
30: TypePointer Input 20(fvec4)
33: TypePointer Function 20(fvec4)
35: TypePointer Output 20(fvec4)
36(ts.pos): 35(ptr) Variable Output
40: 6(int) Constant 1
4(main): 2 Function None 3
5: Label
8(x): 7(ptr) Variable Function
23(o): 22(ptr) Variable Function
Store 8(x) 9
Branch 10
10: Label
LoopMerge 12 13 None
Branch 14
14: Label
15: 6(int) Load 8(x)
18: 17(bool) SLessThan 15 16
BranchConditional 18 11 12
11: Label
29: 6(int) Load 8(x)
31: 30(ptr) AccessChain 28(i.pos) 29
32: 20(fvec4) Load 31
34: 33(ptr) AccessChain 23(o) 9
Store 34 32
37: 33(ptr) AccessChain 23(o) 9
38: 20(fvec4) Load 37
Store 36(ts.pos) 38
EmitVertex
Branch 13
13: Label
39: 6(int) Load 8(x)
41: 6(int) IAdd 39 40
Store 8(x) 41
Branch 10
12: Label
Return
FunctionEnd
hlsl.struct.split.trivial.vert
Shader version: 450
0:? Sequence
0:16 Function Definition: main(struct-VS_INPUT-vf41;vf4; (temp structure{temp 4-component vector of float Pos})
0:16 Function Definition: main(struct-VS_INPUT-vf41;vf4; (temp structure{temp 4-component vector of float Position Pos})
0:16 Function Parameters:
0:16 'vsin' (in structure{temp 4-component vector of float Pos_in})
0:16 'Pos_loose' (in 4-component vector of float Position)
......@@ -24,9 +24,9 @@ Shader version: 450
0:21 0 (const int)
0:21 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'Pos_in' (in 4-component vector of float Position)
0:? 'Pos_loose' (in 4-component vector of float Position)
0:? 'Pos' (out 4-component vector of float Position)
Linked vertex stage:
......@@ -34,7 +34,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
0:16 Function Definition: main(struct-VS_INPUT-vf41;vf4; (temp structure{temp 4-component vector of float Pos})
0:16 Function Definition: main(struct-VS_INPUT-vf41;vf4; (temp structure{temp 4-component vector of float Position Pos})
0:16 Function Parameters:
0:16 'vsin' (in structure{temp 4-component vector of float Pos_in})
0:16 'Pos_loose' (in 4-component vector of float Position)
......@@ -57,9 +57,9 @@ Shader version: 450
0:21 0 (const int)
0:21 Branch: Return
0:? Linker Objects
0:? 'Pos' (out 4-component vector of float Position)
0:? 'Pos_in' (in 4-component vector of float Position)
0:? 'Pos_loose' (in 4-component vector of float Position)
0:? 'Pos' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
......
......@@ -49,7 +49,7 @@ output primitive = triangle_strip
0:22 Sequence
0:22 Sequence
0:22 move second child to first child (temp 4-component vector of float)
0:? 'position' (out 4-component vector of float Position)
0:? 'outStream.position' (out 4-component vector of float Position)
0:22 position: direct index for structure (temp 4-component vector of float)
0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
0:22 Constant:
......@@ -76,7 +76,7 @@ output primitive = triangle_strip
0:? Linker Objects
0:? 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
0:? 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
0:? 'position' (out 4-component vector of float Position)
0:? 'outStream.position' (out 4-component vector of float Position)
Linked geometry stage:
......@@ -132,7 +132,7 @@ output primitive = triangle_strip
0:22 Sequence
0:22 Sequence
0:22 move second child to first child (temp 4-component vector of float)
0:? 'position' (out 4-component vector of float Position)
0:? 'outStream.position' (out 4-component vector of float Position)
0:22 position: direct index for structure (temp 4-component vector of float)
0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
0:22 Constant:
......@@ -159,7 +159,7 @@ output primitive = triangle_strip
0:? Linker Objects
0:? 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
0:? 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
0:? 'position' (out 4-component vector of float Position)
0:? 'outStream.position' (out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
......@@ -184,13 +184,13 @@ output primitive = triangle_strip
MemberName 14(VertexData) 1 "color"
MemberName 14(VertexData) 2 "uv"
Name 19 "vin"
Name 36 "position"
Name 36 "outStream.position"
Name 39 "PS_IN"
MemberName 39(PS_IN) 0 "color"
MemberName 39(PS_IN) 1 "uv"
Name 41 "outStream"
Decorate 19(vin) Location 0
Decorate 36(position) BuiltIn Position
Decorate 36(outStream.position) BuiltIn Position
Decorate 41(outStream) Location 0
2: TypeVoid
3: TypeFunction 2
......@@ -214,7 +214,7 @@ output primitive = triangle_strip
29: TypePointer Function 8(fvec2)
31: 12(int) Constant 0
35: TypePointer Output 7(fvec4)
36(position): 35(ptr) Variable Output
36(outStream.position): 35(ptr) Variable Output
39(PS_IN): TypeStruct 7(fvec4) 8(fvec2)
40: TypePointer Output 39(PS_IN)
41(outStream): 40(ptr) Variable Output
......@@ -236,7 +236,7 @@ output primitive = triangle_strip
Store 34 33
37: 23(ptr) AccessChain 11(vout) 31
38: 7(fvec4) Load 37
Store 36(position) 38
Store 36(outStream.position) 38
42: 23(ptr) AccessChain 11(vout) 13
43: 7(fvec4) Load 42
44: 35(ptr) AccessChain 41(outStream) 31
......
struct PSInput
{
float4 Pos : SV_POSITION;
float2 TexCoord : TEXCOORD;
float3 TerrainPos : TERRAINPOS;
uint VertexID : VertexID;
};
typedef PSInput foo_t[2][3];
[maxvertexcount(4)]
void main(point uint v[1] : VertexID, inout TriangleStream<PSInput> OutputStream)
{
foo_t Verts;
PSInput Out = (PSInput) 0;
for (int x=0; x<2; ++x)
for (int y=0; y<2; ++y)
Verts[x][y] = Out;
}
struct STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO
{
float m0_array[2];
int m1;
};
struct PS_IN
{
float4 pos : SV_Position;
float2 tc : TEXCOORD0;
// float c : SV_ClipDistance0;
};
struct GS_OUT
{
PS_IN psIn;
STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO contains_no_builtin_io;
};
[maxvertexcount(3)]
void main(triangle PS_IN tin[3], inout TriangleStream <GS_OUT> ts )
{
GS_OUT o;
o.psIn.pos = float4(1,2,3,4);
o.psIn.tc = float2(5,6);
ts.Append(o);
}
struct PS_IN
{
float4 pos : SV_Position;
};
struct GS_OUT
{
float4 pos : SV_Position;
};
[maxvertexcount(3)]
void main(triangle PS_IN i[3], inout TriangleStream <GS_OUT> ts)
{
GS_OUT o;
for (int x=0; x<3; ++x) {
o.pos = i[x].pos;
ts.Append(o);
}
}
......@@ -1320,7 +1320,7 @@ public:
virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
// Return true if this is interstage IO
virtual bool isInterstageIO() const
virtual bool isBuiltInInterstageIO() const
{
switch (getQualifier().builtIn) {
case EbvPosition:
......@@ -1401,28 +1401,28 @@ public:
}
// Recursively checks if the type contains an interstage IO builtin
virtual bool containsInterstageIO() const
virtual bool containsBuiltInInterstageIO() const
{
if (isInterstageIO())
if (isBuiltInInterstageIO())
return true;
if (! structure)
return false;
for (unsigned int i = 0; i < structure->size(); ++i) {
if ((*structure)[i].type->containsInterstageIO())
if ((*structure)[i].type->containsBuiltInInterstageIO())
return true;
}
return false;
}
// Recursively checks whether a struct contains only interstage IO
virtual bool containsOnlyInterstageIO() const
virtual bool containsOnlyBuiltInInterstageIO() const
{
if (! structure)
return isInterstageIO();
return isBuiltInInterstageIO();
for (unsigned int i = 0; i < structure->size(); ++i) {
if (!(*structure)[i].type->containsOnlyInterstageIO())
if (!(*structure)[i].type->containsOnlyBuiltInInterstageIO())
return false;
}
return true;
......
......@@ -205,7 +205,10 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.stringtoken.frag", "main"},
{"hlsl.string.frag", "main"},
{"hlsl.struct.split-1.vert", "main"},
{"hlsl.struct.split.array.geom", "main"},
{"hlsl.struct.split.call.vert", "main"},
{"hlsl.struct.split.nested.geom", "main"},
{"hlsl.struct.split.trivial.geom", "main"},
{"hlsl.struct.split.trivial.vert", "main"},
{"hlsl.structarray.flatten.frag", "main"},
{"hlsl.structarray.flatten.geom", "main"},
......
......@@ -478,7 +478,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type)
// type_specifier
if (! acceptType(type)) {
// If this is not a type, we may have inadvertently gone down a wrong path
// py parsing "sample", which can be treated like either an identifier or a
// by parsing "sample", which can be treated like either an identifier or a
// qualifier. Back it out, if we did.
if (qualifier.sample)
recedeToken();
......
......@@ -209,9 +209,10 @@ protected:
bool isFinalFlattening(const TType& type) const { return !(type.isStruct() || type.isArray()); }
// Structure splitting (splits interstage builtin types into its own struct)
bool shouldSplit(const TSourceLoc& loc, const TType&);
TIntermTyped* splitAccess(const TSourceLoc& loc, TIntermTyped*& base, int& member);
TType& split(TType& type);
bool shouldSplit(const TType&);
TIntermTyped* splitAccessStruct(const TSourceLoc& loc, TIntermTyped*& base, int& member);
void splitAccessArray(const TSourceLoc& loc, TIntermTyped* base, TIntermTyped* index);
TType& split(TType& type, TString name, const TType* outerStructType = nullptr);
void split(TIntermTyped*);
void split(const TVariable&);
bool wasSplit(const TIntermTyped* node) const;
......@@ -301,8 +302,32 @@ protected:
TMap<const TTypeList*, TType*> sanitizedTypeMap;
// Structure splitting data:
TMap<TBuiltInVariable, TVariable*> interstageIo; // new structure created for interstage IO from user structs.
TMap<int, TVariable*> splitIoVars; // individual flattened variables
TMap<int, TVariable*> splitIoVars; // variables with the builtin interstage IO removed, indexed by unique ID.
// The builtin interstage IO map considers e.g, EvqPosition on input and output separately, so that we
// can build the linkage correctly if position appears on both sides. Otherwise, multiple positions
// are considered identical.
struct tInterstageIoData {
tInterstageIoData(const TType& memberType, const TType& storageType) :
builtIn(memberType.getQualifier().builtIn),
storage(storageType.getQualifier().storage) { }
TBuiltInVariable builtIn;
TStorageQualifier storage;
// ordering for maps
bool operator<(const tInterstageIoData d) const {
return (builtIn != d.builtIn) ? (builtIn < d.builtIn) : (storage < d.storage);
}
};
TMap<tInterstageIoData, TVariable*> interstageBuiltInIo; // individual builtin interstage IO vars, inxed by builtin type.
// We have to move array references to structs containing builtin interstage IO to the split variables.
// This is only handled for one level. This stores the index, because we'll need it in the future, since
// unlike normal array references, here the index happens before we discover what it applies to.
TIntermTyped* builtInIoIndex;
TIntermTyped* builtInIoBase;
unsigned int nextInLocation;
unsigned int nextOutLocation;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment