[wgpu-core] rename .strict_unregister() & .strict_remove() to .remove()

This commit is contained in:
teoxoy 2024-09-07 02:23:23 +02:00 committed by Teodor Tanasoaia
parent ac74f36590
commit c182d3f24f
6 changed files with 25 additions and 27 deletions

View File

@ -283,7 +283,7 @@ impl Global {
let hub = &self.hub;
let buffer = match hub.buffers.strict_unregister(buffer_id).get() {
let buffer = match hub.buffers.remove(buffer_id).get() {
Ok(buffer) => buffer,
Err(_) => {
return;
@ -439,7 +439,7 @@ impl Global {
let hub = &self.hub;
let _texture = hub.textures.strict_unregister(texture_id);
let _texture = hub.textures.remove(texture_id);
#[cfg(feature = "trace")]
if let Ok(texture) = _texture.get() {
if let Some(t) = texture.device.trace.lock().as_mut() {
@ -502,7 +502,7 @@ impl Global {
let hub = &self.hub;
let _view = hub.texture_views.strict_unregister(texture_view_id);
let _view = hub.texture_views.remove(texture_view_id);
#[cfg(feature = "trace")]
if let Ok(view) = _view.get() {
@ -553,7 +553,7 @@ impl Global {
let hub = &self.hub;
let _sampler = hub.samplers.strict_unregister(sampler_id);
let _sampler = hub.samplers.remove(sampler_id);
#[cfg(feature = "trace")]
if let Ok(sampler) = _sampler.get() {
@ -625,9 +625,7 @@ impl Global {
let hub = &self.hub;
let _layout = hub
.bind_group_layouts
.strict_unregister(bind_group_layout_id);
let _layout = hub.bind_group_layouts.remove(bind_group_layout_id);
#[cfg(feature = "trace")]
if let Ok(layout) = _layout.get() {
@ -698,7 +696,7 @@ impl Global {
let hub = &self.hub;
let _layout = hub.pipeline_layouts.strict_unregister(pipeline_layout_id);
let _layout = hub.pipeline_layouts.remove(pipeline_layout_id);
#[cfg(feature = "trace")]
if let Ok(layout) = _layout.get() {
@ -842,7 +840,7 @@ impl Global {
let hub = &self.hub;
let _bind_group = hub.bind_groups.strict_unregister(bind_group_id);
let _bind_group = hub.bind_groups.remove(bind_group_id);
#[cfg(feature = "trace")]
if let Ok(_bind_group) = _bind_group.get() {
@ -989,7 +987,7 @@ impl Global {
let hub = &self.hub;
let _shader_module = hub.shader_modules.strict_unregister(shader_module_id);
let _shader_module = hub.shader_modules.remove(shader_module_id);
#[cfg(feature = "trace")]
if let Ok(shader_module) = _shader_module.get() {
@ -1038,7 +1036,7 @@ impl Global {
let _cmd_buf = hub
.command_buffers
.strict_unregister(command_encoder_id.into_command_buffer_id());
.remove(command_encoder_id.into_command_buffer_id());
}
pub fn command_buffer_drop(&self, command_buffer_id: id::CommandBufferId) {
@ -1116,7 +1114,7 @@ impl Global {
let hub = &self.hub;
let _bundle = hub.render_bundles.strict_unregister(render_bundle_id);
let _bundle = hub.render_bundles.remove(render_bundle_id);
#[cfg(feature = "trace")]
if let Ok(bundle) = _bundle.get() {
@ -1169,7 +1167,7 @@ impl Global {
let hub = &self.hub;
let _query_set = hub.query_sets.strict_unregister(query_set_id);
let _query_set = hub.query_sets.remove(query_set_id);
#[cfg(feature = "trace")]
if let Ok(query_set) = _query_set.get() {
@ -1406,7 +1404,7 @@ impl Global {
let hub = &self.hub;
let _pipeline = hub.render_pipelines.strict_unregister(render_pipeline_id);
let _pipeline = hub.render_pipelines.remove(render_pipeline_id);
#[cfg(feature = "trace")]
if let Ok(pipeline) = _pipeline.get() {
@ -1592,7 +1590,7 @@ impl Global {
let hub = &self.hub;
let _pipeline = hub.compute_pipelines.strict_unregister(compute_pipeline_id);
let _pipeline = hub.compute_pipelines.remove(compute_pipeline_id);
#[cfg(feature = "trace")]
if let Ok(pipeline) = _pipeline.get() {
@ -1652,7 +1650,7 @@ impl Global {
let hub = &self.hub;
let _cache = hub.pipeline_caches.strict_unregister(pipeline_cache_id);
let _cache = hub.pipeline_caches.remove(pipeline_cache_id);
#[cfg(feature = "trace")]
if let Ok(cache) = _cache.get() {
@ -2089,7 +2087,7 @@ impl Global {
profiling::scope!("Device::drop");
api_log!("Device::drop {device_id:?}");
let device = self.hub.devices.strict_unregister(device_id);
let device = self.hub.devices.remove(device_id);
let device_lost_closure = device.lock_life().device_lost_closure.take();
if let Some(closure) = device_lost_closure {
closure.call(DeviceLostReason::Dropped, String::from("Device dropped."));
@ -2168,7 +2166,7 @@ impl Global {
profiling::scope!("Queue::drop");
api_log!("Queue::drop {queue_id:?}");
self.hub.queues.strict_unregister(queue_id);
self.hub.queues.remove(queue_id);
}
pub fn buffer_map_async(

View File

@ -465,7 +465,7 @@ impl Global {
let device = &queue.device;
let staging_buffer = hub.staging_buffers.strict_unregister(staging_buffer_id);
let staging_buffer = hub.staging_buffers.remove(staging_buffer_id);
let mut pending_writes = device.pending_writes.lock();

View File

@ -593,7 +593,7 @@ impl Global {
api_log!("Surface::drop {id:?}");
let surface = self.surfaces.strict_unregister(id);
let surface = self.surfaces.remove(id);
let surface =
Arc::into_inner(surface).expect("Surface cannot be destroyed because is still in use");
@ -885,7 +885,7 @@ impl Global {
profiling::scope!("Adapter::drop");
api_log!("Adapter::drop {adapter_id:?}");
self.hub.adapters.strict_unregister(adapter_id);
self.hub.adapters.remove(adapter_id);
}
}

View File

@ -280,7 +280,7 @@ impl Global {
// The texture ID got added to the device tracker by `submit()`,
// and now we are moving it away.
let texture = hub.textures.strict_unregister(texture_id).get();
let texture = hub.textures.remove(texture_id).get();
if let Ok(texture) = texture {
device
.trackers
@ -350,7 +350,7 @@ impl Global {
// The texture ID got added to the device tracker by `submit()`,
// and now we are moving it away.
let texture = hub.textures.strict_unregister(texture_id).get();
let texture = hub.textures.remove(texture_id).get();
if let Ok(texture) = texture {
device

View File

@ -100,8 +100,8 @@ impl<T: StorageItem> Registry<T> {
pub(crate) fn write<'a>(&'a self) -> RwLockWriteGuard<'a, Storage<T>> {
self.storage.write()
}
pub(crate) fn strict_unregister(&self, id: Id<T::Marker>) -> T {
let value = self.storage.write().strict_remove(id);
pub(crate) fn remove(&self, id: Id<T::Marker>) -> T {
let value = self.storage.write().remove(id);
// This needs to happen *after* removing it from the storage, to maintain the
// invariant that `self.identity` only contains ids which are actually available
// See https://github.com/gfx-rs/wgpu/issues/5372
@ -161,7 +161,7 @@ mod tests {
let value = Arc::new(TestData);
let new_id = registry.prepare(wgt::Backend::Empty, None);
let id = new_id.assign(value);
registry.strict_unregister(id);
registry.remove(id);
}
});
}

View File

@ -96,7 +96,7 @@ where
self.insert_impl(index as usize, epoch, Element::Occupied(value, epoch))
}
pub(crate) fn strict_remove(&mut self, id: Id<T::Marker>) -> T {
pub(crate) fn remove(&mut self, id: Id<T::Marker>) -> T {
let (index, epoch, _) = id.unzip();
match std::mem::replace(&mut self.map[index as usize], Element::Vacant) {
Element::Occupied(value, storage_epoch) => {