mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
remove device_maintain_ids
This commit is contained in:
parent
c6761bdd7a
commit
140495006e
@ -1,9 +1,5 @@
|
|||||||
/*! This is a player library for WebGPU traces.
|
/*! This is a player library for WebGPU traces.
|
||||||
*
|
*
|
||||||
* # Notes
|
|
||||||
* - we call device_maintain_ids() before creating any refcounted resource,
|
|
||||||
* which is basically everything except for BGL and shader modules,
|
|
||||||
* so that we don't accidentally try to use the same ID.
|
|
||||||
!*/
|
!*/
|
||||||
#![cfg(not(target_arch = "wasm32"))]
|
#![cfg(not(target_arch = "wasm32"))]
|
||||||
#![warn(unsafe_op_in_unsafe_fn)]
|
#![warn(unsafe_op_in_unsafe_fn)]
|
||||||
@ -153,7 +149,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
panic!("Unexpected Surface action: winit feature is not enabled")
|
panic!("Unexpected Surface action: winit feature is not enabled")
|
||||||
}
|
}
|
||||||
Action::CreateBuffer(id, desc) => {
|
Action::CreateBuffer(id, desc) => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let (_, error) = self.device_create_buffer::<A>(device, &desc, Some(id));
|
let (_, error) = self.device_create_buffer::<A>(device, &desc, Some(id));
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
@ -166,7 +161,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
self.buffer_drop::<A>(id, true);
|
self.buffer_drop::<A>(id, true);
|
||||||
}
|
}
|
||||||
Action::CreateTexture(id, desc) => {
|
Action::CreateTexture(id, desc) => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let (_, error) = self.device_create_texture::<A>(device, &desc, Some(id));
|
let (_, error) = self.device_create_texture::<A>(device, &desc, Some(id));
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
@ -183,7 +177,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
parent_id,
|
parent_id,
|
||||||
desc,
|
desc,
|
||||||
} => {
|
} => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let (_, error) = self.texture_create_view::<A>(parent_id, &desc, Some(id));
|
let (_, error) = self.texture_create_view::<A>(parent_id, &desc, Some(id));
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
@ -193,7 +186,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
self.texture_view_drop::<A>(id, true).unwrap();
|
self.texture_view_drop::<A>(id, true).unwrap();
|
||||||
}
|
}
|
||||||
Action::CreateSampler(id, desc) => {
|
Action::CreateSampler(id, desc) => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let (_, error) = self.device_create_sampler::<A>(device, &desc, Some(id));
|
let (_, error) = self.device_create_sampler::<A>(device, &desc, Some(id));
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
@ -203,7 +195,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
self.sampler_drop::<A>(id);
|
self.sampler_drop::<A>(id);
|
||||||
}
|
}
|
||||||
Action::GetSurfaceTexture { id, parent_id } => {
|
Action::GetSurfaceTexture { id, parent_id } => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
self.surface_get_current_texture::<A>(parent_id, Some(id))
|
self.surface_get_current_texture::<A>(parent_id, Some(id))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.texture_id
|
.texture_id
|
||||||
@ -219,7 +210,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
self.bind_group_layout_drop::<A>(id);
|
self.bind_group_layout_drop::<A>(id);
|
||||||
}
|
}
|
||||||
Action::CreatePipelineLayout(id, desc) => {
|
Action::CreatePipelineLayout(id, desc) => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let (_, error) = self.device_create_pipeline_layout::<A>(device, &desc, Some(id));
|
let (_, error) = self.device_create_pipeline_layout::<A>(device, &desc, Some(id));
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
@ -229,7 +219,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
self.pipeline_layout_drop::<A>(id);
|
self.pipeline_layout_drop::<A>(id);
|
||||||
}
|
}
|
||||||
Action::CreateBindGroup(id, desc) => {
|
Action::CreateBindGroup(id, desc) => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let (_, error) = self.device_create_bind_group::<A>(device, &desc, Some(id));
|
let (_, error) = self.device_create_bind_group::<A>(device, &desc, Some(id));
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
@ -263,7 +252,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
desc,
|
desc,
|
||||||
implicit_context,
|
implicit_context,
|
||||||
} => {
|
} => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let implicit_ids =
|
let implicit_ids =
|
||||||
implicit_context
|
implicit_context
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -285,7 +273,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
desc,
|
desc,
|
||||||
implicit_context,
|
implicit_context,
|
||||||
} => {
|
} => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let implicit_ids =
|
let implicit_ids =
|
||||||
implicit_context
|
implicit_context
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -324,7 +311,6 @@ impl GlobalPlay for wgc::global::Global {
|
|||||||
self.render_bundle_drop::<A>(id);
|
self.render_bundle_drop::<A>(id);
|
||||||
}
|
}
|
||||||
Action::CreateQuerySet { id, desc } => {
|
Action::CreateQuerySet { id, desc } => {
|
||||||
self.device_maintain_ids::<A>(device).unwrap();
|
|
||||||
let (_, error) = self.device_create_query_set::<A>(device, &desc, Some(id));
|
let (_, error) = self.device_create_query_set::<A>(device, &desc, Some(id));
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
|
@ -2247,23 +2247,6 @@ impl Global {
|
|||||||
Some(error)
|
Some(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "replay")]
|
|
||||||
/// Only triage suspected resource IDs. This helps us to avoid ID collisions
|
|
||||||
/// upon creating new resources when re-playing a trace.
|
|
||||||
pub fn device_maintain_ids<A: HalApi>(&self, device_id: DeviceId) -> Result<(), DeviceError> {
|
|
||||||
let hub = A::hub(self);
|
|
||||||
|
|
||||||
let device = hub
|
|
||||||
.devices
|
|
||||||
.get(device_id)
|
|
||||||
.map_err(|_| DeviceError::InvalidDeviceId)?;
|
|
||||||
|
|
||||||
device.check_is_valid()?;
|
|
||||||
|
|
||||||
device.lock_life().triage_suspected(&device.trackers);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check `device_id` for freeable resources and completed buffer mappings.
|
/// Check `device_id` for freeable resources and completed buffer mappings.
|
||||||
///
|
///
|
||||||
/// Return `queue_empty` indicating whether there are more queue submissions still in flight.
|
/// Return `queue_empty` indicating whether there are more queue submissions still in flight.
|
||||||
|
@ -76,11 +76,6 @@ use super::{
|
|||||||
/// This means that you must inspect function calls made while a lock is held
|
/// This means that you must inspect function calls made while a lock is held
|
||||||
/// to see what locks the callee may try to acquire.
|
/// to see what locks the callee may try to acquire.
|
||||||
///
|
///
|
||||||
/// As far as this point:
|
|
||||||
/// device_maintain_ids locks Device::lifetime_tracker, and calls...
|
|
||||||
/// triage_suspected locks Device::trackers, and calls...
|
|
||||||
/// Registry::unregister locks Registry::storage
|
|
||||||
///
|
|
||||||
/// Important:
|
/// Important:
|
||||||
/// When locking pending_writes please check that trackers is not locked
|
/// When locking pending_writes please check that trackers is not locked
|
||||||
/// trackers should be locked only when needed for the shortest time possible
|
/// trackers should be locked only when needed for the shortest time possible
|
||||||
|
Loading…
Reference in New Issue
Block a user