From d2218398ff5dfa4f8906db074bf0a01e37f0242a Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:41:09 +0200 Subject: [PATCH] take buffer lookup out of `BufferBindGroupState.add_single` --- wgpu-core/src/device/resource.rs | 9 +++++---- wgpu-core/src/track/buffer.rs | 11 +---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 333316122..cb27ed9d4 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -1923,10 +1923,11 @@ impl Device { )); } - let buffer = used - .buffers - .add_single(storage, bb.buffer_id, internal_use) - .ok_or(Error::InvalidBuffer(bb.buffer_id))?; + let buffer = storage + .get(bb.buffer_id) + .map_err(|_| Error::InvalidBuffer(bb.buffer_id))?; + + used.buffers.add_single(buffer, internal_use); buffer.same_device(self)?; diff --git a/wgpu-core/src/track/buffer.rs b/wgpu-core/src/track/buffer.rs index fb51ee03b..d11cc2c3b 100644 --- a/wgpu-core/src/track/buffer.rs +++ b/wgpu-core/src/track/buffer.rs @@ -90,18 +90,9 @@ impl BufferBindGroupState { } /// Adds the given resource with the given state. - pub fn add_single<'a>( - &self, - storage: &'a Storage>, - id: BufferId, - state: BufferUses, - ) -> Option<&'a Arc>> { - let buffer = storage.get(id).ok()?; - + pub fn add_single(&self, buffer: &Arc>, state: BufferUses) { let mut buffers = self.buffers.lock(); buffers.push((buffer.clone(), state)); - - Some(buffer) } }