Skip to content

Commit 7a2afeb

Browse files
authored
fix(vulkan): remove atomic memory semantics (#8391)
1 parent ddcd89f commit 7a2afeb

13 files changed

+741
-747
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ SamplerDescriptor {
111111

112112
- Align copies b/w textures and buffers via a single intermediate buffer per copy when `D3D12_FEATURE_DATA_D3D12_OPTIONS13.UnrestrictedBufferTextureCopyPitchSupported` is `false`. By @ErichDonGubler in [#7721](https://github.com/gfx-rs/wgpu/pull/7721).
113113

114+
#### Vulkan
115+
116+
- Fixed a validation error regarding atomic memory semantics. By @atlv24 in [#8391](https://github.com/gfx-rs/wgpu/pull/8391).
117+
114118
#### hal
115119

116120
- `DropCallback`s are now called after dropping all other fields of their parent structs. By @jerzywilczek in [#8353](https://github.com/gfx-rs/wgpu/pull/8353)

naga/src/back/spv/block.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,6 +3543,7 @@ impl BlockContext<'_> {
35433543
}
35443544
_ => unimplemented!(),
35453545
};
3546+
35463547
let mut cas_instr = Instruction::new(spirv::Op::AtomicCompareExchange);
35473548
cas_instr.set_type(scalar_type_id);
35483549
cas_instr.set_result(cas_result_id);

naga/src/back/spv/helpers.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,10 @@ impl crate::AddressSpace {
7979
self,
8080
) -> (spirv::MemorySemantics, spirv::Scope) {
8181
match self {
82-
Self::Storage { .. } => (spirv::MemorySemantics::UNIFORM_MEMORY, spirv::Scope::Device),
83-
Self::WorkGroup => (
84-
spirv::MemorySemantics::WORKGROUP_MEMORY,
85-
spirv::Scope::Workgroup,
86-
),
82+
Self::Storage { .. } => (spirv::MemorySemantics::empty(), spirv::Scope::Device),
83+
Self::WorkGroup => (spirv::MemorySemantics::empty(), spirv::Scope::Workgroup),
84+
Self::Uniform => (spirv::MemorySemantics::empty(), spirv::Scope::Device),
85+
Self::Handle => (spirv::MemorySemantics::empty(), spirv::Scope::Device),
8786
_ => (spirv::MemorySemantics::empty(), spirv::Scope::Invocation),
8887
}
8988
}
Lines changed: 146 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
; SPIR-V
22
; Version: 1.0
33
; Generator: rspirv
4-
; Bound: 173
4+
; Bound: 172
55
OpCapability Shader
66
OpCapability Int64Atomics
77
OpCapability Int64
88
OpExtension "SPV_KHR_storage_buffer_storage_class"
99
%1 = OpExtInstImport "GLSL.std.450"
1010
OpMemoryModel Logical GLSL450
1111
OpEntryPoint GLCompute %19 "test_atomic_compare_exchange_i64"
12-
OpEntryPoint GLCompute %104 "test_atomic_compare_exchange_u64"
12+
OpEntryPoint GLCompute %103 "test_atomic_compare_exchange_u64"
1313
OpExecutionMode %19 LocalSize 1 1 1
14-
OpExecutionMode %104 LocalSize 1 1 1
14+
OpExecutionMode %103 LocalSize 1 1 1
1515
OpDecorate %5 ArrayStride 8
1616
OpDecorate %8 ArrayStride 8
1717
OpMemberDecorate %10 0 Offset 0
@@ -62,20 +62,19 @@ OpMemberDecorate %16 0 Offset 0
6262
%64 = OpTypePointer StorageBuffer %4
6363
%68 = OpTypeInt 32 1
6464
%67 = OpConstant %68 1
65-
%69 = OpConstant %3 64
66-
%105 = OpTypePointer StorageBuffer %8
67-
%107 = OpConstant %7 10
68-
%110 = OpTypePointer Function %7
69-
%111 = OpConstantNull %7
70-
%113 = OpConstantNull %9
71-
%137 = OpTypePointer StorageBuffer %7
65+
%104 = OpTypePointer StorageBuffer %8
66+
%106 = OpConstant %7 10
67+
%109 = OpTypePointer Function %7
68+
%110 = OpConstantNull %7
69+
%112 = OpConstantNull %9
70+
%136 = OpTypePointer StorageBuffer %7
7271
%19 = OpFunction %2 None %20
7372
%18 = OpLabel
7473
%27 = OpVariable %28 Function %22
7574
%29 = OpVariable %30 Function %31
7675
%32 = OpVariable %33 Function %34
7776
%46 = OpVariable %41 Function %45
78-
%74 = OpVariable %41 Function %45
77+
%73 = OpVariable %41 Function %45
7978
%23 = OpAccessChain %21 %12 %22
8079
OpBranch %35
8180
%35 = OpLabel
@@ -109,163 +108,163 @@ OpBranch %61
109108
%61 = OpLabel
110109
%63 = OpLoad %3 %27
111110
%65 = OpAccessChain %64 %23 %63
112-
%66 = OpAtomicLoad %4 %65 %67 %69
111+
%66 = OpAtomicLoad %4 %65 %67 %22
113112
OpStore %29 %66
114113
OpStore %32 %24
115-
OpBranch %70
116-
%70 = OpLabel
117-
OpLoopMerge %71 %73 None
118-
OpBranch %75
119-
%75 = OpLabel
120-
%76 = OpLoad %40 %74
121-
%77 = OpIEqual %42 %43 %76
122-
%78 = OpAll %9 %77
123-
OpSelectionMerge %79 None
124-
OpBranchConditional %78 %71 %79
125-
%79 = OpLabel
126-
%80 = OpCompositeExtract %3 %76 1
127-
%81 = OpIEqual %9 %80 %22
128-
%82 = OpSelect %3 %81 %26 %22
129-
%83 = OpCompositeConstruct %40 %82 %26
130-
%84 = OpISub %40 %76 %83
131-
OpStore %74 %84
132-
OpBranch %72
133-
%72 = OpLabel
134-
%85 = OpLoad %9 %32
135-
%86 = OpLogicalNot %9 %85
136-
OpSelectionMerge %87 None
137-
OpBranchConditional %86 %87 %88
138-
%88 = OpLabel
114+
OpBranch %69
115+
%69 = OpLabel
116+
OpLoopMerge %70 %72 None
117+
OpBranch %74
118+
%74 = OpLabel
119+
%75 = OpLoad %40 %73
120+
%76 = OpIEqual %42 %43 %75
121+
%77 = OpAll %9 %76
122+
OpSelectionMerge %78 None
123+
OpBranchConditional %77 %70 %78
124+
%78 = OpLabel
125+
%79 = OpCompositeExtract %3 %75 1
126+
%80 = OpIEqual %9 %79 %22
127+
%81 = OpSelect %3 %80 %26 %22
128+
%82 = OpCompositeConstruct %40 %81 %26
129+
%83 = OpISub %40 %75 %82
130+
OpStore %73 %83
139131
OpBranch %71
132+
%71 = OpLabel
133+
%84 = OpLoad %9 %32
134+
%85 = OpLogicalNot %9 %84
135+
OpSelectionMerge %86 None
136+
OpBranchConditional %85 %86 %87
140137
%87 = OpLabel
138+
OpBranch %70
139+
%86 = OpLabel
140+
OpBranch %88
141+
%88 = OpLabel
142+
%90 = OpLoad %4 %29
143+
%91 = OpIAdd %4 %90 %25
144+
%92 = OpLoad %3 %27
145+
%93 = OpLoad %4 %29
146+
%95 = OpAccessChain %64 %23 %92
147+
%96 = OpAtomicCompareExchange %4 %95 %67 %22 %22 %91 %93
148+
%97 = OpIEqual %9 %96 %93
149+
%94 = OpCompositeConstruct %10 %96 %97
150+
%98 = OpCompositeExtract %4 %94 0
151+
OpStore %29 %98
152+
%99 = OpCompositeExtract %9 %94 1
153+
OpStore %32 %99
141154
OpBranch %89
142155
%89 = OpLabel
143-
%91 = OpLoad %4 %29
144-
%92 = OpIAdd %4 %91 %25
145-
%93 = OpLoad %3 %27
146-
%94 = OpLoad %4 %29
147-
%96 = OpAccessChain %64 %23 %93
148-
%97 = OpAtomicCompareExchange %4 %96 %67 %69 %69 %92 %94
149-
%98 = OpIEqual %9 %97 %94
150-
%95 = OpCompositeConstruct %10 %97 %98
151-
%99 = OpCompositeExtract %4 %95 0
152-
OpStore %29 %99
153-
%100 = OpCompositeExtract %9 %95 1
154-
OpStore %32 %100
155-
OpBranch %90
156-
%90 = OpLabel
157-
OpBranch %73
158-
%73 = OpLabel
159-
OpBranch %70
160-
%71 = OpLabel
156+
OpBranch %72
157+
%72 = OpLabel
158+
OpBranch %69
159+
%70 = OpLabel
161160
OpBranch %62
162161
%62 = OpLabel
163162
OpBranch %39
164163
%39 = OpLabel
165-
%101 = OpLoad %3 %27
166-
%102 = OpIAdd %3 %101 %26
167-
OpStore %27 %102
164+
%100 = OpLoad %3 %27
165+
%101 = OpIAdd %3 %100 %26
166+
OpStore %27 %101
168167
OpBranch %36
169168
%37 = OpLabel
170169
OpReturn
171170
OpFunctionEnd
172-
%104 = OpFunction %2 None %20
173-
%103 = OpLabel
174-
%108 = OpVariable %28 Function %22
175-
%109 = OpVariable %110 Function %111
176-
%112 = OpVariable %33 Function %113
177-
%119 = OpVariable %41 Function %45
178-
%144 = OpVariable %41 Function %45
179-
%106 = OpAccessChain %105 %15 %22
171+
%103 = OpFunction %2 None %20
172+
%102 = OpLabel
173+
%107 = OpVariable %28 Function %22
174+
%108 = OpVariable %109 Function %110
175+
%111 = OpVariable %33 Function %112
176+
%118 = OpVariable %41 Function %45
177+
%143 = OpVariable %41 Function %45
178+
%105 = OpAccessChain %104 %15 %22
179+
OpBranch %113
180+
%113 = OpLabel
180181
OpBranch %114
181182
%114 = OpLabel
182-
OpBranch %115
183-
%115 = OpLabel
184-
OpLoopMerge %116 %118 None
185-
OpBranch %120
186-
%120 = OpLabel
187-
%121 = OpLoad %40 %119
188-
%122 = OpIEqual %42 %43 %121
189-
%123 = OpAll %9 %122
190-
OpSelectionMerge %124 None
191-
OpBranchConditional %123 %116 %124
192-
%124 = OpLabel
193-
%125 = OpCompositeExtract %3 %121 1
194-
%126 = OpIEqual %9 %125 %22
195-
%127 = OpSelect %3 %126 %26 %22
196-
%128 = OpCompositeConstruct %40 %127 %26
197-
%129 = OpISub %40 %121 %128
198-
OpStore %119 %129
199-
OpBranch %117
200-
%117 = OpLabel
201-
%130 = OpLoad %3 %108
202-
%131 = OpULessThan %9 %130 %6
203-
OpSelectionMerge %132 None
204-
OpBranchConditional %131 %132 %133
205-
%133 = OpLabel
183+
OpLoopMerge %115 %117 None
184+
OpBranch %119
185+
%119 = OpLabel
186+
%120 = OpLoad %40 %118
187+
%121 = OpIEqual %42 %43 %120
188+
%122 = OpAll %9 %121
189+
OpSelectionMerge %123 None
190+
OpBranchConditional %122 %115 %123
191+
%123 = OpLabel
192+
%124 = OpCompositeExtract %3 %120 1
193+
%125 = OpIEqual %9 %124 %22
194+
%126 = OpSelect %3 %125 %26 %22
195+
%127 = OpCompositeConstruct %40 %126 %26
196+
%128 = OpISub %40 %120 %127
197+
OpStore %118 %128
206198
OpBranch %116
199+
%116 = OpLabel
200+
%129 = OpLoad %3 %107
201+
%130 = OpULessThan %9 %129 %6
202+
OpSelectionMerge %131 None
203+
OpBranchConditional %130 %131 %132
207204
%132 = OpLabel
208-
OpBranch %134
209-
%134 = OpLabel
210-
%136 = OpLoad %3 %108
211-
%138 = OpAccessChain %137 %106 %136
212-
%139 = OpAtomicLoad %7 %138 %67 %69
213-
OpStore %109 %139
214-
OpStore %112 %24
215-
OpBranch %140
216-
%140 = OpLabel
217-
OpLoopMerge %141 %143 None
218-
OpBranch %145
219-
%145 = OpLabel
220-
%146 = OpLoad %40 %144
221-
%147 = OpIEqual %42 %43 %146
222-
%148 = OpAll %9 %147
223-
OpSelectionMerge %149 None
224-
OpBranchConditional %148 %141 %149
225-
%149 = OpLabel
226-
%150 = OpCompositeExtract %3 %146 1
227-
%151 = OpIEqual %9 %150 %22
228-
%152 = OpSelect %3 %151 %26 %22
229-
%153 = OpCompositeConstruct %40 %152 %26
230-
%154 = OpISub %40 %146 %153
231-
OpStore %144 %154
232-
OpBranch %142
233-
%142 = OpLabel
234-
%155 = OpLoad %9 %112
235-
%156 = OpLogicalNot %9 %155
236-
OpSelectionMerge %157 None
237-
OpBranchConditional %156 %157 %158
238-
%158 = OpLabel
205+
OpBranch %115
206+
%131 = OpLabel
207+
OpBranch %133
208+
%133 = OpLabel
209+
%135 = OpLoad %3 %107
210+
%137 = OpAccessChain %136 %105 %135
211+
%138 = OpAtomicLoad %7 %137 %67 %22
212+
OpStore %108 %138
213+
OpStore %111 %24
214+
OpBranch %139
215+
%139 = OpLabel
216+
OpLoopMerge %140 %142 None
217+
OpBranch %144
218+
%144 = OpLabel
219+
%145 = OpLoad %40 %143
220+
%146 = OpIEqual %42 %43 %145
221+
%147 = OpAll %9 %146
222+
OpSelectionMerge %148 None
223+
OpBranchConditional %147 %140 %148
224+
%148 = OpLabel
225+
%149 = OpCompositeExtract %3 %145 1
226+
%150 = OpIEqual %9 %149 %22
227+
%151 = OpSelect %3 %150 %26 %22
228+
%152 = OpCompositeConstruct %40 %151 %26
229+
%153 = OpISub %40 %145 %152
230+
OpStore %143 %153
239231
OpBranch %141
232+
%141 = OpLabel
233+
%154 = OpLoad %9 %111
234+
%155 = OpLogicalNot %9 %154
235+
OpSelectionMerge %156 None
236+
OpBranchConditional %155 %156 %157
240237
%157 = OpLabel
238+
OpBranch %140
239+
%156 = OpLabel
240+
OpBranch %158
241+
%158 = OpLabel
242+
%160 = OpLoad %7 %108
243+
%161 = OpIAdd %7 %160 %106
244+
%162 = OpLoad %3 %107
245+
%163 = OpLoad %7 %108
246+
%165 = OpAccessChain %136 %105 %162
247+
%166 = OpAtomicCompareExchange %7 %165 %67 %22 %22 %161 %163
248+
%167 = OpIEqual %9 %166 %163
249+
%164 = OpCompositeConstruct %11 %166 %167
250+
%168 = OpCompositeExtract %7 %164 0
251+
OpStore %108 %168
252+
%169 = OpCompositeExtract %9 %164 1
253+
OpStore %111 %169
241254
OpBranch %159
242255
%159 = OpLabel
243-
%161 = OpLoad %7 %109
244-
%162 = OpIAdd %7 %161 %107
245-
%163 = OpLoad %3 %108
246-
%164 = OpLoad %7 %109
247-
%166 = OpAccessChain %137 %106 %163
248-
%167 = OpAtomicCompareExchange %7 %166 %67 %69 %69 %162 %164
249-
%168 = OpIEqual %9 %167 %164
250-
%165 = OpCompositeConstruct %11 %167 %168
251-
%169 = OpCompositeExtract %7 %165 0
252-
OpStore %109 %169
253-
%170 = OpCompositeExtract %9 %165 1
254-
OpStore %112 %170
255-
OpBranch %160
256-
%160 = OpLabel
257-
OpBranch %143
258-
%143 = OpLabel
259-
OpBranch %140
260-
%141 = OpLabel
261-
OpBranch %135
262-
%135 = OpLabel
263-
OpBranch %118
264-
%118 = OpLabel
265-
%171 = OpLoad %3 %108
266-
%172 = OpIAdd %3 %171 %26
267-
OpStore %108 %172
268-
OpBranch %115
269-
%116 = OpLabel
256+
OpBranch %142
257+
%142 = OpLabel
258+
OpBranch %139
259+
%140 = OpLabel
260+
OpBranch %134
261+
%134 = OpLabel
262+
OpBranch %117
263+
%117 = OpLabel
264+
%170 = OpLoad %3 %107
265+
%171 = OpIAdd %3 %170 %26
266+
OpStore %107 %171
267+
OpBranch %114
268+
%115 = OpLabel
270269
OpReturn
271270
OpFunctionEnd

0 commit comments

Comments
 (0)