diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 04e43a143..b7d63f7eb 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -280,7 +280,7 @@ impl Global { .trackers .lock() .buffers - .insert_single(resource, buffer_use); + .insert_single(&resource, buffer_use); return (id, None); }; @@ -593,7 +593,7 @@ impl Global { .trackers .lock() .textures - .insert_single(resource, hal::TextureUses::UNINITIALIZED); + .insert_single(&resource, hal::TextureUses::UNINITIALIZED); return (id, None); }; @@ -666,7 +666,7 @@ impl Global { .trackers .lock() .textures - .insert_single(resource, hal::TextureUses::UNINITIALIZED); + .insert_single(&resource, hal::TextureUses::UNINITIALIZED); return (id, None); }; @@ -716,7 +716,7 @@ impl Global { .trackers .lock() .buffers - .insert_single(buffer, hal::BufferUses::empty()); + .insert_single(&buffer, hal::BufferUses::empty()); return (id, None); }; diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index a49332a3b..b13c4d6cd 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -244,7 +244,7 @@ impl Global { let mut trackers = device.trackers.lock(); trackers .textures - .insert_single(resource, hal::TextureUses::UNINITIALIZED); + .insert_single(&resource, hal::TextureUses::UNINITIALIZED); } if present.acquired_texture.is_some() { diff --git a/wgpu-core/src/track/buffer.rs b/wgpu-core/src/track/buffer.rs index 6c0d1714f..8a899ef85 100644 --- a/wgpu-core/src/track/buffer.rs +++ b/wgpu-core/src/track/buffer.rs @@ -5,7 +5,7 @@ * one subresource, they have no selector. !*/ -use std::{borrow::Cow, marker::PhantomData, sync::Arc}; +use std::{marker::PhantomData, sync::Arc}; use super::{PendingTransition, ResourceTracker, TrackerIndex}; use crate::{ @@ -171,9 +171,7 @@ impl BufferUsageScope { index as _, index, BufferStateProvider::Direct { state }, - ResourceMetadataProvider::Direct { - resource: Cow::Borrowed(resource), - }, + ResourceMetadataProvider::Direct { resource }, )? }; } @@ -247,9 +245,7 @@ impl BufferUsageScope { index as _, index, BufferStateProvider::Direct { state: new_state }, - ResourceMetadataProvider::Direct { - resource: Cow::Owned(buffer.clone()), - }, + ResourceMetadataProvider::Direct { resource: buffer }, )?; } @@ -387,7 +383,7 @@ impl BufferTracker { /// /// If the ID is higher than the length of internal vectors, /// the vectors will be extended. A call to set_size is not needed. - pub fn insert_single(&mut self, resource: Arc>, state: BufferUses) { + pub fn insert_single(&mut self, resource: &Arc>, state: BufferUses) { let index = resource.tracker_index().as_usize(); self.allow_index(index); @@ -408,9 +404,7 @@ impl BufferTracker { index, BufferStateProvider::Direct { state }, None, - ResourceMetadataProvider::Direct { - resource: Cow::Owned(resource), - }, + ResourceMetadataProvider::Direct { resource }, ) } } @@ -441,9 +435,7 @@ impl BufferTracker { index, BufferStateProvider::Direct { state }, None, - ResourceMetadataProvider::Direct { - resource: Cow::Owned(buffer.clone()), - }, + ResourceMetadataProvider::Direct { resource: buffer }, &mut self.temp, ) }; diff --git a/wgpu-core/src/track/metadata.rs b/wgpu-core/src/track/metadata.rs index d412fc71a..cc9e29783 100644 --- a/wgpu-core/src/track/metadata.rs +++ b/wgpu-core/src/track/metadata.rs @@ -1,7 +1,7 @@ //! The `ResourceMetadata` type. use bit_vec::BitVec; -use std::{borrow::Cow, mem, sync::Arc}; +use std::{mem, sync::Arc}; use wgt::strict_assert; /// A set of resources, holding a `Arc` and epoch for each member. @@ -176,7 +176,7 @@ impl ResourceMetadata { /// trackers can get new resource metadata from. pub(super) enum ResourceMetadataProvider<'a, T> { /// Comes directly from explicit values. - Direct { resource: Cow<'a, Arc> }, + Direct { resource: &'a Arc }, /// Comes from another metadata tracker. Indirect { metadata: &'a ResourceMetadata }, } diff --git a/wgpu-core/src/track/texture.rs b/wgpu-core/src/track/texture.rs index 4884195d4..742af97c5 100644 --- a/wgpu-core/src/track/texture.rs +++ b/wgpu-core/src/track/texture.rs @@ -40,7 +40,7 @@ use naga::FastHashMap; use wgt::{strict_assert, strict_assert_eq}; -use std::{borrow::Cow, iter, marker::PhantomData, ops::Range, sync::Arc, vec::Drain}; +use std::{iter, marker::PhantomData, ops::Range, sync::Arc, vec::Drain}; /// Specifies a particular set of subresources in a texture. #[derive(Clone, Debug, PartialEq, Eq)] @@ -382,9 +382,7 @@ impl TextureUsageScope { &mut self.metadata, index, TextureStateProvider::from_option(selector, new_state), - ResourceMetadataProvider::Direct { - resource: Cow::Borrowed(texture), - }, + ResourceMetadataProvider::Direct { resource: texture }, )? }; @@ -537,7 +535,7 @@ impl TextureTracker { /// /// If the ID is higher than the length of internal vectors, /// the vectors will be extended. A call to set_size is not needed. - pub fn insert_single(&mut self, resource: Arc>, usage: TextureUses) { + pub fn insert_single(&mut self, resource: &Arc>, usage: TextureUses) { let index = resource.tracker_index().as_usize(); self.allow_index(index); @@ -559,9 +557,7 @@ impl TextureTracker { index, TextureStateProvider::KnownSingle { state: usage }, None, - ResourceMetadataProvider::Direct { - resource: Cow::Owned(resource), - }, + ResourceMetadataProvider::Direct { resource }, ) }; } @@ -597,9 +593,7 @@ impl TextureTracker { state: new_state, }, None, - ResourceMetadataProvider::Direct { - resource: Cow::Owned(texture.clone()), - }, + ResourceMetadataProvider::Direct { resource: texture }, &mut self.temp, ) }