diff --git a/wgpu-core/src/track/buffer.rs b/wgpu-core/src/track/buffer.rs index 38ffe1fc5..f098b1d59 100644 --- a/wgpu-core/src/track/buffer.rs +++ b/wgpu-core/src/track/buffer.rs @@ -768,7 +768,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_buffer( - unsafe { metadata_provider.get(index).info.id() }, + unsafe { metadata_provider.get(index) }, *current_state, new_state, )); diff --git a/wgpu-core/src/track/mod.rs b/wgpu-core/src/track/mod.rs index 6e501a285..794c3905b 100644 --- a/wgpu-core/src/track/mod.rs +++ b/wgpu-core/src/track/mod.rs @@ -104,9 +104,9 @@ mod texture; use crate::{ binding_model, command, conv, hal_api::HalApi, - id, lock::{rank, Mutex, RwLock}, - pipeline, resource, + pipeline, + resource::{self, Resource, ResourceErrorIdent}, snatch::SnatchGuard, }; @@ -338,16 +338,18 @@ fn skip_barrier(old_state: T, new_state: T) -> bool { old_state == new_state && old_state.all_ordered() } -#[derive(Clone, Debug, Error, Eq, PartialEq)] +#[derive(Clone, Debug, Error)] pub enum UsageConflict { - #[error("Attempted to use buffer with {invalid_use}.")] + #[error("Attempted to use {res} with {invalid_use}.")] Buffer { - id: id::BufferId, + res: ResourceErrorIdent, invalid_use: InvalidUse, }, - #[error("Attempted to use a texture (mips {mip_levels:?} layers {array_layers:?}) with {invalid_use}.")] + #[error( + "Attempted to use {res} (mips {mip_levels:?} layers {array_layers:?}) with {invalid_use}." + )] Texture { - id: id::TextureId, + res: ResourceErrorIdent, mip_levels: ops::Range, array_layers: ops::Range, invalid_use: InvalidUse, @@ -355,13 +357,13 @@ pub enum UsageConflict { } impl UsageConflict { - fn from_buffer( - id: id::BufferId, + fn from_buffer( + buffer: &resource::Buffer, current_state: hal::BufferUses, new_state: hal::BufferUses, ) -> Self { Self::Buffer { - id, + res: buffer.error_ident(), invalid_use: InvalidUse { current_state, new_state, @@ -369,14 +371,14 @@ impl UsageConflict { } } - fn from_texture( - id: id::TextureId, + fn from_texture( + texture: &resource::Texture, selector: TextureSelector, current_state: hal::TextureUses, new_state: hal::TextureUses, ) -> Self { Self::Texture { - id, + res: texture.error_ident(), mip_levels: selector.mips, array_layers: selector.layers, invalid_use: InvalidUse { @@ -390,14 +392,6 @@ impl UsageConflict { impl crate::error::PrettyError for UsageConflict { fn fmt_pretty(&self, fmt: &mut crate::error::ErrorFormatter) { fmt.error(self); - match *self { - Self::Buffer { id, .. } => { - fmt.buffer_label(&id); - } - Self::Texture { id, .. } => { - fmt.texture_label(&id); - } - } } } diff --git a/wgpu-core/src/track/texture.rs b/wgpu-core/src/track/texture.rs index c3cc82fd1..ffd9fd52e 100644 --- a/wgpu-core/src/track/texture.rs +++ b/wgpu-core/src/track/texture.rs @@ -1096,7 +1096,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - unsafe { metadata_provider.get(index).info.id() }, + unsafe { metadata_provider.get(index) }, texture_selector.clone(), *current_simple, new_simple, @@ -1123,7 +1123,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - unsafe { metadata_provider.get(index).info.id() }, + unsafe { metadata_provider.get(index) }, selector, *current_simple, new_state, @@ -1164,7 +1164,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - unsafe { metadata_provider.get(index).info.id() }, + unsafe { metadata_provider.get(index) }, TextureSelector { mips: mip_id..mip_id + 1, layers: layers.clone(), @@ -1205,7 +1205,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - unsafe { metadata_provider.get(index).info.id() }, + unsafe { metadata_provider.get(index) }, TextureSelector { mips: mip_id..mip_id + 1, layers: layers.clone(),