mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
use ResourceErrorIdent in a few buffer error variants
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::{
|
||||
device::{
|
||||
bgl, Device, DeviceError, MissingDownlevelFlags, MissingFeatures, SHADER_STAGE_COUNT,
|
||||
},
|
||||
error::{ErrorFormatter, PrettyError},
|
||||
error::PrettyError,
|
||||
hal_api::HalApi,
|
||||
id::{BindGroupLayoutId, BufferId, SamplerId, TextureViewId},
|
||||
init_tracker::{BufferInitTrackerAction, TextureInitTrackerAction},
|
||||
@@ -94,20 +94,20 @@ pub enum CreateBindGroupError {
|
||||
BindingArrayLengthMismatch { actual: usize, expected: usize },
|
||||
#[error("Array binding provided zero elements")]
|
||||
BindingArrayZeroLength,
|
||||
#[error("Bound buffer range {range:?} does not fit in buffer of size {size}")]
|
||||
#[error("The bound range {range:?} of {buffer} overflows its size ({size})")]
|
||||
BindingRangeTooLarge {
|
||||
buffer: BufferId,
|
||||
buffer: ResourceErrorIdent,
|
||||
range: Range<wgt::BufferAddress>,
|
||||
size: u64,
|
||||
},
|
||||
#[error("Buffer binding size {actual} is less than minimum {min}")]
|
||||
#[error("Binding size {actual} of {buffer} is less than minimum {min}")]
|
||||
BindingSizeTooSmall {
|
||||
buffer: BufferId,
|
||||
buffer: ResourceErrorIdent,
|
||||
actual: u64,
|
||||
min: u64,
|
||||
},
|
||||
#[error("Buffer binding size is zero")]
|
||||
BindingZeroSize(BufferId),
|
||||
#[error("{0} binding size is zero")]
|
||||
BindingZeroSize(ResourceErrorIdent),
|
||||
#[error("Number of bindings in bind group descriptor ({actual}) does not match the number of bindings defined in the bind group layout ({expected})")]
|
||||
BindingsNumMismatch { actual: usize, expected: usize },
|
||||
#[error("Binding {0} is used at least twice in the descriptor")]
|
||||
@@ -185,23 +185,7 @@ pub enum CreateBindGroupError {
|
||||
ResourceUsageCompatibility(#[from] ResourceUsageCompatibilityError),
|
||||
}
|
||||
|
||||
impl PrettyError for CreateBindGroupError {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
match *self {
|
||||
Self::BindingZeroSize(id) => {
|
||||
fmt.buffer_label(&id);
|
||||
}
|
||||
Self::BindingRangeTooLarge { buffer, .. } => {
|
||||
fmt.buffer_label(&buffer);
|
||||
}
|
||||
Self::BindingSizeTooSmall { buffer, .. } => {
|
||||
fmt.buffer_label(&buffer);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
impl PrettyError for CreateBindGroupError {}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
pub enum BindingZone {
|
||||
|
||||
@@ -1919,7 +1919,7 @@ impl<A: HalApi> Device<A> {
|
||||
let end = bb.offset + size.get();
|
||||
if end > buffer.size {
|
||||
return Err(Error::BindingRangeTooLarge {
|
||||
buffer: bb.buffer_id,
|
||||
buffer: buffer.error_ident(),
|
||||
range: bb.offset..end,
|
||||
size: buffer.size,
|
||||
});
|
||||
@@ -1929,7 +1929,7 @@ impl<A: HalApi> Device<A> {
|
||||
None => {
|
||||
if buffer.size < bb.offset {
|
||||
return Err(Error::BindingRangeTooLarge {
|
||||
buffer: bb.buffer_id,
|
||||
buffer: buffer.error_ident(),
|
||||
range: bb.offset..bb.offset,
|
||||
size: buffer.size,
|
||||
});
|
||||
@@ -1961,14 +1961,14 @@ impl<A: HalApi> Device<A> {
|
||||
let min_size = non_zero.get();
|
||||
if min_size > bind_size {
|
||||
return Err(Error::BindingSizeTooSmall {
|
||||
buffer: bb.buffer_id,
|
||||
buffer: buffer.error_ident(),
|
||||
actual: bind_size,
|
||||
min: min_size,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
let late_size =
|
||||
wgt::BufferSize::new(bind_size).ok_or(Error::BindingZeroSize(bb.buffer_id))?;
|
||||
let late_size = wgt::BufferSize::new(bind_size)
|
||||
.ok_or_else(|| Error::BindingZeroSize(buffer.error_ident()))?;
|
||||
late_buffer_binding_sizes.insert(binding, late_size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user