remove IDs from UsageConflict variants

This commit is contained in:
teoxoy 2024-06-20 13:46:13 +02:00 committed by Teodor Tanasoaia
parent 123a59ae7b
commit 5f6848eddf
3 changed files with 20 additions and 26 deletions

View File

@ -768,7 +768,7 @@ unsafe fn merge<A: HalApi>(
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,
));

View File

@ -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<T: ResourceUses>(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<hal::BufferUses>,
},
#[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<u32>,
array_layers: ops::Range<u32>,
invalid_use: InvalidUse<hal::TextureUses>,
@ -355,13 +357,13 @@ pub enum UsageConflict {
}
impl UsageConflict {
fn from_buffer(
id: id::BufferId,
fn from_buffer<A: HalApi>(
buffer: &resource::Buffer<A>,
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<A: HalApi>(
texture: &resource::Texture<A>,
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);
}
}
}
}

View File

@ -1096,7 +1096,7 @@ unsafe fn merge<A: HalApi>(
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<A: HalApi>(
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<A: HalApi>(
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<A: HalApi>(
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(),