remove bind group id from set bind group scope

and make sure that we use `ResourceErrorIdent` in all relevant inner errors
This commit is contained in:
teoxoy 2024-06-26 13:02:25 +02:00 committed by Teodor Tanasoaia
parent f54b354021
commit 92c8cf415c
7 changed files with 18 additions and 15 deletions

View File

@ -8,7 +8,7 @@ use crate::{
init_tracker::{BufferInitTrackerAction, TextureInitTrackerAction},
resource::{
DestroyedResourceError, MissingBufferUsageError, MissingTextureUsageError, ParentDevice,
Resource, ResourceInfo, ResourceType,
Resource, ResourceErrorIdent, ResourceInfo, ResourceType,
},
resource_log,
snatch::{SnatchGuard, Snatchable},
@ -771,19 +771,21 @@ pub enum BindingResource<'a> {
#[non_exhaustive]
pub enum BindError {
#[error(
"Bind group {group} expects {expected} dynamic offset{s0}. However {actual} dynamic offset{s1} were provided.",
"{bind_group} {group} expects {expected} dynamic offset{s0}. However {actual} dynamic offset{s1} were provided.",
s0 = if *.expected >= 2 { "s" } else { "" },
s1 = if *.actual >= 2 { "s" } else { "" },
)]
MismatchedDynamicOffsetCount {
bind_group: ResourceErrorIdent,
group: u32,
actual: usize,
expected: usize,
},
#[error(
"Dynamic binding index {idx} (targeting bind group {group}, binding {binding}) with value {offset}, does not respect device's requested `{limit_name}` limit: {alignment}"
"Dynamic binding index {idx} (targeting {bind_group} {group}, binding {binding}) with value {offset}, does not respect device's requested `{limit_name}` limit: {alignment}"
)]
UnalignedDynamicBinding {
bind_group: ResourceErrorIdent,
idx: usize,
group: u32,
binding: u32,
@ -792,10 +794,11 @@ pub enum BindError {
limit_name: &'static str,
},
#[error(
"Dynamic binding offset index {idx} with offset {offset} would overrun the buffer bound to bind group {group} -> binding {binding}. \
"Dynamic binding offset index {idx} with offset {offset} would overrun the buffer bound to {bind_group} {group} -> binding {binding}. \
Buffer size is {buffer_size} bytes, the binding binds bytes {binding_range:?}, meaning the maximum the binding can be offset is {maximum_dynamic_offset} bytes",
)]
DynamicBindingOutOfBounds {
bind_group: ResourceErrorIdent,
idx: usize,
group: u32,
binding: u32,
@ -895,6 +898,7 @@ impl<A: HalApi> BindGroup<A> {
) -> Result<(), BindError> {
if self.dynamic_binding_info.len() != offsets.len() {
return Err(BindError::MismatchedDynamicOffsetCount {
bind_group: self.error_ident(),
group: bind_group_index,
expected: self.dynamic_binding_info.len(),
actual: offsets.len(),
@ -911,6 +915,7 @@ impl<A: HalApi> BindGroup<A> {
buffer_binding_type_alignment(&self.device.limits, info.binding_type);
if offset as wgt::BufferAddress % alignment as u64 != 0 {
return Err(BindError::UnalignedDynamicBinding {
bind_group: self.error_ident(),
group: bind_group_index,
binding: info.binding_idx,
idx,
@ -922,6 +927,7 @@ impl<A: HalApi> BindGroup<A> {
if offset as wgt::BufferAddress > info.maximum_dynamic_offset {
return Err(BindError::DynamicBindingOutOfBounds {
bind_group: self.error_ident(),
group: bind_group_index,
binding: info.binding_idx,
idx,

View File

@ -409,7 +409,7 @@ impl RenderBundleEncoder {
num_dynamic_offsets,
bind_group_id,
} => {
let scope = PassErrorScope::SetBindGroup(bind_group_id);
let scope = PassErrorScope::SetBindGroup;
set_bind_group(
&mut state,
&bind_group_guard,

View File

@ -603,7 +603,7 @@ impl Global {
num_dynamic_offsets,
bind_group,
} => {
let scope = PassErrorScope::SetBindGroup(bind_group.as_info().id());
let scope = PassErrorScope::SetBindGroup;
set_bind_group(
&mut state,
cmd_buf,
@ -1041,7 +1041,7 @@ impl Global {
bind_group_id: id::BindGroupId,
offsets: &[DynamicOffset],
) -> Result<(), ComputePassError> {
let scope = PassErrorScope::SetBindGroup(bind_group_id);
let scope = PassErrorScope::SetBindGroup;
let base = pass
.base
.as_mut()

View File

@ -97,7 +97,7 @@ impl ComputeCommand {
num_dynamic_offsets,
bind_group: bind_group_guard.get_owned(bind_group_id).map_err(|_| {
ComputePassError {
scope: PassErrorScope::SetBindGroup(bind_group_id),
scope: PassErrorScope::SetBindGroup,
inner: ComputePassErrorInner::InvalidBindGroupId(bind_group_id),
}
})?,

View File

@ -867,7 +867,7 @@ pub enum PassErrorScope {
#[error("In a pass parameter")]
Pass(Option<id::CommandBufferId>),
#[error("In a set_bind_group command")]
SetBindGroup(id::BindGroupId),
SetBindGroup,
#[error("In a set_pipeline command")]
SetPipelineRender,
#[error("In a set_pipeline command")]
@ -922,9 +922,6 @@ impl PrettyError for PassErrorScope {
Self::Pass(Some(id)) => {
fmt.command_buffer_label(&id);
}
Self::SetBindGroup(id) => {
fmt.bind_group_label(&id);
}
_ => {}
}
}

View File

@ -1530,7 +1530,7 @@ impl Global {
num_dynamic_offsets,
bind_group,
} => {
let scope = PassErrorScope::SetBindGroup(bind_group.as_info().id());
let scope = PassErrorScope::SetBindGroup;
set_bind_group(
&mut state,
&cmd_buf,
@ -2637,7 +2637,7 @@ impl Global {
bind_group_id: id::BindGroupId,
offsets: &[DynamicOffset],
) -> Result<(), RenderPassError> {
let scope = PassErrorScope::SetBindGroup(bind_group_id);
let scope = PassErrorScope::SetBindGroup;
let base = pass
.base
.as_mut()

View File

@ -153,7 +153,7 @@ impl RenderCommand {
num_dynamic_offsets,
bind_group: bind_group_guard.get_owned(bind_group_id).map_err(|_| {
RenderPassError {
scope: PassErrorScope::SetBindGroup(bind_group_id),
scope: PassErrorScope::SetBindGroup,
inner: RenderPassErrorInner::InvalidBindGroup(index),
}
})?,