SPV: Flatten structs for copy when they are GLSL type aliases.
Addresses issue #304 and issue #307 by replacing unmatched type OpStores with per-member copies. Covers assignment statements and most argument passing, but does not yet cover r-value-based argument passing.
This commit is contained in:
parent
31207bc20a
commit
4bf7155051
7 changed files with 455 additions and 26 deletions
192
Test/baseResults/spv.multiStruct.comp.out
Executable file
192
Test/baseResults/spv.multiStruct.comp.out
Executable file
|
|
@ -0,0 +1,192 @@
|
|||
spv.multiStruct.comp
|
||||
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
|
||||
|
||||
|
||||
Linked compute stage:
|
||||
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 97
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint GLCompute 4 "main"
|
||||
ExecutionMode 4 LocalSize 1 1 1
|
||||
Source GLSL 450
|
||||
Name 4 "main"
|
||||
Name 9 "MyStruct"
|
||||
MemberName 9(MyStruct) 0 "foo"
|
||||
MemberName 9(MyStruct) 1 "sb"
|
||||
Name 11 "t"
|
||||
Name 13 "MyStruct"
|
||||
MemberName 13(MyStruct) 0 "foo"
|
||||
MemberName 13(MyStruct) 1 "sb"
|
||||
Name 14 "SSBO0"
|
||||
MemberName 14(SSBO0) 0 "a"
|
||||
Name 16 "inBuf"
|
||||
Name 29 "SSBO1"
|
||||
MemberName 29(SSBO1) 0 "b"
|
||||
Name 31 "outBuf"
|
||||
Name 43 "MyStruct"
|
||||
MemberName 43(MyStruct) 0 "foo"
|
||||
MemberName 43(MyStruct) 1 "sb"
|
||||
Name 44 "UBO"
|
||||
MemberName 44(UBO) 0 "c"
|
||||
Name 46 "uBuf"
|
||||
Name 61 "Nested"
|
||||
MemberName 61(Nested) 0 "f"
|
||||
MemberName 61(Nested) 1 "S"
|
||||
Name 63 "n"
|
||||
Name 64 "Nested"
|
||||
MemberName 64(Nested) 0 "f"
|
||||
MemberName 64(Nested) 1 "S"
|
||||
Name 65 "UBON"
|
||||
MemberName 65(UBON) 0 "N1"
|
||||
Name 67 "uBufN"
|
||||
Name 80 "Nested"
|
||||
MemberName 80(Nested) 0 "f"
|
||||
MemberName 80(Nested) 1 "S"
|
||||
Name 81 "SSBO1N"
|
||||
MemberName 81(SSBO1N) 0 "N2"
|
||||
Name 83 "outBufN"
|
||||
MemberDecorate 13(MyStruct) 0 Offset 0
|
||||
MemberDecorate 13(MyStruct) 1 Offset 16
|
||||
MemberDecorate 14(SSBO0) 0 Offset 0
|
||||
Decorate 14(SSBO0) BufferBlock
|
||||
Decorate 16(inBuf) DescriptorSet 0
|
||||
Decorate 16(inBuf) Binding 0
|
||||
MemberDecorate 29(SSBO1) 0 Offset 0
|
||||
Decorate 29(SSBO1) BufferBlock
|
||||
Decorate 31(outBuf) DescriptorSet 0
|
||||
Decorate 31(outBuf) Binding 1
|
||||
MemberDecorate 43(MyStruct) 0 Offset 0
|
||||
MemberDecorate 43(MyStruct) 1 Offset 16
|
||||
MemberDecorate 44(UBO) 0 Offset 0
|
||||
Decorate 44(UBO) Block
|
||||
Decorate 46(uBuf) DescriptorSet 0
|
||||
Decorate 46(uBuf) Binding 2
|
||||
MemberDecorate 64(Nested) 0 Offset 0
|
||||
MemberDecorate 64(Nested) 1 Offset 16
|
||||
MemberDecorate 65(UBON) 0 Offset 0
|
||||
Decorate 65(UBON) Block
|
||||
Decorate 67(uBufN) DescriptorSet 0
|
||||
Decorate 67(uBufN) Binding 2
|
||||
MemberDecorate 80(Nested) 0 Offset 0
|
||||
MemberDecorate 80(Nested) 1 Offset 16
|
||||
MemberDecorate 81(SSBO1N) 0 Offset 0
|
||||
Decorate 81(SSBO1N) BufferBlock
|
||||
Decorate 83(outBufN) DescriptorSet 0
|
||||
Decorate 83(outBufN) Binding 1
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeFloat 32
|
||||
7: TypeVector 6(float) 4
|
||||
8: TypeBool
|
||||
9(MyStruct): TypeStruct 7(fvec4) 8(bool)
|
||||
10: TypePointer Function 9(MyStruct)
|
||||
12: TypeInt 32 0
|
||||
13(MyStruct): TypeStruct 7(fvec4) 12(int)
|
||||
14(SSBO0): TypeStruct 13(MyStruct)
|
||||
15: TypePointer Uniform 14(SSBO0)
|
||||
16(inBuf): 15(ptr) Variable Uniform
|
||||
17: TypeInt 32 1
|
||||
18: 17(int) Constant 0
|
||||
19: TypePointer Uniform 13(MyStruct)
|
||||
23: TypePointer Function 7(fvec4)
|
||||
26: 17(int) Constant 1
|
||||
27: TypePointer Function 8(bool)
|
||||
29(SSBO1): TypeStruct 13(MyStruct)
|
||||
30: TypePointer Uniform 29(SSBO1)
|
||||
31(outBuf): 30(ptr) Variable Uniform
|
||||
35: TypePointer Uniform 7(fvec4)
|
||||
38: 12(int) Constant 0
|
||||
39: 12(int) Constant 1
|
||||
41: TypePointer Uniform 12(int)
|
||||
43(MyStruct): TypeStruct 7(fvec4) 12(int)
|
||||
44(UBO): TypeStruct 43(MyStruct)
|
||||
45: TypePointer Uniform 44(UBO)
|
||||
46(uBuf): 45(ptr) Variable Uniform
|
||||
47: TypePointer Uniform 43(MyStruct)
|
||||
61(Nested): TypeStruct 6(float) 9(MyStruct)
|
||||
62: TypePointer Function 61(Nested)
|
||||
64(Nested): TypeStruct 6(float) 43(MyStruct)
|
||||
65(UBON): TypeStruct 64(Nested)
|
||||
66: TypePointer Uniform 65(UBON)
|
||||
67(uBufN): 66(ptr) Variable Uniform
|
||||
68: TypePointer Uniform 64(Nested)
|
||||
72: TypePointer Function 6(float)
|
||||
80(Nested): TypeStruct 6(float) 13(MyStruct)
|
||||
81(SSBO1N): TypeStruct 80(Nested)
|
||||
82: TypePointer Uniform 81(SSBO1N)
|
||||
83(outBufN): 82(ptr) Variable Uniform
|
||||
85: TypePointer Uniform 80(Nested)
|
||||
88: TypePointer Uniform 6(float)
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
11(t): 10(ptr) Variable Function
|
||||
63(n): 62(ptr) Variable Function
|
||||
20: 19(ptr) AccessChain 16(inBuf) 18
|
||||
21:13(MyStruct) Load 20
|
||||
22: 7(fvec4) CompositeExtract 21 0
|
||||
24: 23(ptr) AccessChain 11(t) 18
|
||||
Store 24 22
|
||||
25: 12(int) CompositeExtract 21 1
|
||||
28: 27(ptr) AccessChain 11(t) 26
|
||||
Store 28 25
|
||||
32: 9(MyStruct) Load 11(t)
|
||||
33: 19(ptr) AccessChain 31(outBuf) 18
|
||||
34: 7(fvec4) CompositeExtract 32 0
|
||||
36: 35(ptr) AccessChain 33 18
|
||||
Store 36 34
|
||||
37: 8(bool) CompositeExtract 32 1
|
||||
40: 12(int) Select 37 39 38
|
||||
42: 41(ptr) AccessChain 33 26
|
||||
Store 42 40
|
||||
48: 47(ptr) AccessChain 46(uBuf) 18
|
||||
49:43(MyStruct) Load 48
|
||||
50: 7(fvec4) CompositeExtract 49 0
|
||||
51: 23(ptr) AccessChain 11(t) 18
|
||||
Store 51 50
|
||||
52: 12(int) CompositeExtract 49 1
|
||||
53: 27(ptr) AccessChain 11(t) 26
|
||||
Store 53 52
|
||||
54: 9(MyStruct) Load 11(t)
|
||||
55: 19(ptr) AccessChain 31(outBuf) 18
|
||||
56: 7(fvec4) CompositeExtract 54 0
|
||||
57: 35(ptr) AccessChain 55 18
|
||||
Store 57 56
|
||||
58: 8(bool) CompositeExtract 54 1
|
||||
59: 12(int) Select 58 39 38
|
||||
60: 41(ptr) AccessChain 55 26
|
||||
Store 60 59
|
||||
69: 68(ptr) AccessChain 67(uBufN) 18
|
||||
70: 64(Nested) Load 69
|
||||
71: 6(float) CompositeExtract 70 0
|
||||
73: 72(ptr) AccessChain 63(n) 18
|
||||
Store 73 71
|
||||
74:43(MyStruct) CompositeExtract 70 1
|
||||
75: 10(ptr) AccessChain 63(n) 26
|
||||
76: 7(fvec4) CompositeExtract 74 0
|
||||
77: 23(ptr) AccessChain 75 18
|
||||
Store 77 76
|
||||
78: 12(int) CompositeExtract 74 1
|
||||
79: 27(ptr) AccessChain 75 26
|
||||
Store 79 78
|
||||
84: 61(Nested) Load 63(n)
|
||||
86: 85(ptr) AccessChain 83(outBufN) 18
|
||||
87: 6(float) CompositeExtract 84 0
|
||||
89: 88(ptr) AccessChain 86 18
|
||||
Store 89 87
|
||||
90: 9(MyStruct) CompositeExtract 84 1
|
||||
91: 19(ptr) AccessChain 86 26
|
||||
92: 7(fvec4) CompositeExtract 90 0
|
||||
93: 35(ptr) AccessChain 91 18
|
||||
Store 93 92
|
||||
94: 8(bool) CompositeExtract 90 1
|
||||
95: 12(int) Select 94 39 38
|
||||
96: 41(ptr) AccessChain 91 26
|
||||
Store 96 95
|
||||
Return
|
||||
FunctionEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue