HLSL: Type sanitization: create non-IO types for var decl and fn param/ret
This introduces parallel types for IO-type containing aggregates used as non-entry point function parameters or return types, or declared as variables. Further uses of the same original type will share the same sanitized deep structure. This is intended to be used with the wrap-entry-point branch.
This commit is contained in:
parent
0fe106afd2
commit
5d3023af03
@ -4,20 +4,20 @@ gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:8 Function Definition: fun(struct-InParam-vf2-vf4-vi21; (temp float)
|
||||
0:8 Function Parameters:
|
||||
0:8 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
|
||||
0:8 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
|
||||
0:? Sequence
|
||||
0:9 Branch: Return with expression
|
||||
0:9 add (temp float)
|
||||
0:9 direct index (temp float)
|
||||
0:9 v: direct index for structure (temp 2-component vector of float)
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
|
||||
0:9 Constant:
|
||||
0:9 0 (const int)
|
||||
0:9 Constant:
|
||||
0:9 1 (const int)
|
||||
0:9 direct index (temp float)
|
||||
0:9 fragCoord: direct index for structure (temp 4-component vector of float FragCoord)
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
|
||||
0:9 fragCoord: direct index for structure (temp 4-component vector of float)
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
|
||||
0:9 Constant:
|
||||
0:9 1 (const int)
|
||||
0:9 Constant:
|
||||
@ -94,20 +94,20 @@ gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:8 Function Definition: fun(struct-InParam-vf2-vf4-vi21; (temp float)
|
||||
0:8 Function Parameters:
|
||||
0:8 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
|
||||
0:8 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
|
||||
0:? Sequence
|
||||
0:9 Branch: Return with expression
|
||||
0:9 add (temp float)
|
||||
0:9 direct index (temp float)
|
||||
0:9 v: direct index for structure (temp 2-component vector of float)
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
|
||||
0:9 Constant:
|
||||
0:9 0 (const int)
|
||||
0:9 Constant:
|
||||
0:9 1 (const int)
|
||||
0:9 direct index (temp float)
|
||||
0:9 fragCoord: direct index for structure (temp 4-component vector of float FragCoord)
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
|
||||
0:9 fragCoord: direct index for structure (temp 4-component vector of float)
|
||||
0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
|
||||
0:9 Constant:
|
||||
0:9 1 (const int)
|
||||
0:9 Constant:
|
||||
@ -191,12 +191,12 @@ gl_FragCoord origin is upper left
|
||||
MemberName 11(InParam) 2 "i2"
|
||||
Name 15 "fun(struct-InParam-vf2-vf4-vi21;"
|
||||
Name 14 "p"
|
||||
Name 19 "@PixelShaderFunction(struct-InParam-vf2-vf4-vi21;"
|
||||
Name 18 "i"
|
||||
Name 34 "InParam"
|
||||
MemberName 34(InParam) 0 "v"
|
||||
MemberName 34(InParam) 1 "fragCoord"
|
||||
MemberName 34(InParam) 2 "i2"
|
||||
Name 17 "InParam"
|
||||
MemberName 17(InParam) 0 "v"
|
||||
MemberName 17(InParam) 1 "fragCoord"
|
||||
MemberName 17(InParam) 2 "i2"
|
||||
Name 21 "@PixelShaderFunction(struct-InParam-vf2-vf4-vi21;"
|
||||
Name 20 "i"
|
||||
Name 36 "local"
|
||||
Name 48 "ret1"
|
||||
Name 49 "param"
|
||||
@ -210,7 +210,7 @@ gl_FragCoord origin is upper left
|
||||
Name 73 "i_fragCoord"
|
||||
Name 81 "@entryPointOutput"
|
||||
Name 82 "param"
|
||||
MemberDecorate 11(InParam) 1 BuiltIn FragCoord
|
||||
MemberDecorate 17(InParam) 1 BuiltIn FragCoord
|
||||
Decorate 67(i) Location 0
|
||||
Decorate 73(i_fragCoord) BuiltIn FragCoord
|
||||
Decorate 81(@entryPointOutput) Location 0
|
||||
@ -224,15 +224,15 @@ gl_FragCoord origin is upper left
|
||||
11(InParam): TypeStruct 7(fvec2) 8(fvec4) 10(ivec2)
|
||||
12: TypePointer Function 11(InParam)
|
||||
13: TypeFunction 6(float) 12(ptr)
|
||||
17: TypeFunction 8(fvec4) 12(ptr)
|
||||
21: 9(int) Constant 0
|
||||
22: TypeInt 32 0
|
||||
23: 22(int) Constant 1
|
||||
24: TypePointer Function 6(float)
|
||||
27: 9(int) Constant 1
|
||||
28: 22(int) Constant 0
|
||||
34(InParam): TypeStruct 7(fvec2) 8(fvec4) 10(ivec2)
|
||||
35: TypePointer Function 34(InParam)
|
||||
17(InParam): TypeStruct 7(fvec2) 8(fvec4) 10(ivec2)
|
||||
18: TypePointer Function 17(InParam)
|
||||
19: TypeFunction 8(fvec4) 18(ptr)
|
||||
23: 9(int) Constant 0
|
||||
24: TypeInt 32 0
|
||||
25: 24(int) Constant 1
|
||||
26: TypePointer Function 6(float)
|
||||
29: 9(int) Constant 1
|
||||
30: 24(int) Constant 0
|
||||
39: TypePointer Function 7(fvec2)
|
||||
42: TypePointer Function 8(fvec4)
|
||||
45: 9(int) Constant 2
|
||||
@ -248,62 +248,62 @@ gl_FragCoord origin is upper left
|
||||
81(@entryPointOutput): 80(ptr) Variable Output
|
||||
4(PixelShaderFunction): 2 Function None 3
|
||||
5: Label
|
||||
64(i): 12(ptr) Variable Function
|
||||
82(param): 12(ptr) Variable Function
|
||||
69: 68(ptr) AccessChain 67(i) 21
|
||||
64(i): 18(ptr) Variable Function
|
||||
82(param): 18(ptr) Variable Function
|
||||
69: 68(ptr) AccessChain 67(i) 23
|
||||
70: 7(fvec2) Load 69
|
||||
71: 39(ptr) AccessChain 64(i) 21
|
||||
71: 39(ptr) AccessChain 64(i) 23
|
||||
Store 71 70
|
||||
74: 8(fvec4) Load 73(i_fragCoord)
|
||||
75: 42(ptr) AccessChain 64(i) 27
|
||||
75: 42(ptr) AccessChain 64(i) 29
|
||||
Store 75 74
|
||||
77: 76(ptr) AccessChain 67(i) 27
|
||||
77: 76(ptr) AccessChain 67(i) 29
|
||||
78: 10(ivec2) Load 77
|
||||
79: 46(ptr) AccessChain 64(i) 45
|
||||
Store 79 78
|
||||
83: 11(InParam) Load 64(i)
|
||||
83: 17(InParam) Load 64(i)
|
||||
Store 82(param) 83
|
||||
84: 8(fvec4) FunctionCall 19(@PixelShaderFunction(struct-InParam-vf2-vf4-vi21;) 82(param)
|
||||
84: 8(fvec4) FunctionCall 21(@PixelShaderFunction(struct-InParam-vf2-vf4-vi21;) 82(param)
|
||||
Store 81(@entryPointOutput) 84
|
||||
Return
|
||||
FunctionEnd
|
||||
15(fun(struct-InParam-vf2-vf4-vi21;): 6(float) Function None 13
|
||||
14(p): 12(ptr) FunctionParameter
|
||||
16: Label
|
||||
25: 24(ptr) AccessChain 14(p) 21 23
|
||||
26: 6(float) Load 25
|
||||
29: 24(ptr) AccessChain 14(p) 27 28
|
||||
30: 6(float) Load 29
|
||||
31: 6(float) FAdd 26 30
|
||||
ReturnValue 31
|
||||
27: 26(ptr) AccessChain 14(p) 23 25
|
||||
28: 6(float) Load 27
|
||||
31: 26(ptr) AccessChain 14(p) 29 30
|
||||
32: 6(float) Load 31
|
||||
33: 6(float) FAdd 28 32
|
||||
ReturnValue 33
|
||||
FunctionEnd
|
||||
19(@PixelShaderFunction(struct-InParam-vf2-vf4-vi21;): 8(fvec4) Function None 17
|
||||
18(i): 12(ptr) FunctionParameter
|
||||
20: Label
|
||||
36(local): 35(ptr) Variable Function
|
||||
48(ret1): 24(ptr) Variable Function
|
||||
49(param): 35(ptr) Variable Function
|
||||
52(ret2): 24(ptr) Variable Function
|
||||
53(param): 12(ptr) Variable Function
|
||||
37: 11(InParam) Load 18(i)
|
||||
21(@PixelShaderFunction(struct-InParam-vf2-vf4-vi21;): 8(fvec4) Function None 19
|
||||
20(i): 18(ptr) FunctionParameter
|
||||
22: Label
|
||||
36(local): 12(ptr) Variable Function
|
||||
48(ret1): 26(ptr) Variable Function
|
||||
49(param): 12(ptr) Variable Function
|
||||
52(ret2): 26(ptr) Variable Function
|
||||
53(param): 18(ptr) Variable Function
|
||||
37: 17(InParam) Load 20(i)
|
||||
38: 7(fvec2) CompositeExtract 37 0
|
||||
40: 39(ptr) AccessChain 36(local) 21
|
||||
40: 39(ptr) AccessChain 36(local) 23
|
||||
Store 40 38
|
||||
41: 8(fvec4) CompositeExtract 37 1
|
||||
43: 42(ptr) AccessChain 36(local) 27
|
||||
43: 42(ptr) AccessChain 36(local) 29
|
||||
Store 43 41
|
||||
44: 10(ivec2) CompositeExtract 37 2
|
||||
47: 46(ptr) AccessChain 36(local) 45
|
||||
Store 47 44
|
||||
50: 34(InParam) Load 36(local)
|
||||
50: 11(InParam) Load 36(local)
|
||||
Store 49(param) 50
|
||||
51: 6(float) FunctionCall 15(fun(struct-InParam-vf2-vf4-vi21;) 49(param)
|
||||
Store 48(ret1) 51
|
||||
54: 11(InParam) Load 18(i)
|
||||
54: 17(InParam) Load 20(i)
|
||||
Store 53(param) 54
|
||||
55: 6(float) FunctionCall 15(fun(struct-InParam-vf2-vf4-vi21;) 53(param)
|
||||
Store 52(ret2) 55
|
||||
56: 42(ptr) AccessChain 36(local) 27
|
||||
56: 42(ptr) AccessChain 36(local) 29
|
||||
57: 8(fvec4) Load 56
|
||||
58: 6(float) Load 48(ret1)
|
||||
59: 8(fvec4) VectorTimesScalar 57 58
|
||||
|
||||
@ -4,15 +4,15 @@ Shader version: 450
|
||||
0:17 Function Definition: Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11; (temp void)
|
||||
0:17 Function Parameters:
|
||||
0:17 'fn1_in' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
|
||||
0:17 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
|
||||
0:17 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
|
||||
0:? Sequence
|
||||
0:18 add (temp 4-component vector of float)
|
||||
0:18 Pos_in: direct index for structure (temp 4-component vector of float Position)
|
||||
0:18 Pos_in: direct index for structure (temp 4-component vector of float)
|
||||
0:18 'fn1_in' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
|
||||
0:18 Constant:
|
||||
0:18 1 (const int)
|
||||
0:18 Pos_out: direct index for structure (temp 4-component vector of float Position)
|
||||
0:18 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
|
||||
0:18 Pos_out: direct index for structure (temp 4-component vector of float)
|
||||
0:18 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
|
||||
0:18 Constant:
|
||||
0:18 1 (const int)
|
||||
0:22 Function Definition: @main(struct-VS_INPUT-i1-vf4-i11; (temp structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
|
||||
@ -118,15 +118,15 @@ Shader version: 450
|
||||
0:17 Function Definition: Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11; (temp void)
|
||||
0:17 Function Parameters:
|
||||
0:17 'fn1_in' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
|
||||
0:17 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
|
||||
0:17 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
|
||||
0:? Sequence
|
||||
0:18 add (temp 4-component vector of float)
|
||||
0:18 Pos_in: direct index for structure (temp 4-component vector of float Position)
|
||||
0:18 Pos_in: direct index for structure (temp 4-component vector of float)
|
||||
0:18 'fn1_in' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
|
||||
0:18 Constant:
|
||||
0:18 1 (const int)
|
||||
0:18 Pos_out: direct index for structure (temp 4-component vector of float Position)
|
||||
0:18 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
|
||||
0:18 Pos_out: direct index for structure (temp 4-component vector of float)
|
||||
0:18 'fn1_out' (in structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
|
||||
0:18 Constant:
|
||||
0:18 1 (const int)
|
||||
0:22 Function Definition: @main(struct-VS_INPUT-i1-vf4-i11; (temp structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
|
||||
@ -225,12 +225,12 @@ Shader version: 450
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 93
|
||||
// Id's are bound by 95
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Vertex 4 "main" 62 66 69 78 84 92
|
||||
EntryPoint Vertex 4 "main" 64 68 71 80 86 94
|
||||
Name 4 "main"
|
||||
Name 9 "VS_INPUT"
|
||||
MemberName 9(VS_INPUT) 0 "x0_in"
|
||||
@ -243,37 +243,41 @@ Shader version: 450
|
||||
Name 16 "Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11;"
|
||||
Name 14 "fn1_in"
|
||||
Name 15 "fn1_out"
|
||||
Name 20 "@main(struct-VS_INPUT-i1-vf4-i11;"
|
||||
Name 19 "vsin"
|
||||
Name 29 "VS_OUTPUT"
|
||||
MemberName 29(VS_OUTPUT) 0 "x0_out"
|
||||
MemberName 29(VS_OUTPUT) 1 "Pos_out"
|
||||
MemberName 29(VS_OUTPUT) 2 "x1_out"
|
||||
Name 31 "vsout"
|
||||
Name 44 "param"
|
||||
Name 46 "param"
|
||||
Name 60 "vsin"
|
||||
Name 62 "x0_in"
|
||||
Name 66 "Pos_in"
|
||||
Name 69 "x1_in"
|
||||
Name 72 "flattenTemp"
|
||||
Name 73 "param"
|
||||
Name 76 "VS_OUTPUT"
|
||||
MemberName 76(VS_OUTPUT) 0 "x0_out"
|
||||
MemberName 76(VS_OUTPUT) 1 "x1_out"
|
||||
Name 78 "@entryPointOutput"
|
||||
Name 84 "@entryPointOutput_Pos_out"
|
||||
Name 90 "PerVertex_out"
|
||||
MemberName 90(PerVertex_out) 0 "@entryPointOutput_Pos_out"
|
||||
Name 18 "VS_INPUT"
|
||||
MemberName 18(VS_INPUT) 0 "x0_in"
|
||||
MemberName 18(VS_INPUT) 1 "Pos_in"
|
||||
MemberName 18(VS_INPUT) 2 "x1_in"
|
||||
Name 20 "VS_OUTPUT"
|
||||
MemberName 20(VS_OUTPUT) 0 "x0_out"
|
||||
MemberName 20(VS_OUTPUT) 1 "Pos_out"
|
||||
MemberName 20(VS_OUTPUT) 2 "x1_out"
|
||||
Name 23 "@main(struct-VS_INPUT-i1-vf4-i11;"
|
||||
Name 22 "vsin"
|
||||
Name 32 "vsout"
|
||||
Name 45 "param"
|
||||
Name 47 "param"
|
||||
Name 62 "vsin"
|
||||
Name 64 "x0_in"
|
||||
Name 68 "Pos_in"
|
||||
Name 71 "x1_in"
|
||||
Name 74 "flattenTemp"
|
||||
Name 75 "param"
|
||||
Name 78 "VS_OUTPUT"
|
||||
MemberName 78(VS_OUTPUT) 0 "x0_out"
|
||||
MemberName 78(VS_OUTPUT) 1 "x1_out"
|
||||
Name 80 "@entryPointOutput"
|
||||
Name 86 "@entryPointOutput_Pos_out"
|
||||
Name 92 "PerVertex_out"
|
||||
MemberDecorate 11(VS_OUTPUT) 1 BuiltIn Position
|
||||
Decorate 62(x0_in) Location 0
|
||||
Decorate 66(Pos_in) BuiltIn Position
|
||||
Decorate 69(x1_in) Location 1
|
||||
Decorate 78(@entryPointOutput) Location 0
|
||||
Decorate 84(@entryPointOutput_Pos_out) BuiltIn Position
|
||||
MemberDecorate 90(PerVertex_out) 0 BuiltIn Position
|
||||
Decorate 90(PerVertex_out) Block
|
||||
MemberName 92(PerVertex_out) 0 "@entryPointOutput_Pos_out"
|
||||
Name 94 "PerVertex_out"
|
||||
MemberDecorate 20(VS_OUTPUT) 1 BuiltIn Position
|
||||
Decorate 64(x0_in) Location 0
|
||||
Decorate 68(Pos_in) BuiltIn Position
|
||||
Decorate 71(x1_in) Location 1
|
||||
Decorate 80(@entryPointOutput) Location 0
|
||||
Decorate 86(@entryPointOutput_Pos_out) BuiltIn Position
|
||||
MemberDecorate 92(PerVertex_out) 0 BuiltIn Position
|
||||
Decorate 92(PerVertex_out) Block
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 32 1
|
||||
@ -284,104 +288,106 @@ Shader version: 450
|
||||
11(VS_OUTPUT): TypeStruct 6(int) 8(fvec4) 6(int)
|
||||
12: TypePointer Function 11(VS_OUTPUT)
|
||||
13: TypeFunction 2 10(ptr) 12(ptr)
|
||||
18: TypeFunction 11(VS_OUTPUT) 10(ptr)
|
||||
22: 6(int) Constant 1
|
||||
23: TypePointer Function 8(fvec4)
|
||||
29(VS_OUTPUT): TypeStruct 6(int) 8(fvec4) 6(int)
|
||||
30: TypePointer Function 29(VS_OUTPUT)
|
||||
32: 6(int) Constant 0
|
||||
33: TypePointer Function 6(int)
|
||||
40: 6(int) Constant 2
|
||||
61: TypePointer Input 6(int)
|
||||
62(x0_in): 61(ptr) Variable Input
|
||||
65: TypePointer Input 8(fvec4)
|
||||
66(Pos_in): 65(ptr) Variable Input
|
||||
69(x1_in): 61(ptr) Variable Input
|
||||
76(VS_OUTPUT): TypeStruct 6(int) 6(int)
|
||||
77: TypePointer Output 76(VS_OUTPUT)
|
||||
78(@entryPointOutput): 77(ptr) Variable Output
|
||||
81: TypePointer Output 6(int)
|
||||
83: TypePointer Output 8(fvec4)
|
||||
84(@entryPointOutput_Pos_out): 83(ptr) Variable Output
|
||||
90(PerVertex_out): TypeStruct 8(fvec4)
|
||||
91: TypePointer Output 90(PerVertex_out)
|
||||
92(PerVertex_out): 91(ptr) Variable Output
|
||||
18(VS_INPUT): TypeStruct 6(int) 8(fvec4) 6(int)
|
||||
19: TypePointer Function 18(VS_INPUT)
|
||||
20(VS_OUTPUT): TypeStruct 6(int) 8(fvec4) 6(int)
|
||||
21: TypeFunction 20(VS_OUTPUT) 19(ptr)
|
||||
25: 6(int) Constant 1
|
||||
26: TypePointer Function 8(fvec4)
|
||||
33: 6(int) Constant 0
|
||||
34: TypePointer Function 6(int)
|
||||
41: 6(int) Constant 2
|
||||
51: TypePointer Function 20(VS_OUTPUT)
|
||||
63: TypePointer Input 6(int)
|
||||
64(x0_in): 63(ptr) Variable Input
|
||||
67: TypePointer Input 8(fvec4)
|
||||
68(Pos_in): 67(ptr) Variable Input
|
||||
71(x1_in): 63(ptr) Variable Input
|
||||
78(VS_OUTPUT): TypeStruct 6(int) 6(int)
|
||||
79: TypePointer Output 78(VS_OUTPUT)
|
||||
80(@entryPointOutput): 79(ptr) Variable Output
|
||||
83: TypePointer Output 6(int)
|
||||
85: TypePointer Output 8(fvec4)
|
||||
86(@entryPointOutput_Pos_out): 85(ptr) Variable Output
|
||||
92(PerVertex_out): TypeStruct 8(fvec4)
|
||||
93: TypePointer Output 92(PerVertex_out)
|
||||
94(PerVertex_out): 93(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
60(vsin): 10(ptr) Variable Function
|
||||
72(flattenTemp): 12(ptr) Variable Function
|
||||
73(param): 10(ptr) Variable Function
|
||||
63: 6(int) Load 62(x0_in)
|
||||
64: 33(ptr) AccessChain 60(vsin) 32
|
||||
Store 64 63
|
||||
67: 8(fvec4) Load 66(Pos_in)
|
||||
68: 23(ptr) AccessChain 60(vsin) 22
|
||||
Store 68 67
|
||||
70: 6(int) Load 69(x1_in)
|
||||
71: 33(ptr) AccessChain 60(vsin) 40
|
||||
Store 71 70
|
||||
74: 9(VS_INPUT) Load 60(vsin)
|
||||
Store 73(param) 74
|
||||
75:11(VS_OUTPUT) FunctionCall 20(@main(struct-VS_INPUT-i1-vf4-i11;) 73(param)
|
||||
Store 72(flattenTemp) 75
|
||||
79: 33(ptr) AccessChain 72(flattenTemp) 32
|
||||
80: 6(int) Load 79
|
||||
82: 81(ptr) AccessChain 78(@entryPointOutput) 32
|
||||
Store 82 80
|
||||
85: 23(ptr) AccessChain 72(flattenTemp) 22
|
||||
86: 8(fvec4) Load 85
|
||||
Store 84(@entryPointOutput_Pos_out) 86
|
||||
87: 33(ptr) AccessChain 72(flattenTemp) 40
|
||||
88: 6(int) Load 87
|
||||
89: 81(ptr) AccessChain 78(@entryPointOutput) 22
|
||||
Store 89 88
|
||||
62(vsin): 19(ptr) Variable Function
|
||||
74(flattenTemp): 51(ptr) Variable Function
|
||||
75(param): 19(ptr) Variable Function
|
||||
65: 6(int) Load 64(x0_in)
|
||||
66: 34(ptr) AccessChain 62(vsin) 33
|
||||
Store 66 65
|
||||
69: 8(fvec4) Load 68(Pos_in)
|
||||
70: 26(ptr) AccessChain 62(vsin) 25
|
||||
Store 70 69
|
||||
72: 6(int) Load 71(x1_in)
|
||||
73: 34(ptr) AccessChain 62(vsin) 41
|
||||
Store 73 72
|
||||
76:18(VS_INPUT) Load 62(vsin)
|
||||
Store 75(param) 76
|
||||
77:20(VS_OUTPUT) FunctionCall 23(@main(struct-VS_INPUT-i1-vf4-i11;) 75(param)
|
||||
Store 74(flattenTemp) 77
|
||||
81: 34(ptr) AccessChain 74(flattenTemp) 33
|
||||
82: 6(int) Load 81
|
||||
84: 83(ptr) AccessChain 80(@entryPointOutput) 33
|
||||
Store 84 82
|
||||
87: 26(ptr) AccessChain 74(flattenTemp) 25
|
||||
88: 8(fvec4) Load 87
|
||||
Store 86(@entryPointOutput_Pos_out) 88
|
||||
89: 34(ptr) AccessChain 74(flattenTemp) 41
|
||||
90: 6(int) Load 89
|
||||
91: 83(ptr) AccessChain 80(@entryPointOutput) 25
|
||||
Store 91 90
|
||||
Return
|
||||
FunctionEnd
|
||||
16(Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11;): 2 Function None 13
|
||||
14(fn1_in): 10(ptr) FunctionParameter
|
||||
15(fn1_out): 12(ptr) FunctionParameter
|
||||
17: Label
|
||||
24: 23(ptr) AccessChain 14(fn1_in) 22
|
||||
25: 8(fvec4) Load 24
|
||||
26: 23(ptr) AccessChain 15(fn1_out) 22
|
||||
27: 8(fvec4) Load 26
|
||||
28: 8(fvec4) FAdd 25 27
|
||||
27: 26(ptr) AccessChain 14(fn1_in) 25
|
||||
28: 8(fvec4) Load 27
|
||||
29: 26(ptr) AccessChain 15(fn1_out) 25
|
||||
30: 8(fvec4) Load 29
|
||||
31: 8(fvec4) FAdd 28 30
|
||||
Return
|
||||
FunctionEnd
|
||||
20(@main(struct-VS_INPUT-i1-vf4-i11;):11(VS_OUTPUT) Function None 18
|
||||
19(vsin): 10(ptr) FunctionParameter
|
||||
21: Label
|
||||
31(vsout): 30(ptr) Variable Function
|
||||
44(param): 10(ptr) Variable Function
|
||||
46(param): 30(ptr) Variable Function
|
||||
50: 12(ptr) Variable Function
|
||||
34: 33(ptr) AccessChain 19(vsin) 32
|
||||
35: 6(int) Load 34
|
||||
36: 33(ptr) AccessChain 31(vsout) 32
|
||||
Store 36 35
|
||||
37: 23(ptr) AccessChain 19(vsin) 22
|
||||
38: 8(fvec4) Load 37
|
||||
39: 23(ptr) AccessChain 31(vsout) 22
|
||||
Store 39 38
|
||||
41: 33(ptr) AccessChain 19(vsin) 40
|
||||
42: 6(int) Load 41
|
||||
43: 33(ptr) AccessChain 31(vsout) 40
|
||||
Store 43 42
|
||||
45: 9(VS_INPUT) Load 19(vsin)
|
||||
Store 44(param) 45
|
||||
47:29(VS_OUTPUT) Load 31(vsout)
|
||||
Store 46(param) 47
|
||||
48: 2 FunctionCall 16(Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11;) 44(param) 46(param)
|
||||
49:29(VS_OUTPUT) Load 31(vsout)
|
||||
51: 6(int) CompositeExtract 49 0
|
||||
52: 33(ptr) AccessChain 50 32
|
||||
Store 52 51
|
||||
53: 8(fvec4) CompositeExtract 49 1
|
||||
54: 23(ptr) AccessChain 50 22
|
||||
23(@main(struct-VS_INPUT-i1-vf4-i11;):20(VS_OUTPUT) Function None 21
|
||||
22(vsin): 19(ptr) FunctionParameter
|
||||
24: Label
|
||||
32(vsout): 12(ptr) Variable Function
|
||||
45(param): 19(ptr) Variable Function
|
||||
47(param): 12(ptr) Variable Function
|
||||
52: 51(ptr) Variable Function
|
||||
35: 34(ptr) AccessChain 22(vsin) 33
|
||||
36: 6(int) Load 35
|
||||
37: 34(ptr) AccessChain 32(vsout) 33
|
||||
Store 37 36
|
||||
38: 26(ptr) AccessChain 22(vsin) 25
|
||||
39: 8(fvec4) Load 38
|
||||
40: 26(ptr) AccessChain 32(vsout) 25
|
||||
Store 40 39
|
||||
42: 34(ptr) AccessChain 22(vsin) 41
|
||||
43: 6(int) Load 42
|
||||
44: 34(ptr) AccessChain 32(vsout) 41
|
||||
Store 44 43
|
||||
46:18(VS_INPUT) Load 22(vsin)
|
||||
Store 45(param) 46
|
||||
48:11(VS_OUTPUT) Load 32(vsout)
|
||||
Store 47(param) 48
|
||||
49: 2 FunctionCall 16(Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11;) 45(param) 47(param)
|
||||
50:11(VS_OUTPUT) Load 32(vsout)
|
||||
53: 6(int) CompositeExtract 50 0
|
||||
54: 34(ptr) AccessChain 52 33
|
||||
Store 54 53
|
||||
55: 6(int) CompositeExtract 49 2
|
||||
56: 33(ptr) AccessChain 50 40
|
||||
55: 8(fvec4) CompositeExtract 50 1
|
||||
56: 26(ptr) AccessChain 52 25
|
||||
Store 56 55
|
||||
57:11(VS_OUTPUT) Load 50
|
||||
ReturnValue 57
|
||||
57: 6(int) CompositeExtract 50 2
|
||||
58: 34(ptr) AccessChain 52 41
|
||||
Store 58 57
|
||||
59:20(VS_OUTPUT) Load 52
|
||||
ReturnValue 59
|
||||
FunctionEnd
|
||||
|
||||
@ -401,7 +401,20 @@ public:
|
||||
// drop qualifiers that don't belong in a temporary variable
|
||||
void makeTemporary()
|
||||
{
|
||||
makeNonIo();
|
||||
storage = EvqTemporary;
|
||||
specConstant = false;
|
||||
coherent = false;
|
||||
volatil = false;
|
||||
restrict = false;
|
||||
readonly = false;
|
||||
writeonly = false;
|
||||
}
|
||||
|
||||
// Remove IO related data from qualifier.
|
||||
void makeNonIo()
|
||||
{
|
||||
// This preserves the storage type
|
||||
builtIn = EbvNone;
|
||||
centroid = false;
|
||||
smooth = false;
|
||||
@ -412,15 +425,18 @@ public:
|
||||
#endif
|
||||
patch = false;
|
||||
sample = false;
|
||||
coherent = false;
|
||||
volatil = false;
|
||||
restrict = false;
|
||||
readonly = false;
|
||||
writeonly = false;
|
||||
specConstant = false;
|
||||
clearLayout();
|
||||
}
|
||||
|
||||
// Return true if there is data which would be scrubbed by makeNonIo
|
||||
bool hasIoData() const
|
||||
{
|
||||
return builtIn != EbvNone ||
|
||||
hasLayout() ||
|
||||
isInterpolation() ||
|
||||
isAuxiliary();
|
||||
}
|
||||
|
||||
// Drop just the storage qualification, which perhaps should
|
||||
// never be done, as it is fundamentally inconsistent, but need to
|
||||
// explore what downstream consumers need.
|
||||
@ -1209,6 +1225,30 @@ public:
|
||||
deepCopy(copyOf, copied);
|
||||
}
|
||||
|
||||
// Return true if type (recursively) contains IO data.
|
||||
bool hasIoData() const
|
||||
{
|
||||
if (getQualifier().hasIoData())
|
||||
return true;
|
||||
|
||||
if (isStruct())
|
||||
for (unsigned int i = 0; i < structure->size(); ++i)
|
||||
if ((*structure)[i].type->hasIoData())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove IO related data from type
|
||||
void makeNonIo()
|
||||
{
|
||||
getQualifier().makeNonIo();
|
||||
|
||||
if (isStruct())
|
||||
for (unsigned int i = 0; i < structure->size(); ++i)
|
||||
(*structure)[i].type->makeNonIo();
|
||||
}
|
||||
|
||||
// Recursively make temporary
|
||||
void makeTemporary()
|
||||
{
|
||||
@ -1701,6 +1741,7 @@ public:
|
||||
const char* getBuiltInVariableString() const { return GetBuiltInVariableString(qualifier.builtIn); }
|
||||
const char* getPrecisionQualifierString() const { return GetPrecisionQualifierString(qualifier.precision); }
|
||||
const TTypeList* getStruct() const { return structure; }
|
||||
void setStruct(TTypeList* s) { structure = s; }
|
||||
TTypeList* getWritableStruct() const { return structure; } // This should only be used when known to not be sharing with other threads
|
||||
|
||||
int computeNumComponents() const
|
||||
|
||||
@ -1803,15 +1803,13 @@ void HlslParseContext::remapEntryPointIO(const TFunction& function, TVariable*&
|
||||
// declares entry point IO built-ins, but these have to be undone.
|
||||
void HlslParseContext::remapNonEntryPointIO(TFunction& function)
|
||||
{
|
||||
const auto remapBuiltInType = [&](TType& type) { type.getQualifier().builtIn = EbvNone; };
|
||||
|
||||
// return value
|
||||
if (function.getType().getBasicType() != EbtVoid)
|
||||
remapBuiltInType(function.getWritableType());
|
||||
makeNonIoType(&function.getWritableType());
|
||||
|
||||
// parameters
|
||||
for (int i = 0; i < function.getParamCount(); i++)
|
||||
remapBuiltInType(*function[i].type);
|
||||
makeNonIoType(function[i].type);
|
||||
}
|
||||
|
||||
// Handle function returns, including type conversions to the function return type
|
||||
@ -5393,41 +5391,43 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
|
||||
error(loc, "name already defined", "typedef", identifier.c_str());
|
||||
}
|
||||
|
||||
// Type sanitization: return existing sanitized (temporary) type if there is one, else make new one.
|
||||
TType* HlslParseContext::sanitizeType(TType* type)
|
||||
// Create a non-IO type from an IO type. If there is no IO data, this
|
||||
// returns the input type unmodified. Otherwise, it modifies the type
|
||||
// in place, and returns a pointer to it.
|
||||
TType* HlslParseContext::makeNonIoType(TType* type)
|
||||
{
|
||||
// We only do this for structs.
|
||||
// early out if there's nothing to do: prevents introduction of unneeded types.
|
||||
if (!type->hasIoData())
|
||||
return type;
|
||||
|
||||
type->getQualifier().makeNonIo(); // Sanitize the qualifier.
|
||||
|
||||
// Nothing more to do if there is no deep structure.
|
||||
if (!type->isStruct())
|
||||
return type;
|
||||
|
||||
// Type sanitization: if this is declaring a variable of a type that contains
|
||||
// interstage IO, we want to make it a temporary.
|
||||
const auto sanitizedTypeIter = sanitizedTypeMap.find(type->getStruct());
|
||||
const auto typeIter = nonIoTypeMap.find(type->getStruct());
|
||||
|
||||
if (sanitizedTypeIter != sanitizedTypeMap.end()) {
|
||||
// We've sanitized this before. Use that one.
|
||||
TType* sanitizedType = new TType();
|
||||
sanitizedType->shallowCopy(*sanitizedTypeIter->second);
|
||||
|
||||
// Arrayness is not part of the sanitized type. Use the input type's arrayness.
|
||||
if (type->isArray())
|
||||
sanitizedType->newArraySizes(type->getArraySizes());
|
||||
else
|
||||
sanitizedType->clearArraySizes();
|
||||
return sanitizedType;
|
||||
if (typeIter != nonIoTypeMap.end()) {
|
||||
// reuse deep structure if we have sanitized it before, but we must preserve
|
||||
// our unique shallow structure, which may not be shared with other users of
|
||||
// the deep copy. Create a new type with the sanitized qualifier, and the
|
||||
// shared deep structure
|
||||
type->setStruct(typeIter->second); // share already sanitized deep structure.
|
||||
} else {
|
||||
if (type->containsBuiltInInterstageIO(language)) {
|
||||
// This means the type contains interstage IO, but we've never encountered it before.
|
||||
// Copy it, sanitize it, and remember it in the sanitizedTypeMap
|
||||
TType* sanitizedType = type->clone();
|
||||
sanitizedType->makeTemporary();
|
||||
sanitizedTypeMap[type->getStruct()] = sanitizedType;
|
||||
return sanitizedType;
|
||||
} else {
|
||||
// This means the type has no interstage IO, so we can use it as is.
|
||||
return type;
|
||||
}
|
||||
}
|
||||
// The type contains interstage IO, but we've never encountered it before.
|
||||
// Copy it, scrub data we don't want for an non-IO type, and remember it in the nonIoTypeMap
|
||||
|
||||
TType nonIoType;
|
||||
nonIoType.deepCopy(*type);
|
||||
nonIoType.makeNonIo();
|
||||
|
||||
// remember the new deep structure in a map, so we can share it in the future.
|
||||
nonIoTypeMap[type->getStruct()] = nonIoType.getWritableStruct();
|
||||
type->shallowCopy(nonIoType); // we modify the input type in place
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
//
|
||||
@ -5456,18 +5456,23 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
|
||||
|
||||
const bool flattenVar = shouldFlattenUniform(type);
|
||||
|
||||
// Type sanitization: if this is declaring a variable of a type that contains
|
||||
// interstage IO, we want to make it a temporary.
|
||||
TType* sanitizedType = sanitizeType(&type);
|
||||
// make non-IO version of type
|
||||
switch (type.getQualifier().storage) {
|
||||
case EvqGlobal:
|
||||
case EvqTemporary:
|
||||
makeNonIoType(&type);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Declare the variable
|
||||
if (type.isArray()) {
|
||||
// array case
|
||||
declareArray(loc, identifier, *sanitizedType, symbol, !flattenVar);
|
||||
declareArray(loc, identifier, type, symbol, !flattenVar);
|
||||
} else {
|
||||
// non-array case
|
||||
if (! symbol)
|
||||
symbol = declareNonArray(loc, identifier, *sanitizedType, !flattenVar);
|
||||
symbol = declareNonArray(loc, identifier, type, !flattenVar);
|
||||
else if (type != symbol->getType())
|
||||
error(loc, "cannot change the type of", "redeclaration", symbol->getName().c_str());
|
||||
}
|
||||
|
||||
@ -228,8 +228,9 @@ protected:
|
||||
int flattenStruct(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
|
||||
int flattenArray(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
|
||||
|
||||
// Type sanitization: return existing sanitized (temporary) type if there is one, else make new one.
|
||||
TType* sanitizeType(TType*);
|
||||
// Create a non-IO type from an IO type. If there is no IO data, this returns the input type unmodified.
|
||||
// Otherwise, it modifies the type in place, and returns a pointer to it.
|
||||
TType* makeNonIoType(TType*);
|
||||
|
||||
void finish() override; // post-processing
|
||||
|
||||
@ -296,9 +297,9 @@ protected:
|
||||
TVector<int> flattenLevel; // nested postfix operator level for flattening
|
||||
TVector<int> flattenOffset; // cumulative offset for flattening
|
||||
|
||||
// Sanitized type map. During declarations we use the sanitized form of the type
|
||||
// if it exists.
|
||||
TMap<const TTypeList*, TType*> sanitizedTypeMap;
|
||||
// Sanitized type map. If the same type is sanitized again, we want to reuse it.
|
||||
// We cannot index by the TType: the map is typelist to typelist.
|
||||
TMap<const TTypeList*, TTypeList*> nonIoTypeMap;
|
||||
|
||||
// Structure splitting data:
|
||||
TMap<int, TVariable*> splitIoVars; // variables with the builtin interstage IO removed, indexed by unique ID.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user