Skip to content

Commit

Permalink
remove bind group id from set bind group scope
Browse files Browse the repository at this point in the history
and make sure that we use `ResourceErrorIdent` in all relevant inner errors
  • Loading branch information
teoxoy committed Jun 27, 2024
1 parent f54b354 commit 92c8cf4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
14 changes: 10 additions & 4 deletions wgpu-core/src/binding_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/command/compute_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
})?,
Expand Down
5 changes: 1 addition & 4 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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);
}
_ => {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/command/render_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
})?,
Expand Down

0 comments on commit 92c8cf4

Please sign in to comment.