
This adds structure splitting, which among other things will enable GS support where input structs are passed, and thus become input arrays of structs in the GS inputs. That is a common GS case. The salient points of this PR are: * Structure splitting has been changed from "always between stages" to "only into the VS and out of the PS". It had previously happened between stages because it's not legal to pass a struct containing a builtin IO variable. * Structs passed between stages are now split into a struct containing ONLY user types, and a collection of loose builtin IO variables, if any. The user-part is passed as a normal struct between stages, which is valid SPIR-V now that the builtin IO is removed. * Internal to the shader, a sanitized struct (with IO qualifiers removed) is used, so that e.g, functions can work unmodified. * If a builtin IO such as Position occurs in an arrayed struct, for example as an input to a GS, the array reference is moved to the split-off loose variable, which is given the array dimension itself. When passing things around inside the shader, such as over a function call, the the original type is used in a sanitized form that removes the builtIn qualifications and makes them temporaries. This means internal function calls do not have to change. However, the type when returned from the shader will be member-wise copied from the internal sanitized one to the external type. The sanitized type is used in variable declarations. When copying split types and unsplit, if a sub-struct contains only user variables, it is copied as a single entity to avoid more AST verbosity. Above strategy arrived at with talks with @johnkslang. This is a big complex change. I'm inclined to leave it as a WIP until it can get some exposure to real world cases.
251 lines
16 KiB
Plaintext
251 lines
16 KiB
Plaintext
hlsl.structarray.flatten.geom
|
|
Shader version: 450
|
|
invocations = -1
|
|
max_vertices = 4
|
|
input primitive = lines
|
|
output primitive = triangle_strip
|
|
0:? Sequence
|
|
0:16 Function Definition: main(struct-VertexData-vf4-vf4-vf21[2];struct-PS_IN-vf4-vf4-vf21; (temp void)
|
|
0:16 Function Parameters:
|
|
0:16 '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:16 'outStream' (out structure{temp 4-component vector of float Position position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:? Sequence
|
|
0:19 move second child to first child (temp 4-component vector of float)
|
|
0:19 color: direct index for structure (temp 4-component vector of float)
|
|
0:19 '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:19 Constant:
|
|
0:19 1 (const int)
|
|
0:19 color: direct index for structure (temp 4-component vector of float)
|
|
0:19 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:19 '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:19 Constant:
|
|
0:19 1 (const int)
|
|
0:19 Constant:
|
|
0:19 1 (const int)
|
|
0:20 move second child to first child (temp 2-component vector of float)
|
|
0:20 uv: direct index for structure (temp 2-component vector of float)
|
|
0:20 '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:20 Constant:
|
|
0:20 2 (const int)
|
|
0:20 uv: direct index for structure (temp 2-component vector of float)
|
|
0:20 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:20 '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:20 Constant:
|
|
0:20 1 (const int)
|
|
0:20 Constant:
|
|
0:20 2 (const int)
|
|
0:21 move second child to first child (temp 4-component vector of float)
|
|
0:21 position: direct index for structure (temp 4-component vector of float)
|
|
0:21 '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:21 Constant:
|
|
0:21 0 (const int)
|
|
0:21 position: direct index for structure (temp 4-component vector of float)
|
|
0:21 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:21 '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:21 Constant:
|
|
0:21 1 (const int)
|
|
0:21 Constant:
|
|
0:21 0 (const int)
|
|
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: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:
|
|
0:22 0 (const int)
|
|
0:22 move second child to first child (temp 4-component vector of float)
|
|
0:22 color: direct index for structure (temp 4-component vector of float)
|
|
0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:22 Constant:
|
|
0:22 0 (const int)
|
|
0:22 color: 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:
|
|
0:22 1 (const int)
|
|
0:22 move second child to first child (temp 2-component vector of float)
|
|
0:22 uv: direct index for structure (temp 2-component vector of float)
|
|
0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:22 Constant:
|
|
0:22 1 (const int)
|
|
0:22 uv: direct index for structure (temp 2-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:
|
|
0:22 2 (const int)
|
|
0:22 EmitVertex (temp void)
|
|
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)
|
|
|
|
|
|
Linked geometry stage:
|
|
|
|
|
|
Shader version: 450
|
|
invocations = 1
|
|
max_vertices = 4
|
|
input primitive = lines
|
|
output primitive = triangle_strip
|
|
0:? Sequence
|
|
0:16 Function Definition: main(struct-VertexData-vf4-vf4-vf21[2];struct-PS_IN-vf4-vf4-vf21; (temp void)
|
|
0:16 Function Parameters:
|
|
0:16 '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:16 'outStream' (out structure{temp 4-component vector of float Position position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:? Sequence
|
|
0:19 move second child to first child (temp 4-component vector of float)
|
|
0:19 color: direct index for structure (temp 4-component vector of float)
|
|
0:19 '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:19 Constant:
|
|
0:19 1 (const int)
|
|
0:19 color: direct index for structure (temp 4-component vector of float)
|
|
0:19 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:19 '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:19 Constant:
|
|
0:19 1 (const int)
|
|
0:19 Constant:
|
|
0:19 1 (const int)
|
|
0:20 move second child to first child (temp 2-component vector of float)
|
|
0:20 uv: direct index for structure (temp 2-component vector of float)
|
|
0:20 '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:20 Constant:
|
|
0:20 2 (const int)
|
|
0:20 uv: direct index for structure (temp 2-component vector of float)
|
|
0:20 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:20 '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:20 Constant:
|
|
0:20 1 (const int)
|
|
0:20 Constant:
|
|
0:20 2 (const int)
|
|
0:21 move second child to first child (temp 4-component vector of float)
|
|
0:21 position: direct index for structure (temp 4-component vector of float)
|
|
0:21 '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:21 Constant:
|
|
0:21 0 (const int)
|
|
0:21 position: direct index for structure (temp 4-component vector of float)
|
|
0:21 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:21 '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:21 Constant:
|
|
0:21 1 (const int)
|
|
0:21 Constant:
|
|
0:21 0 (const int)
|
|
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: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:
|
|
0:22 0 (const int)
|
|
0:22 move second child to first child (temp 4-component vector of float)
|
|
0:22 color: direct index for structure (temp 4-component vector of float)
|
|
0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:22 Constant:
|
|
0:22 0 (const int)
|
|
0:22 color: 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:
|
|
0:22 1 (const int)
|
|
0:22 move second child to first child (temp 2-component vector of float)
|
|
0:22 uv: direct index for structure (temp 2-component vector of float)
|
|
0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
|
|
0:22 Constant:
|
|
0:22 1 (const int)
|
|
0:22 uv: direct index for structure (temp 2-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:
|
|
0:22 2 (const int)
|
|
0:22 EmitVertex (temp void)
|
|
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)
|
|
|
|
// Module Version 10000
|
|
// Generated by (magic number): 80001
|
|
// Id's are bound by 49
|
|
|
|
Capability Geometry
|
|
1: ExtInstImport "GLSL.std.450"
|
|
MemoryModel Logical GLSL450
|
|
EntryPoint Geometry 4 "main" 19 36 41
|
|
ExecutionMode 4 InputLines
|
|
ExecutionMode 4 Invocations 1
|
|
ExecutionMode 4 OutputTriangleStrip
|
|
ExecutionMode 4 OutputVertices 4
|
|
Name 4 "main"
|
|
Name 9 "PS_IN"
|
|
MemberName 9(PS_IN) 0 "position"
|
|
MemberName 9(PS_IN) 1 "color"
|
|
MemberName 9(PS_IN) 2 "uv"
|
|
Name 11 "vout"
|
|
Name 14 "VertexData"
|
|
MemberName 14(VertexData) 0 "position"
|
|
MemberName 14(VertexData) 1 "color"
|
|
MemberName 14(VertexData) 2 "uv"
|
|
Name 19 "vin"
|
|
Name 36 "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 41(outStream) Location 0
|
|
2: TypeVoid
|
|
3: TypeFunction 2
|
|
6: TypeFloat 32
|
|
7: TypeVector 6(float) 4
|
|
8: TypeVector 6(float) 2
|
|
9(PS_IN): TypeStruct 7(fvec4) 7(fvec4) 8(fvec2)
|
|
10: TypePointer Function 9(PS_IN)
|
|
12: TypeInt 32 1
|
|
13: 12(int) Constant 1
|
|
14(VertexData): TypeStruct 7(fvec4) 7(fvec4) 8(fvec2)
|
|
15: TypeInt 32 0
|
|
16: 15(int) Constant 2
|
|
17: TypeArray 14(VertexData) 16
|
|
18: TypePointer Input 17
|
|
19(vin): 18(ptr) Variable Input
|
|
20: TypePointer Input 7(fvec4)
|
|
23: TypePointer Function 7(fvec4)
|
|
25: 12(int) Constant 2
|
|
26: TypePointer Input 8(fvec2)
|
|
29: TypePointer Function 8(fvec2)
|
|
31: 12(int) Constant 0
|
|
35: TypePointer Output 7(fvec4)
|
|
36(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
|
|
47: TypePointer Output 8(fvec2)
|
|
4(main): 2 Function None 3
|
|
5: Label
|
|
11(vout): 10(ptr) Variable Function
|
|
21: 20(ptr) AccessChain 19(vin) 13 13
|
|
22: 7(fvec4) Load 21
|
|
24: 23(ptr) AccessChain 11(vout) 13
|
|
Store 24 22
|
|
27: 26(ptr) AccessChain 19(vin) 13 25
|
|
28: 8(fvec2) Load 27
|
|
30: 29(ptr) AccessChain 11(vout) 25
|
|
Store 30 28
|
|
32: 20(ptr) AccessChain 19(vin) 13 31
|
|
33: 7(fvec4) Load 32
|
|
34: 23(ptr) AccessChain 11(vout) 31
|
|
Store 34 33
|
|
37: 23(ptr) AccessChain 11(vout) 31
|
|
38: 7(fvec4) Load 37
|
|
Store 36(position) 38
|
|
42: 23(ptr) AccessChain 11(vout) 13
|
|
43: 7(fvec4) Load 42
|
|
44: 35(ptr) AccessChain 41(outStream) 31
|
|
Store 44 43
|
|
45: 29(ptr) AccessChain 11(vout) 25
|
|
46: 8(fvec2) Load 45
|
|
48: 47(ptr) AccessChain 41(outStream) 13
|
|
Store 48 46
|
|
EmitVertex
|
|
Return
|
|
FunctionEnd
|