diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 3443bcf782..68300706a1 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -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 BindGroup { ) -> 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 BindGroup { 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 BindGroup { 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, diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 1e08bac6f9..5f913fd791 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -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, diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 91aed2421d..73b8838073 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -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() diff --git a/wgpu-core/src/command/compute_command.rs b/wgpu-core/src/command/compute_command.rs index 0a37f3d781..eb8ce9fa34 100644 --- a/wgpu-core/src/command/compute_command.rs +++ b/wgpu-core/src/command/compute_command.rs @@ -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), } })?, diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 7737ec2bea..844691c7c2 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -867,7 +867,7 @@ pub enum PassErrorScope { #[error("In a pass parameter")] Pass(Option), #[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); - } _ => {} } } diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 11312c39d1..133bdad26e 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -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() diff --git a/wgpu-core/src/command/render_command.rs b/wgpu-core/src/command/render_command.rs index 9ef929c118..3140b78e68 100644 --- a/wgpu-core/src/command/render_command.rs +++ b/wgpu-core/src/command/render_command.rs @@ -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), } })?,