diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index e46c0acec8..a56860c208 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -386,13 +386,13 @@ impl Global { &self, pass: &mut ComputePass, ) -> Result<(), ComputePassError> { + let scope = PassErrorScope::Pass; + let cmd_buf = pass .parent .as_ref() .ok_or(ComputePassErrorInner::InvalidParentEncoder) - .map_pass_err(PassErrorScope::Pass(None))?; - - let scope = PassErrorScope::Pass(Some(cmd_buf.as_info().id())); + .map_pass_err(scope)?; cmd_buf.unlock_encoder().map_pass_err(scope)?; @@ -413,7 +413,7 @@ impl Global { timestamp_writes: Option<&PassTimestampWrites>, ) -> Result<(), ComputePassError> { let hub = A::hub(self); - let scope = PassErrorScope::PassEncoder(encoder_id); + let scope = PassErrorScope::Pass; let cmd_buf = CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(scope)?; @@ -473,7 +473,7 @@ impl Global { mut timestamp_writes: Option>, ) -> Result<(), ComputePassError> { profiling::scope!("CommandEncoder::run_compute_pass"); - let pass_scope = PassErrorScope::Pass(Some(cmd_buf.as_info().id())); + let pass_scope = PassErrorScope::Pass; let device = &cmd_buf.device; device.check_is_valid().map_pass_err(pass_scope)?; diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index e1f1a5ceef..07e19e5583 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -882,12 +882,12 @@ pub enum DrawKind { #[derive(Clone, Copy, Debug, Error)] pub enum PassErrorScope { + // TODO: Extract out the 2 error variants below so that we can always + // include the ResourceErrorIdent of the pass around all inner errors #[error("In a bundle parameter")] Bundle, #[error("In a pass parameter")] - PassEncoder(id::CommandEncoderId), // Needed only for ending pass via tracing. - #[error("In a pass parameter")] - Pass(Option), + Pass, #[error("In a set_bind_group command")] SetBindGroup, #[error("In a set_pipeline command")] @@ -934,17 +934,4 @@ pub enum PassErrorScope { InsertDebugMarker, } -impl PrettyError for PassErrorScope { - fn fmt_pretty(&self, fmt: &mut ErrorFormatter) { - // This error is not in the error chain, only notes are needed - match *self { - Self::PassEncoder(id) => { - fmt.command_buffer_label(&id.into_command_buffer_id()); - } - Self::Pass(Some(id)) => { - fmt.command_buffer_label(&id); - } - _ => {} - } - } -} +impl PrettyError for PassErrorScope {} diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 1de7af12f7..6056e956b3 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -281,11 +281,6 @@ impl RenderPass { } } - #[inline] - pub fn parent_id(&self) -> Option { - self.parent.as_ref().map(|cmd_buf| cmd_buf.as_info().id()) - } - #[inline] pub fn label(&self) -> Option<&str> { self.base.as_ref().and_then(|base| base.label.as_deref()) @@ -305,7 +300,7 @@ impl RenderPass { impl fmt::Debug for RenderPass { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RenderPass") - .field("encoder_id", &self.parent_id()) + .field("label", &self.label()) .field("color_attachments", &self.color_attachments) .field("depth_stencil_target", &self.depth_stencil_attachment) .field( @@ -1506,7 +1501,8 @@ impl Global { timestamp_writes: Option<&PassTimestampWrites>, occlusion_query_set: Option, ) -> Result<(), RenderPassError> { - let pass_scope = PassErrorScope::PassEncoder(encoder_id); + let pass_scope = PassErrorScope::Pass; + #[cfg(feature = "trace")] { let hub = A::hub(self); @@ -1569,7 +1565,7 @@ impl Global { if let Some(err) = encoder_error { Err(RenderPassError { - scope: PassErrorScope::PassEncoder(encoder_id), + scope: pass_scope, inner: err.into(), }) } else { @@ -1582,7 +1578,7 @@ impl Global { &self, pass: &mut RenderPass, ) -> Result<(), RenderPassError> { - let pass_scope = PassErrorScope::Pass(pass.parent_id()); + let pass_scope = PassErrorScope::Pass; let base = pass .base diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 829762eb26..1683e1c7f6 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -103,6 +103,7 @@ impl ResourceInfo { } } + #[allow(dead_code)] pub(crate) fn id(&self) -> Id { self.id.unwrap() }