mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-24 15:54:00 +00:00
refactor: make Snatchable::snatch
take _guard
by &mut _
This commit is contained in:
parent
7ac533a312
commit
38a13b94f0
@ -363,7 +363,7 @@ impl Device {
|
||||
let Some(view) = view.upgrade() else {
|
||||
continue;
|
||||
};
|
||||
let Some(raw_view) = view.raw.snatch(self.snatchable_lock.write()) else {
|
||||
let Some(raw_view) = view.raw.snatch(&mut self.snatchable_lock.write()) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -377,7 +377,8 @@ impl Device {
|
||||
let Some(bind_group) = bind_group.upgrade() else {
|
||||
continue;
|
||||
};
|
||||
let Some(raw_bind_group) = bind_group.raw.snatch(self.snatchable_lock.write())
|
||||
let Some(raw_bind_group) =
|
||||
bind_group.raw.snatch(&mut self.snatchable_lock.write())
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
@ -288,8 +288,11 @@ impl Global {
|
||||
.textures
|
||||
.remove(texture.tracker_index());
|
||||
let suf = surface.raw(device.backend()).unwrap();
|
||||
let exclusive_snatch_guard = device.snatchable_lock.write();
|
||||
match texture.inner.snatch(exclusive_snatch_guard).unwrap() {
|
||||
match texture
|
||||
.inner
|
||||
.snatch(&mut device.snatchable_lock.write())
|
||||
.unwrap()
|
||||
{
|
||||
resource::TextureInner::Surface { raw, parent_id } => {
|
||||
if surface_id != parent_id {
|
||||
log::error!("Presented frame is from a different surface");
|
||||
@ -359,8 +362,11 @@ impl Global {
|
||||
.textures
|
||||
.remove(texture.tracker_index());
|
||||
let suf = surface.raw(device.backend());
|
||||
let exclusive_snatch_guard = device.snatchable_lock.write();
|
||||
match texture.inner.snatch(exclusive_snatch_guard).unwrap() {
|
||||
match texture
|
||||
.inner
|
||||
.snatch(&mut device.snatchable_lock.write())
|
||||
.unwrap()
|
||||
{
|
||||
resource::TextureInner::Surface { raw, parent_id } => {
|
||||
if surface_id == parent_id {
|
||||
unsafe { suf.unwrap().discard_texture(raw) };
|
||||
|
@ -737,8 +737,7 @@ impl Buffer {
|
||||
let device = &self.device;
|
||||
|
||||
let temp = {
|
||||
let snatch_guard = device.snatchable_lock.write();
|
||||
let raw = match self.raw.snatch(snatch_guard) {
|
||||
let raw = match self.raw.snatch(&mut device.snatchable_lock.write()) {
|
||||
Some(raw) => raw,
|
||||
None => {
|
||||
return Err(DestroyError::AlreadyDestroyed);
|
||||
@ -1185,8 +1184,7 @@ impl Texture {
|
||||
let device = &self.device;
|
||||
|
||||
let temp = {
|
||||
let snatch_guard = device.snatchable_lock.write();
|
||||
let raw = match self.inner.snatch(snatch_guard) {
|
||||
let raw = match self.inner.snatch(&mut device.snatchable_lock.write()) {
|
||||
Some(TextureInner::Native { raw }) => raw,
|
||||
Some(TextureInner::Surface { .. }) => {
|
||||
return Ok(());
|
||||
|
@ -38,7 +38,7 @@ impl<T> Snatchable<T> {
|
||||
}
|
||||
|
||||
/// Take the value. Requires a the snatchable lock's write guard.
|
||||
pub fn snatch(&self, _guard: ExclusiveSnatchGuard) -> Option<T> {
|
||||
pub fn snatch(&self, _guard: &mut ExclusiveSnatchGuard) -> Option<T> {
|
||||
unsafe { (*self.value.get()).take() }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user