mirror of
https://github.com/RPCS3/glslang.git
synced 2024-12-03 16:41:30 +00:00
a2e7531057
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.
193 lines
9.0 KiB
Plaintext
193 lines
9.0 KiB
Plaintext
hlsl.basic.geom
|
|
Shader version: 450
|
|
invocations = -1
|
|
max_vertices = 4
|
|
input primitive = triangles
|
|
output primitive = line_strip
|
|
0:? Sequence
|
|
0:16 Function Definition: main(u1[3];u1[3];struct-PSInput-f1-i11; (temp void)
|
|
0:16 Function Parameters:
|
|
0:16 'VertexID' (layout(location=0 ) in 3-element array of uint)
|
|
0:16 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:16 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
0:? Sequence
|
|
0:19 move second child to first child (temp float)
|
|
0:19 myfloat: direct index for structure (temp float)
|
|
0:19 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:19 Constant:
|
|
0:19 0 (const int)
|
|
0:19 Convert uint to float (temp float)
|
|
0:19 add (temp uint)
|
|
0:19 add (temp uint)
|
|
0:19 direct index (layout(location=3 ) temp uint)
|
|
0:19 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:19 Constant:
|
|
0:19 0 (const int)
|
|
0:19 direct index (layout(location=3 ) temp uint)
|
|
0:19 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:19 Constant:
|
|
0:19 1 (const int)
|
|
0:19 direct index (layout(location=3 ) temp uint)
|
|
0:19 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:19 Constant:
|
|
0:19 2 (const int)
|
|
0:20 move second child to first child (temp int)
|
|
0:20 something: direct index for structure (temp int)
|
|
0:20 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:20 Constant:
|
|
0:20 1 (const int)
|
|
0:20 Convert uint to int (temp int)
|
|
0:20 direct index (layout(location=0 ) temp uint)
|
|
0:20 'VertexID' (layout(location=0 ) in 3-element array of uint)
|
|
0:20 Constant:
|
|
0:20 0 (const int)
|
|
0:22 Sequence
|
|
0:22 move second child to first child (temp structure{temp float myfloat, temp int something})
|
|
0:22 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
0:22 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:22 EmitVertex (temp void)
|
|
0:23 Sequence
|
|
0:23 move second child to first child (temp structure{temp float myfloat, temp int something})
|
|
0:23 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
0:23 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:23 EmitVertex (temp void)
|
|
0:24 EndPrimitive (temp void)
|
|
0:? Linker Objects
|
|
0:? 'VertexID' (layout(location=0 ) in 3-element array of uint)
|
|
0:? 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:? 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
|
|
|
|
Linked geometry stage:
|
|
|
|
|
|
Shader version: 450
|
|
invocations = 1
|
|
max_vertices = 4
|
|
input primitive = triangles
|
|
output primitive = line_strip
|
|
0:? Sequence
|
|
0:16 Function Definition: main(u1[3];u1[3];struct-PSInput-f1-i11; (temp void)
|
|
0:16 Function Parameters:
|
|
0:16 'VertexID' (layout(location=0 ) in 3-element array of uint)
|
|
0:16 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:16 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
0:? Sequence
|
|
0:19 move second child to first child (temp float)
|
|
0:19 myfloat: direct index for structure (temp float)
|
|
0:19 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:19 Constant:
|
|
0:19 0 (const int)
|
|
0:19 Convert uint to float (temp float)
|
|
0:19 add (temp uint)
|
|
0:19 add (temp uint)
|
|
0:19 direct index (layout(location=3 ) temp uint)
|
|
0:19 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:19 Constant:
|
|
0:19 0 (const int)
|
|
0:19 direct index (layout(location=3 ) temp uint)
|
|
0:19 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:19 Constant:
|
|
0:19 1 (const int)
|
|
0:19 direct index (layout(location=3 ) temp uint)
|
|
0:19 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:19 Constant:
|
|
0:19 2 (const int)
|
|
0:20 move second child to first child (temp int)
|
|
0:20 something: direct index for structure (temp int)
|
|
0:20 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:20 Constant:
|
|
0:20 1 (const int)
|
|
0:20 Convert uint to int (temp int)
|
|
0:20 direct index (layout(location=0 ) temp uint)
|
|
0:20 'VertexID' (layout(location=0 ) in 3-element array of uint)
|
|
0:20 Constant:
|
|
0:20 0 (const int)
|
|
0:22 Sequence
|
|
0:22 move second child to first child (temp structure{temp float myfloat, temp int something})
|
|
0:22 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
0:22 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:22 EmitVertex (temp void)
|
|
0:23 Sequence
|
|
0:23 move second child to first child (temp structure{temp float myfloat, temp int something})
|
|
0:23 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
0:23 'Vert' (temp structure{temp float myfloat, temp int something})
|
|
0:23 EmitVertex (temp void)
|
|
0:24 EndPrimitive (temp void)
|
|
0:? Linker Objects
|
|
0:? 'VertexID' (layout(location=0 ) in 3-element array of uint)
|
|
0:? 'test' (layout(location=3 ) in 3-element array of uint)
|
|
0:? 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
|
|
|
|
// Module Version 10000
|
|
// Generated by (magic number): 80001
|
|
// Id's are bound by 41
|
|
|
|
Capability Geometry
|
|
1: ExtInstImport "GLSL.std.450"
|
|
MemoryModel Logical GLSL450
|
|
EntryPoint Geometry 4 "main" 16 31 38
|
|
ExecutionMode 4 Triangles
|
|
ExecutionMode 4 Invocations 1
|
|
ExecutionMode 4 OutputLineStrip
|
|
ExecutionMode 4 OutputVertices 4
|
|
Name 4 "main"
|
|
Name 8 "PSInput"
|
|
MemberName 8(PSInput) 0 "myfloat"
|
|
MemberName 8(PSInput) 1 "something"
|
|
Name 10 "Vert"
|
|
Name 16 "test"
|
|
Name 31 "VertexID"
|
|
Name 38 "OutputStream"
|
|
Decorate 16(test) Location 3
|
|
Decorate 31(VertexID) Location 0
|
|
Decorate 38(OutputStream) Location 0
|
|
2: TypeVoid
|
|
3: TypeFunction 2
|
|
6: TypeFloat 32
|
|
7: TypeInt 32 1
|
|
8(PSInput): TypeStruct 6(float) 7(int)
|
|
9: TypePointer Function 8(PSInput)
|
|
11: 7(int) Constant 0
|
|
12: TypeInt 32 0
|
|
13: 12(int) Constant 3
|
|
14: TypeArray 12(int) 13
|
|
15: TypePointer Input 14
|
|
16(test): 15(ptr) Variable Input
|
|
17: TypePointer Input 12(int)
|
|
20: 7(int) Constant 1
|
|
24: 7(int) Constant 2
|
|
29: TypePointer Function 6(float)
|
|
31(VertexID): 15(ptr) Variable Input
|
|
35: TypePointer Function 7(int)
|
|
37: TypePointer Output 8(PSInput)
|
|
38(OutputStream): 37(ptr) Variable Output
|
|
4(main): 2 Function None 3
|
|
5: Label
|
|
10(Vert): 9(ptr) Variable Function
|
|
18: 17(ptr) AccessChain 16(test) 11
|
|
19: 12(int) Load 18
|
|
21: 17(ptr) AccessChain 16(test) 20
|
|
22: 12(int) Load 21
|
|
23: 12(int) IAdd 19 22
|
|
25: 17(ptr) AccessChain 16(test) 24
|
|
26: 12(int) Load 25
|
|
27: 12(int) IAdd 23 26
|
|
28: 6(float) ConvertUToF 27
|
|
30: 29(ptr) AccessChain 10(Vert) 11
|
|
Store 30 28
|
|
32: 17(ptr) AccessChain 31(VertexID) 11
|
|
33: 12(int) Load 32
|
|
34: 7(int) Bitcast 33
|
|
36: 35(ptr) AccessChain 10(Vert) 20
|
|
Store 36 34
|
|
39: 8(PSInput) Load 10(Vert)
|
|
Store 38(OutputStream) 39
|
|
EmitVertex
|
|
40: 8(PSInput) Load 10(Vert)
|
|
Store 38(OutputStream) 40
|
|
EmitVertex
|
|
EndPrimitive
|
|
Return
|
|
FunctionEnd
|