From 2ea314e97893c95a3cfbf817cb856192486da18d Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:24:29 +0200 Subject: [PATCH] [wgpu-core] remove `Arc` around `StagingBuffer` --- wgpu-core/src/device/queue.rs | 10 ++-------- wgpu-core/src/hub.rs | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 6139a5f3b..235d02a1b 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -334,8 +334,6 @@ pub enum QueueWriteError { DestroyedResource(#[from] DestroyedResourceError), #[error(transparent)] InvalidResource(#[from] InvalidResourceError), - #[error("StagingBufferId {0:?} is invalid")] - InvalidStagingBufferId(id::StagingBufferId), } #[derive(Clone, Debug, Error)] @@ -442,7 +440,7 @@ impl Global { let ptr = unsafe { staging_buffer.ptr() }; let fid = hub.staging_buffers.prepare(queue_id.backend(), id_in); - let id = fid.assign(Arc::new(staging_buffer)); + let id = fid.assign(staging_buffer); resource_log!("Queue::create_staging_buffer {id:?}"); Ok((id, ptr)) @@ -462,11 +460,7 @@ impl Global { let device = &queue.device; - let staging_buffer = hub - .staging_buffers - .unregister(staging_buffer_id) - .and_then(Arc::into_inner) - .ok_or_else(|| QueueWriteError::InvalidStagingBufferId(staging_buffer_id))?; + let staging_buffer = hub.staging_buffers.strict_unregister(staging_buffer_id); let mut pending_writes = device.pending_writes.lock(); diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index d0b333f02..b3afac80c 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -176,7 +176,7 @@ pub struct Hub { pub(crate) pipeline_caches: Registry>, pub(crate) query_sets: Registry>, pub(crate) buffers: Registry>, - pub(crate) staging_buffers: Registry>, + pub(crate) staging_buffers: Registry, pub(crate) textures: Registry>, pub(crate) texture_views: Registry>, pub(crate) samplers: Registry>,