take buffer lookup out of BufferBindGroupState.add_single

This commit is contained in:
teoxoy 2024-06-20 00:41:09 +02:00 committed by Teodor Tanasoaia
parent 6a181fa634
commit d2218398ff
2 changed files with 6 additions and 14 deletions

View File

@ -1923,10 +1923,11 @@ impl<A: HalApi> Device<A> {
)); ));
} }
let buffer = used let buffer = storage
.buffers .get(bb.buffer_id)
.add_single(storage, bb.buffer_id, internal_use) .map_err(|_| Error::InvalidBuffer(bb.buffer_id))?;
.ok_or(Error::InvalidBuffer(bb.buffer_id))?;
used.buffers.add_single(buffer, internal_use);
buffer.same_device(self)?; buffer.same_device(self)?;

View File

@ -90,18 +90,9 @@ impl<A: HalApi> BufferBindGroupState<A> {
} }
/// Adds the given resource with the given state. /// Adds the given resource with the given state.
pub fn add_single<'a>( pub fn add_single(&self, buffer: &Arc<Buffer<A>>, state: BufferUses) {
&self,
storage: &'a Storage<Buffer<A>>,
id: BufferId,
state: BufferUses,
) -> Option<&'a Arc<Buffer<A>>> {
let buffer = storage.get(id).ok()?;
let mut buffers = self.buffers.lock(); let mut buffers = self.buffers.lock();
buffers.push((buffer.clone(), state)); buffers.push((buffer.clone(), state));
Some(buffer)
} }
} }