change Storage.force_replace to take an Arc<T>

This commit is contained in:
teoxoy 2024-07-01 12:43:26 +02:00 committed by Teodor Tanasoaia
parent 896418c740
commit 1f6ac35e83
3 changed files with 7 additions and 6 deletions

View File

@ -2590,7 +2590,7 @@ impl<A: HalApi> Device<A> {
for (bgl_id, map) in ids.group_ids.iter_mut().zip(derived_group_layouts) {
let bgl = self.create_bind_group_layout(&None, map, bgl::Origin::Derived)?;
bgl_registry.force_replace(*bgl_id, bgl);
bgl_registry.force_replace(*bgl_id, Arc::new(bgl));
}
let layout_desc = binding_model::PipelineLayoutDescriptor {
@ -2599,8 +2599,9 @@ impl<A: HalApi> Device<A> {
push_constant_ranges: Cow::Borrowed(&[]), //TODO?
};
let layout = self.create_pipeline_layout(&layout_desc, bgl_registry)?;
pipeline_layout_registry.force_replace(ids.root_id, layout);
Ok(pipeline_layout_registry.get(ids.root_id).unwrap())
let layout = Arc::new(layout);
pipeline_layout_registry.force_replace(ids.root_id, layout.clone());
Ok(layout)
}
pub(crate) fn create_compute_pipeline(

View File

@ -129,7 +129,7 @@ impl<T: StorageItem> Registry<T> {
self.identity.free(id);
storage.remove(id)
}
pub(crate) fn force_replace(&self, id: Id<T::Marker>, value: T) {
pub(crate) fn force_replace(&self, id: Id<T::Marker>, value: Arc<T>) {
let mut storage = self.storage.write();
storage.force_replace(id, value)
}

View File

@ -164,10 +164,10 @@ where
}
}
pub(crate) fn force_replace(&mut self, id: Id<T::Marker>, value: T) {
pub(crate) fn force_replace(&mut self, id: Id<T::Marker>, value: Arc<T>) {
log::trace!("User is replacing {}{:?}", T::TYPE, id);
let (index, epoch, _) = id.unzip();
self.map[index as usize] = Element::Occupied(Arc::new(value), epoch);
self.map[index as usize] = Element::Occupied(value, epoch);
}
pub(crate) fn remove(&mut self, id: Id<T::Marker>) -> Option<Arc<T>> {