remove PassErrorScope::PassEncoder and id arg of PassErrorScope::Pass

This commit is contained in:
teoxoy 2024-06-26 13:21:40 +02:00 committed by Teodor Tanasoaia
parent d26aef554e
commit 66777cc80d
4 changed files with 15 additions and 31 deletions

View File

@ -386,13 +386,13 @@ impl Global {
&self,
pass: &mut ComputePass<A>,
) -> 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<ArcPassTimestampWrites<A>>,
) -> 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)?;

View File

@ -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<id::CommandBufferId>),
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 {}

View File

@ -281,11 +281,6 @@ impl<A: HalApi> RenderPass<A> {
}
}
#[inline]
pub fn parent_id(&self) -> Option<id::CommandBufferId> {
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<A: HalApi> RenderPass<A> {
impl<A: HalApi> fmt::Debug for RenderPass<A> {
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<id::QuerySetId>,
) -> 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<A>,
) -> Result<(), RenderPassError> {
let pass_scope = PassErrorScope::Pass(pass.parent_id());
let pass_scope = PassErrorScope::Pass;
let base = pass
.base

View File

@ -103,6 +103,7 @@ impl<T: Resource> ResourceInfo<T> {
}
}
#[allow(dead_code)]
pub(crate) fn id(&self) -> Id<T::Marker> {
self.id.unwrap()
}