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,18 +1,18 @@
hlsl.partialFlattenLocal.vert
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 159
// Id's are bound by 164
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 83 86
EntryPoint Vertex 4 "main" 86 89
Source HLSL 500
Name 4 "main"
Name 83 "pos"
Name 86 "@entryPointOutput"
Decorate 83(pos) Location 0
Decorate 86(@entryPointOutput) BuiltIn Position
Name 86 "pos"
Name 89 "@entryPointOutput"
Decorate 86(pos) Location 0
Decorate 89(@entryPointOutput) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -33,49 +33,54 @@ hlsl.partialFlattenLocal.vert
37: 6(float) Constant 1065353216
38: 18(fvec2) ConstantComposite 32 37
39: TypePointer Function 18(fvec2)
42: TypePointer Function 6(float)
54: TypeBool
82: TypePointer Input 7(fvec4)
83(pos): 82(ptr) Variable Input
85: TypePointer Output 7(fvec4)
86(@entryPointOutput): 85(ptr) Variable Output
131: TypePointer Function 17
133: TypePointer Function 20
64: 15(int) Constant 0
67: 15(int) Constant 1
85: TypePointer Input 7(fvec4)
86(pos): 85(ptr) Variable Input
88: TypePointer Output 7(fvec4)
89(@entryPointOutput): 88(ptr) Variable Output
135: TypePointer Function 17
137: TypePointer Function 20
4(main): 2 Function None 3
5: Label
134: 133(ptr) Variable Function
132: 131(ptr) Variable Function
84: 7(fvec4) Load 83(pos)
137: 34(ptr) AccessChain 132 25
Store 137 33
138: 39(ptr) AccessChain 134 25
Store 138 38
Branch 101
101: Label
158: 21(int) Phi 25 5 119 105
104: 54(bool) SLessThan 158 31
LoopMerge 120 105 None
BranchConditional 104 105 120
105: Label
139: 39(ptr) AccessChain 134 158
109: 18(fvec2) Load 139
140: 34(ptr) AccessChain 132 158
111: 14(fvec3) Load 140
112: 18(fvec2) VectorShuffle 111 111 0 1
113: 18(fvec2) FAdd 112 109
141: 34(ptr) AccessChain 132 158
115: 14(fvec3) Load 141
116: 14(fvec3) VectorShuffle 115 113 3 4 2
Store 141 116
119: 21(int) IAdd 158 31
Branch 101
120: Label
143: 17 Load 132
157: 14(fvec3) CompositeExtract 143 0
125: 6(float) CompositeExtract 157 0
126: 6(float) CompositeExtract 157 1
127: 6(float) CompositeExtract 157 2
128: 7(fvec4) CompositeConstruct 125 126 127 32
129: 7(fvec4) FAdd 84 128
Store 86(@entryPointOutput) 129
138: 137(ptr) Variable Function
136: 135(ptr) Variable Function
87: 7(fvec4) Load 86(pos)
141: 34(ptr) AccessChain 136 25
Store 141 33
142: 39(ptr) AccessChain 138 25
Store 142 38
Branch 104
104: Label
163: 21(int) Phi 25 5 123 108
107: 54(bool) SLessThan 163 31
LoopMerge 124 108 None
BranchConditional 107 108 124
108: Label
143: 39(ptr) AccessChain 138 163
112: 18(fvec2) Load 143
144: 34(ptr) AccessChain 136 163
114: 14(fvec3) Load 144
115: 18(fvec2) VectorShuffle 114 114 0 1
116: 18(fvec2) FAdd 115 112
145: 42(ptr) AccessChain 136 163 64
118: 6(float) CompositeExtract 116 0
Store 145 118
146: 42(ptr) AccessChain 136 163 67
120: 6(float) CompositeExtract 116 1
Store 146 120
123: 21(int) IAdd 163 31
Branch 104
124: Label
148: 17 Load 136
162: 14(fvec3) CompositeExtract 148 0
129: 6(float) CompositeExtract 162 0
130: 6(float) CompositeExtract 162 1
131: 6(float) CompositeExtract 162 2
132: 7(fvec4) CompositeConstruct 129 130 131 32
133: 7(fvec4) FAdd 87 132
Store 89(@entryPointOutput) 133
Return
FunctionEnd