Skip to content

Commit

Permalink
Fix deadlock between snatchable_lock and trackers in Queue::write_tex…
Browse files Browse the repository at this point in the history
…ture (#7004)

* Fix deadlock between snatchable_lock and trackers in Queue::write_texture

* Fix another deadlock in write_texture between pending_writes and snatchable_lock.
  • Loading branch information
metamuffin authored Jan 27, 2025
1 parent df54acc commit 33e8df0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924).
- Fix `wgpu` not building with `--no-default-features` on when targeting `wasm32-unknown-unknown`. By @wumpf in [#6946](https://github.com/gfx-rs/wgpu/pull/6946).
- Fix `CopyExternalImageDestInfo` not exported on `wgpu`. By @wumpf in [#6962](https://github.com/gfx-rs/wgpu/pull/6962).
- Fix drop order in `Surface`. By @ed-2100 in [#6997](https://github.com/gfx-rs/wgpu/pull/6997)
- Fix a possible deadlock within `Queue::write_texture`. By @metamuffin in [#7004](https://github.com/gfx-rs/wgpu/pull/7004)

#### Vulkan

Expand Down
6 changes: 3 additions & 3 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ impl Queue {
.map_err(TransferError::from)?;
}

let snatch_guard = self.device.snatchable_lock.read();

let mut pending_writes = self.pending_writes.lock();
let encoder = pending_writes.activate();

Expand Down Expand Up @@ -732,7 +734,7 @@ impl Queue {
&mut trackers.textures,
&self.device.alignments,
self.device.zero_buffer.as_ref(),
&self.device.snatchable_lock.read(),
&snatch_guard,
)
.map_err(QueueWriteError::from)?;
}
Expand All @@ -742,8 +744,6 @@ impl Queue {
}
}

let snatch_guard = self.device.snatchable_lock.read();

let dst_raw = dst.try_raw(&snatch_guard)?;

let (block_width, block_height) = dst.desc.format.block_dimensions();
Expand Down

0 comments on commit 33e8df0

Please sign in to comment.