From f9f55b7d510963b7308359dbbf2a7b91c5351ee5 Mon Sep 17 00:00:00 2001 From: AdrianEddy Date: Thu, 30 Jul 2026 12:07:11 +0200 Subject: [PATCH] fix(core): drop `PendingSubmission`'s guards in reverse acquisition order (#9960) Co-authored-by: Erich Gubler --- CHANGELOG.md | 1 + wgpu-core/src/device/queue.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00e5a2f76..703aa8386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Bottom level categories: - Zero-initialize padding (if any) at the end of a buffer allocation. This was application-visible in rare cases on Vulkan when a shader read beyond the valid range of a vertex buffer. By @andyleiserson in [#9791](https://github.com/gfx-rs/wgpu/pull/9791). - Fix required immediate slots calculation and remove `naga::valid::FunctionInfo::immediate_slots_used`. By @beicause in [#9725](https://github.com/gfx-rs/wgpu/pull/9725). +- Fix `PendingSubmission` releasing its lock guards out of stacking order, which tripped `--cfg wgpu_validate_locks` on any submission. By @AdrianEddy in [#9960](https://github.com/gfx-rs/wgpu/pull/9960). #### naga diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index e29290898..1e74b3198 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -638,8 +638,10 @@ impl WebGpuError for QueueSubmitError { /// [`submit`]: `PendingSubmission::submit` pub(crate) struct PendingSubmission<'a> { queue: &'a Queue, - snatch_guard: SnatchGuard<'a>, + // NOTE: Guards must be declared in reverse of acquisition order, so `wgpu_validate_locks` + // succeeds. command_index_guard: RwLockWriteGuard<'a, CommandIndices>, + snatch_guard: SnatchGuard<'a>, // Command buffers to be executed, along with trackers for the resources they use. pub executions: Vec, // Surface textures referenced by command buffers in this submission. These need to be