diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index f039f6b5b..7f340e922 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -336,6 +336,7 @@ impl Device { pub(crate) fn lock_life<'this, 'token: 'this>( &'this self, + //TODO: fix this - the token has to be borrowed for the lock token: &mut Token<'token, Self>, ) -> MutexGuard<'this, life::LifetimeTracker> { Self::lock_life_internal(&self.life_tracker, token) @@ -1282,19 +1283,20 @@ impl Global { let (device_guard, mut token) = hub.devices.read(&mut token); let device = &device_guard[device_id]; - let mut life_lock = device_guard[device_id].lock_life(&mut token); - - if device.pending_writes.dst_buffers.contains(&buffer_id) { - life_lock.future_suspected_buffers.push(Stored { - value: id::Valid(buffer_id), - ref_count, - }); - } else { - drop(ref_count); - life_lock - .suspected_resources - .buffers - .push(id::Valid(buffer_id)); + { + let mut life_lock = device.lock_life(&mut token); + if device.pending_writes.dst_buffers.contains(&buffer_id) { + life_lock.future_suspected_buffers.push(Stored { + value: id::Valid(buffer_id), + ref_count, + }); + } else { + drop(ref_count); + life_lock + .suspected_resources + .buffers + .push(id::Valid(buffer_id)); + } } if wait { @@ -1429,19 +1431,20 @@ impl Global { let (device_guard, mut token) = hub.devices.read(&mut token); let device = &device_guard[device_id]; - let mut life_lock = device_guard[device_id].lock_life(&mut token); - - if device.pending_writes.dst_textures.contains(&texture_id) { - life_lock.future_suspected_textures.push(Stored { - value: id::Valid(texture_id), - ref_count, - }); - } else { - drop(ref_count); - life_lock - .suspected_resources - .textures - .push(id::Valid(texture_id)); + { + let mut life_lock = device.lock_life(&mut token); + if device.pending_writes.dst_textures.contains(&texture_id) { + life_lock.future_suspected_textures.push(Stored { + value: id::Valid(texture_id), + ref_count, + }); + } else { + drop(ref_count); + life_lock + .suspected_resources + .textures + .push(id::Valid(texture_id)); + } } if wait { diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index d64174702..dc78864d9 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -3,9 +3,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::id; +use std::ops::Range; #[cfg(feature = "trace")] -use std::io::Write as _; -use std::{borrow::Cow, ops::Range}; +use std::{borrow::Cow, io::Write as _}; //TODO: consider a readable Id that doesn't include the backend