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) } }