Generate separate stores for partially swizzled memory stores

Full vector and fully specified vector swizzle stores are not affected by this change, only partial swizzles ie swizzles with fewer components than the vector being stored to.

Previously the vector being stored to loaded and any components not specified in the swizzle were used to create a full store to the vector.

While this change generates more SPIR-V instructions, it is necessary for correctness.

Fixes #2518.
This commit is contained in:
Jeremy Hayes 2021-07-16 15:07:16 -06:00
parent 9158061398
commit 6d5b40f051
50 changed files with 31343 additions and 26594 deletions

View file

@ -1,12 +1,12 @@
spv.swizzle.frag
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 108
// Id's are bound by 117
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 14 30 69 107
EntryPoint Fragment 4 "main" 14 30 78 116
ExecutionMode 4 OriginUpperLeft
Source GLSL 140
Name 4 "main"
@ -18,16 +18,16 @@ spv.swizzle.frag
Name 20 "w2"
Name 22 "w_flow"
Name 30 "t"
Name 49 "w_undef"
Name 56 "p"
Name 69 "gl_FragColor"
Name 81 "c"
Name 83 "rep"
Name 107 "blend"
Name 56 "w_undef"
Name 65 "p"
Name 78 "gl_FragColor"
Name 90 "c"
Name 92 "rep"
Name 116 "blend"
Decorate 14(u) Location 1
Decorate 30(t) Location 2
Decorate 69(gl_FragColor) Location 0
Decorate 107(blend) Location 0
Decorate 78(gl_FragColor) Location 0
Decorate 116(blend) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -42,21 +42,22 @@ spv.swizzle.frag
28: TypeVector 6(float) 2
29: TypePointer Input 28(fvec2)
30(t): 29(ptr) Variable Input
35: 25(int) Constant 0
40: 25(int) Constant 1
54: TypeBool
55: TypePointer Private 54(bool)
56(p): 55(ptr) Variable Private
60: TypePointer Input 6(float)
68: TypePointer Output 10(fvec4)
69(gl_FragColor): 68(ptr) Variable Output
80: TypePointer Function 28(fvec2)
84: 6(float) Constant 0
85: 6(float) Constant 1065353216
86: 10(fvec4) ConstantComposite 84 84 84 85
92: 6(float) Constant 3212836864
102: 6(float) Constant 1079613850
107(blend): 60(ptr) Variable Input
32: 25(int) Constant 3
35: 25(int) Constant 1
39: 25(int) Constant 0
63: TypeBool
64: TypePointer Private 63(bool)
65(p): 64(ptr) Variable Private
69: TypePointer Input 6(float)
77: TypePointer Output 10(fvec4)
78(gl_FragColor): 77(ptr) Variable Output
89: TypePointer Function 28(fvec2)
93: 6(float) Constant 0
94: 6(float) Constant 1065353216
95: 10(fvec4) ConstantComposite 93 93 93 94
101: 6(float) Constant 3212836864
111: 6(float) Constant 1079613850
116(blend): 69(ptr) Variable Input
4(main): 2 Function None 3
5: Label
8(blendscale): 7(ptr) Variable Function
@ -65,9 +66,9 @@ spv.swizzle.frag
18(w_reorder): 11(ptr) Variable Function
20(w2): 11(ptr) Variable Function
22(w_flow): 11(ptr) Variable Function
49(w_undef): 11(ptr) Variable Function
81(c): 80(ptr) Variable Function
83(rep): 11(ptr) Variable Function
56(w_undef): 11(ptr) Variable Function
90(c): 89(ptr) Variable Function
92(rep): 11(ptr) Variable Function
Store 8(blendscale) 9
15: 10(fvec4) Load 14(u)
Store 12(w) 15
@ -83,88 +84,100 @@ spv.swizzle.frag
27: 7(ptr) AccessChain 18(w_reorder) 26
Store 27 24
31: 28(fvec2) Load 30(t)
32: 10(fvec4) Load 12(w)
33: 10(fvec4) VectorShuffle 32 31 0 5 2 4
Store 12(w) 33
34: 6(float) Load 8(blendscale)
36: 7(ptr) AccessChain 18(w_reorder) 35
Store 36 34
37: 10(fvec4) Load 14(u)
38: 10(fvec4) VectorShuffle 37 37 2 3 0 1
Store 20(w2) 38
39: 6(float) Load 8(blendscale)
41: 7(ptr) AccessChain 18(w_reorder) 40
Store 41 39
42: 10(fvec4) Load 20(w2)
43: 28(fvec2) VectorShuffle 42 42 0 2
44: 10(fvec4) Load 16(w_dep)
45: 10(fvec4) VectorShuffle 44 43 4 5 2 3
Store 16(w_dep) 45
46: 28(fvec2) Load 30(t)
47: 10(fvec4) Load 16(w_dep)
48: 10(fvec4) VectorShuffle 47 46 0 1 4 5
Store 16(w_dep) 48
50: 10(fvec4) Load 14(u)
51: 28(fvec2) VectorShuffle 50 50 2 3
52: 10(fvec4) Load 49(w_undef)
53: 10(fvec4) VectorShuffle 52 51 4 5 2 3
Store 49(w_undef) 53
57: 54(bool) Load 56(p)
SelectionMerge 59 None
BranchConditional 57 58 64
58: Label
61: 60(ptr) AccessChain 30(t) 35
62: 6(float) Load 61
63: 7(ptr) AccessChain 22(w_flow) 35
Store 63 62
Branch 59
64: Label
65: 60(ptr) AccessChain 30(t) 40
66: 6(float) Load 65
67: 7(ptr) AccessChain 22(w_flow) 35
Store 67 66
Branch 59
59: Label
70: 10(fvec4) Load 18(w_reorder)
71: 10(fvec4) Load 49(w_undef)
72: 10(fvec4) Load 12(w)
73: 10(fvec4) Load 20(w2)
74: 10(fvec4) FMul 72 73
75: 10(fvec4) Load 16(w_dep)
76: 10(fvec4) FMul 74 75
77: 10(fvec4) Load 22(w_flow)
78: 10(fvec4) FMul 76 77
79: 10(fvec4) ExtInst 1(GLSL.std.450) 46(FMix) 70 71 78
Store 69(gl_FragColor) 79
82: 28(fvec2) Load 30(t)
Store 81(c) 82
Store 83(rep) 86
87: 7(ptr) AccessChain 81(c) 35
88: 6(float) Load 87
89: 54(bool) FOrdLessThan 88 84
SelectionMerge 91 None
BranchConditional 89 90 91
90: Label
93: 7(ptr) AccessChain 81(c) 35
94: 6(float) Load 93
95: 6(float) FMul 94 92
96: 7(ptr) AccessChain 81(c) 35
Store 96 95
Branch 91
91: Label
97: 7(ptr) AccessChain 81(c) 35
98: 6(float) Load 97
99: 54(bool) FOrdLessThanEqual 98 85
SelectionMerge 101 None
BranchConditional 99 100 101
100: Label
103: 7(ptr) AccessChain 83(rep) 35
Store 103 102
Branch 101
101: Label
104: 10(fvec4) Load 83(rep)
105: 10(fvec4) Load 69(gl_FragColor)
106: 10(fvec4) FAdd 105 104
Store 69(gl_FragColor) 106
33: 7(ptr) AccessChain 12(w) 32
34: 6(float) CompositeExtract 31 0
Store 33 34
36: 7(ptr) AccessChain 12(w) 35
37: 6(float) CompositeExtract 31 1
Store 36 37
38: 6(float) Load 8(blendscale)
40: 7(ptr) AccessChain 18(w_reorder) 39
Store 40 38
41: 10(fvec4) Load 14(u)
42: 10(fvec4) VectorShuffle 41 41 2 3 0 1
Store 20(w2) 42
43: 6(float) Load 8(blendscale)
44: 7(ptr) AccessChain 18(w_reorder) 35
Store 44 43
45: 10(fvec4) Load 20(w2)
46: 28(fvec2) VectorShuffle 45 45 0 2
47: 7(ptr) AccessChain 16(w_dep) 39
48: 6(float) CompositeExtract 46 0
Store 47 48
49: 7(ptr) AccessChain 16(w_dep) 35
50: 6(float) CompositeExtract 46 1
Store 49 50
51: 28(fvec2) Load 30(t)
52: 7(ptr) AccessChain 16(w_dep) 26
53: 6(float) CompositeExtract 51 0
Store 52 53
54: 7(ptr) AccessChain 16(w_dep) 32
55: 6(float) CompositeExtract 51 1
Store 54 55
57: 10(fvec4) Load 14(u)
58: 28(fvec2) VectorShuffle 57 57 2 3
59: 7(ptr) AccessChain 56(w_undef) 39
60: 6(float) CompositeExtract 58 0
Store 59 60
61: 7(ptr) AccessChain 56(w_undef) 35
62: 6(float) CompositeExtract 58 1
Store 61 62
66: 63(bool) Load 65(p)
SelectionMerge 68 None
BranchConditional 66 67 73
67: Label
70: 69(ptr) AccessChain 30(t) 39
71: 6(float) Load 70
72: 7(ptr) AccessChain 22(w_flow) 39
Store 72 71
Branch 68
73: Label
74: 69(ptr) AccessChain 30(t) 35
75: 6(float) Load 74
76: 7(ptr) AccessChain 22(w_flow) 39
Store 76 75
Branch 68
68: Label
79: 10(fvec4) Load 18(w_reorder)
80: 10(fvec4) Load 56(w_undef)
81: 10(fvec4) Load 12(w)
82: 10(fvec4) Load 20(w2)
83: 10(fvec4) FMul 81 82
84: 10(fvec4) Load 16(w_dep)
85: 10(fvec4) FMul 83 84
86: 10(fvec4) Load 22(w_flow)
87: 10(fvec4) FMul 85 86
88: 10(fvec4) ExtInst 1(GLSL.std.450) 46(FMix) 79 80 87
Store 78(gl_FragColor) 88
91: 28(fvec2) Load 30(t)
Store 90(c) 91
Store 92(rep) 95
96: 7(ptr) AccessChain 90(c) 39
97: 6(float) Load 96
98: 63(bool) FOrdLessThan 97 93
SelectionMerge 100 None
BranchConditional 98 99 100
99: Label
102: 7(ptr) AccessChain 90(c) 39
103: 6(float) Load 102
104: 6(float) FMul 103 101
105: 7(ptr) AccessChain 90(c) 39
Store 105 104
Branch 100
100: Label
106: 7(ptr) AccessChain 90(c) 39
107: 6(float) Load 106
108: 63(bool) FOrdLessThanEqual 107 94
SelectionMerge 110 None
BranchConditional 108 109 110
109: Label
112: 7(ptr) AccessChain 92(rep) 39
Store 112 111
Branch 110
110: Label
113: 10(fvec4) Load 92(rep)
114: 10(fvec4) Load 78(gl_FragColor)
115: 10(fvec4) FAdd 114 113
Store 78(gl_FragColor) 115
Return
FunctionEnd