HLSL: Wrap the entry-point; need to write 'in' args, and support 'inout' args.

This needs some render testing, but is destined to be part of master.

This also leads to a variety of other simplifications.
 - IO are global symbols, so only need one list of linkage nodes (deferred)
 - no longer need parse-context-wide 'inEntryPoint' state, entry-point is localized
 - several parts of splitting/flattening are now localized
This commit is contained in:
John Kessenich
2017-01-19 15:41:47 -07:00
parent 18adbdbbb8
commit 02467d8d94
171 changed files with 37604 additions and 32679 deletions

View File

@@ -20,9 +20,9 @@ gl_FragCoord origin is upper left
0:9 0.000000
0:9 0.000000
0:9 0.000000
0:18 Function Definition: PixelShaderFunction(vf4; (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Definition: @PixelShaderFunction(vf4; (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Parameters:
0:18 'input' (layout(location=0 ) in 4-component vector of float)
0:18 'input' (in 4-component vector of float)
0:? Sequence
0:19 Sequence
0:19 move second child to first child (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
@@ -143,41 +143,51 @@ gl_FragCoord origin is upper left
0:30 1 (const int)
0:30 Convert int to float (temp float)
0:30 'cgi' (temp int)
0:32 Sequence
0:32 Sequence
0:32 move second child to first child (temp int)
0:? 'a' (layout(location=0 ) out int)
0:32 a: direct index for structure (temp int)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 0 (const int)
0:32 move second child to first child (temp float)
0:? 'b' (layout(location=1 ) out float)
0:32 b: direct index for structure (temp float)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 1 (const int)
0:32 move second child to first child (temp bool)
0:? 'c' (layout(location=2 ) out bool)
0:32 c: direct index for structure (temp bool)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 2 (const int)
0:32 move second child to first child (temp 4-component vector of float)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
0:32 v: direct index for structure (temp 4-component vector of float)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 3 (const int)
0:32 Branch: Return
0:32 Branch: Return with expression
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Definition: PixelShaderFunction( (temp void)
0:18 Function Parameters:
0:? Sequence
0:18 move second child to first child (temp 4-component vector of float)
0:? 'input' (temp 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:18 Sequence
0:18 move second child to first child (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Call: @PixelShaderFunction(vf4; (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:? 'input' (temp 4-component vector of float)
0:18 move second child to first child (temp int)
0:? 'a' (layout(location=0 ) out int)
0:18 a: direct index for structure (temp int)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 0 (const int)
0:18 move second child to first child (temp float)
0:? 'b' (layout(location=1 ) out float)
0:18 b: direct index for structure (temp float)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 1 (const int)
0:18 move second child to first child (temp bool)
0:? 'c' (layout(location=2 ) out bool)
0:18 c: direct index for structure (temp bool)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 2 (const int)
0:18 move second child to first child (temp 4-component vector of float)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
0:18 v: direct index for structure (temp 4-component vector of float)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 3 (const int)
0:? Linker Objects
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
0:? 'a' (layout(location=0 ) out int)
0:? 'b' (layout(location=1 ) out float)
0:? 'c' (layout(location=2 ) out bool)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
0:? 'cgf2a' (const 3-element array of 2-component vector of float)
0:? 0.000000
0:? 0.000000
@@ -210,9 +220,9 @@ gl_FragCoord origin is upper left
0:9 0.000000
0:9 0.000000
0:9 0.000000
0:18 Function Definition: PixelShaderFunction(vf4; (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Definition: @PixelShaderFunction(vf4; (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Parameters:
0:18 'input' (layout(location=0 ) in 4-component vector of float)
0:18 'input' (in 4-component vector of float)
0:? Sequence
0:19 Sequence
0:19 move second child to first child (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
@@ -333,41 +343,51 @@ gl_FragCoord origin is upper left
0:30 1 (const int)
0:30 Convert int to float (temp float)
0:30 'cgi' (temp int)
0:32 Sequence
0:32 Sequence
0:32 move second child to first child (temp int)
0:? 'a' (layout(location=0 ) out int)
0:32 a: direct index for structure (temp int)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 0 (const int)
0:32 move second child to first child (temp float)
0:? 'b' (layout(location=1 ) out float)
0:32 b: direct index for structure (temp float)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 1 (const int)
0:32 move second child to first child (temp bool)
0:? 'c' (layout(location=2 ) out bool)
0:32 c: direct index for structure (temp bool)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 2 (const int)
0:32 move second child to first child (temp 4-component vector of float)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
0:32 v: direct index for structure (temp 4-component vector of float)
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:32 Constant:
0:32 3 (const int)
0:32 Branch: Return
0:32 Branch: Return with expression
0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Definition: PixelShaderFunction( (temp void)
0:18 Function Parameters:
0:? Sequence
0:18 move second child to first child (temp 4-component vector of float)
0:? 'input' (temp 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:18 Sequence
0:18 move second child to first child (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Function Call: @PixelShaderFunction(vf4; (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:? 'input' (temp 4-component vector of float)
0:18 move second child to first child (temp int)
0:? 'a' (layout(location=0 ) out int)
0:18 a: direct index for structure (temp int)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 0 (const int)
0:18 move second child to first child (temp float)
0:? 'b' (layout(location=1 ) out float)
0:18 b: direct index for structure (temp float)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 1 (const int)
0:18 move second child to first child (temp bool)
0:? 'c' (layout(location=2 ) out bool)
0:18 c: direct index for structure (temp bool)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 2 (const int)
0:18 move second child to first child (temp 4-component vector of float)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
0:18 v: direct index for structure (temp 4-component vector of float)
0:18 'flattenTemp' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
0:18 Constant:
0:18 3 (const int)
0:? Linker Objects
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
0:? 'a' (layout(location=0 ) out int)
0:? 'b' (layout(location=1 ) out float)
0:? 'c' (layout(location=2 ) out bool)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
0:? 'cgf2a' (const 3-element array of 2-component vector of float)
0:? 0.000000
0:? 0.000000
@@ -380,146 +400,167 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 92
// Id's are bound by 104
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 72 76 80 84 89
EntryPoint Fragment 4 "PixelShaderFunction" 80 87 91 95 99
ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction"
Name 9 "gv"
Name 17 "gfa"
Name 21 "outs"
MemberName 21(outs) 0 "a"
MemberName 21(outs) 1 "b"
MemberName 21(outs) 2 "c"
MemberName 21(outs) 3 "v"
Name 23 "o2"
Name 28 "o4"
Name 37 "o1"
Name 40 "o3"
Name 47 "Nest"
MemberName 47(Nest) 0 "m"
MemberName 47(Nest) 1 "os"
MemberName 47(Nest) 2 "b"
Name 49 "nest"
Name 57 "gf2a"
Name 61 "cgi"
Name 72 "a"
Name 76 "b"
Name 80 "c"
Name 84 "v"
Name 89 "input"
Decorate 72(a) Location 0
Decorate 76(b) Location 1
Decorate 80(c) Location 2
Decorate 84(v) Location 3
Decorate 89(input) Location 0
Name 11 "outs"
MemberName 11(outs) 0 "a"
MemberName 11(outs) 1 "b"
MemberName 11(outs) 2 "c"
MemberName 11(outs) 3 "v"
Name 14 "@PixelShaderFunction(vf4;"
Name 13 "input"
Name 17 "gv"
Name 25 "gfa"
Name 28 "o2"
Name 33 "o4"
Name 41 "o1"
Name 44 "o3"
Name 51 "Nest"
MemberName 51(Nest) 0 "m"
MemberName 51(Nest) 1 "os"
MemberName 51(Nest) 2 "b"
Name 53 "nest"
Name 61 "gf2a"
Name 65 "cgi"
Name 78 "input"
Name 80 "input"
Name 82 "flattenTemp"
Name 83 "param"
Name 87 "a"
Name 91 "b"
Name 95 "c"
Name 99 "v"
Decorate 80(input) Location 0
Decorate 87(a) Location 0
Decorate 91(b) Location 1
Decorate 95(c) Location 2
Decorate 99(v) Location 3
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Private 7(fvec4)
9(gv): 8(ptr) Variable Private
10: 6(float) Constant 0
11: 6(float) Constant 1065353216
12: 7(fvec4) ConstantComposite 10 10 11 10
13: TypeInt 32 0
14: 13(int) Constant 3
15: TypeArray 6(float) 14
16: TypePointer Private 15
17(gfa): 16(ptr) Variable Private
18: 15 ConstantComposite 10 10 10
19: TypeInt 32 1
20: TypeBool
21(outs): TypeStruct 19(int) 6(float) 20(bool) 7(fvec4)
22: TypePointer Function 21(outs)
24: 19(int) Constant 3
25: 20(bool) ConstantFalse
26: 7(fvec4) ConstantComposite 10 10 10 10
27: 21(outs) ConstantComposite 24 10 25 26
30: 19(int) Constant 2
31: TypePointer Private 6(float)
35: TypePointer Function 7(fvec4)
38: 19(int) Constant 0
39: 21(outs) ConstantComposite 38 10 25 26
41: TypePointer Function 20(bool)
45: TypeVector 6(float) 3
46: TypeMatrix 45(fvec3) 4
47(Nest): TypeStruct 46 21(outs) 20(bool)
48: TypePointer Function 47(Nest)
50: 45(fvec3) ConstantComposite 10 10 10
51: 46 ConstantComposite 50 50 50 50
52: 47(Nest) ConstantComposite 51 39 25
53: TypeVector 6(float) 2
54: 13(int) Constant 4
55: TypeArray 53(fvec2) 54
56: TypePointer Function 55
58: 53(fvec2) ConstantComposite 10 10
59: 55 ConstantComposite 58 58 58 58
60: TypePointer Function 19(int)
62: 19(int) Constant 1
63: 13(int) Constant 1
64: TypePointer Function 6(float)
71: TypePointer Output 19(int)
72(a): 71(ptr) Variable Output
75: TypePointer Output 6(float)
76(b): 75(ptr) Variable Output
79: TypePointer Output 20(bool)
80(c): 79(ptr) Variable Output
83: TypePointer Output 7(fvec4)
84(v): 83(ptr) Variable Output
88: TypePointer Input 7(fvec4)
89(input): 88(ptr) Variable Input
90: TypeArray 53(fvec2) 14
91: 90 ConstantComposite 58 58 58
8: TypePointer Function 7(fvec4)
9: TypeInt 32 1
10: TypeBool
11(outs): TypeStruct 9(int) 6(float) 10(bool) 7(fvec4)
12: TypeFunction 11(outs) 8(ptr)
16: TypePointer Private 7(fvec4)
17(gv): 16(ptr) Variable Private
18: 6(float) Constant 0
19: 6(float) Constant 1065353216
20: 7(fvec4) ConstantComposite 18 18 19 18
21: TypeInt 32 0
22: 21(int) Constant 3
23: TypeArray 6(float) 22
24: TypePointer Private 23
25(gfa): 24(ptr) Variable Private
26: 23 ConstantComposite 18 18 18
27: TypePointer Function 11(outs)
29: 9(int) Constant 3
30: 10(bool) ConstantFalse
31: 7(fvec4) ConstantComposite 18 18 18 18
32: 11(outs) ConstantComposite 29 18 30 31
35: 9(int) Constant 2
36: TypePointer Private 6(float)
42: 9(int) Constant 0
43: 11(outs) ConstantComposite 42 18 30 31
45: TypePointer Function 10(bool)
49: TypeVector 6(float) 3
50: TypeMatrix 49(fvec3) 4
51(Nest): TypeStruct 50 11(outs) 10(bool)
52: TypePointer Function 51(Nest)
54: 49(fvec3) ConstantComposite 18 18 18
55: 50 ConstantComposite 54 54 54 54
56: 51(Nest) ConstantComposite 55 43 30
57: TypeVector 6(float) 2
58: 21(int) Constant 4
59: TypeArray 57(fvec2) 58
60: TypePointer Function 59
62: 57(fvec2) ConstantComposite 18 18
63: 59 ConstantComposite 62 62 62 62
64: TypePointer Function 9(int)
66: 9(int) Constant 1
67: 21(int) Constant 1
68: TypePointer Function 6(float)
79: TypePointer Input 7(fvec4)
80(input): 79(ptr) Variable Input
86: TypePointer Output 9(int)
87(a): 86(ptr) Variable Output
90: TypePointer Output 6(float)
91(b): 90(ptr) Variable Output
94: TypePointer Output 10(bool)
95(c): 94(ptr) Variable Output
98: TypePointer Output 7(fvec4)
99(v): 98(ptr) Variable Output
102: TypeArray 57(fvec2) 22
103: 102 ConstantComposite 62 62 62
4(PixelShaderFunction): 2 Function None 3
5: Label
23(o2): 22(ptr) Variable Function
28(o4): 22(ptr) Variable Function
37(o1): 22(ptr) Variable Function
40(o3): 22(ptr) Variable Function
49(nest): 48(ptr) Variable Function
57(gf2a): 56(ptr) Variable Function
61(cgi): 60(ptr) Variable Function
Store 9(gv) 12
Store 17(gfa) 18
Store 23(o2) 27
29: 7(fvec4) Load 9(gv)
32: 31(ptr) AccessChain 17(gfa) 30
33: 6(float) Load 32
34: 7(fvec4) VectorTimesScalar 29 33
36: 35(ptr) AccessChain 28(o4) 24
Store 36 34
Store 37(o1) 39
Store 40(o3) 39
Store 28(o4) 39
42: 41(ptr) AccessChain 37(o1) 30
43: 20(bool) Load 42
44: 41(ptr) AccessChain 28(o4) 30
Store 44 43
Store 49(nest) 52
Store 57(gf2a) 59
Store 61(cgi) 38
65: 64(ptr) AccessChain 57(gf2a) 30 63
66: 6(float) Load 65
67: 19(int) Load 61(cgi)
68: 6(float) ConvertSToF 67
69: 6(float) FMul 66 68
70: 64(ptr) AccessChain 28(o4) 62
Store 70 69
73: 60(ptr) AccessChain 28(o4) 38
74: 19(int) Load 73
Store 72(a) 74
77: 64(ptr) AccessChain 28(o4) 62
78: 6(float) Load 77
Store 76(b) 78
81: 41(ptr) AccessChain 28(o4) 30
82: 20(bool) Load 81
Store 80(c) 82
85: 35(ptr) AccessChain 28(o4) 24
86: 7(fvec4) Load 85
Store 84(v) 86
78(input): 8(ptr) Variable Function
82(flattenTemp): 27(ptr) Variable Function
83(param): 8(ptr) Variable Function
Store 17(gv) 20
Store 25(gfa) 26
81: 7(fvec4) Load 80(input)
Store 78(input) 81
84: 7(fvec4) Load 78(input)
Store 83(param) 84
85: 11(outs) FunctionCall 14(@PixelShaderFunction(vf4;) 83(param)
Store 82(flattenTemp) 85
88: 64(ptr) AccessChain 82(flattenTemp) 42
89: 9(int) Load 88
Store 87(a) 89
92: 68(ptr) AccessChain 82(flattenTemp) 66
93: 6(float) Load 92
Store 91(b) 93
96: 45(ptr) AccessChain 82(flattenTemp) 35
97: 10(bool) Load 96
Store 95(c) 97
100: 8(ptr) AccessChain 82(flattenTemp) 29
101: 7(fvec4) Load 100
Store 99(v) 101
Return
FunctionEnd
14(@PixelShaderFunction(vf4;): 11(outs) Function None 12
13(input): 8(ptr) FunctionParameter
15: Label
28(o2): 27(ptr) Variable Function
33(o4): 27(ptr) Variable Function
41(o1): 27(ptr) Variable Function
44(o3): 27(ptr) Variable Function
53(nest): 52(ptr) Variable Function
61(gf2a): 60(ptr) Variable Function
65(cgi): 64(ptr) Variable Function
Store 28(o2) 32
34: 7(fvec4) Load 17(gv)
37: 36(ptr) AccessChain 25(gfa) 35
38: 6(float) Load 37
39: 7(fvec4) VectorTimesScalar 34 38
40: 8(ptr) AccessChain 33(o4) 29
Store 40 39
Store 41(o1) 43
Store 44(o3) 43
Store 33(o4) 43
46: 45(ptr) AccessChain 41(o1) 35
47: 10(bool) Load 46
48: 45(ptr) AccessChain 33(o4) 35
Store 48 47
Store 53(nest) 56
Store 61(gf2a) 63
Store 65(cgi) 42
69: 68(ptr) AccessChain 61(gf2a) 35 67
70: 6(float) Load 69
71: 9(int) Load 65(cgi)
72: 6(float) ConvertSToF 71
73: 6(float) FMul 70 72
74: 68(ptr) AccessChain 33(o4) 66
Store 74 73
75: 11(outs) Load 33(o4)
ReturnValue 75
FunctionEnd