Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Merge #613
Browse files Browse the repository at this point in the history
613: Add more context to errors originating in Passes and Encoders r=kvark a=Kimundi

**Description**
This adds some top-level error context information to indicate wether an error originated in a `{Render,Compute}Pass` or `{Command,RenderBundle}Encoder` to make error messages more clear.

Combined with gfx-rs/wgpu#1018, errors in passes will look like this:
```
wgpu error: Validation error

Caused by:
    In a RenderPass
    In a draw command
    index 3600 extends beyond limit 38
```


Co-authored-by: Marvin Löbel <[email protected]>
  • Loading branch information
bors[bot] and Kimundi authored Nov 11, 2020
2 parents 2edb962 + d4da268 commit 2563f20
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@ impl crate::Context for Context {
wgc::gfx_select!(
encoder.id => global.command_encoder_run_compute_pass(encoder.id, pass)
)
.map_err(|err| err.with_context("In a ComputePass".to_string()))
.unwrap_error_sink(&encoder.error_sink, || ())
}

Expand Down Expand Up @@ -1416,13 +1417,15 @@ impl crate::Context for Context {
) {
let global = &self.0;
wgc::gfx_select!(encoder.id => global.command_encoder_run_render_pass(encoder.id, pass))
.map_err(|err| err.with_context("In a RenderPass".to_string()))
.unwrap_error_sink(&encoder.error_sink, || ())
}

fn command_encoder_finish(&self, encoder: &Self::CommandEncoderId) -> Self::CommandBufferId {
let desc = wgt::CommandBufferDescriptor::default();
let global = &self.0;
wgc::gfx_select!(encoder.id => global.command_encoder_finish(encoder.id, &desc))
.map_err(|err| err.with_context("In a CommandEncoder".to_string()))
.unwrap_error_sink(
&encoder.error_sink,
|| wgc::gfx_select!( encoder.id => global.command_buffer_error(PhantomData)),
Expand All @@ -1432,8 +1435,8 @@ impl crate::Context for Context {
fn command_encoder_insert_debug_marker(&self, encoder: &Self::CommandEncoderId, label: &str) {
let global = &self.0;
wgc::gfx_select!(encoder.id => global.command_encoder_insert_debug_marker(encoder.id, &label))
.map_err(|err| err.with_context("In CommandEncoder::insert_debug_marker".to_string()))
.unwrap_error_sink(&encoder.error_sink, ||())
.map_err(|err| err.with_context("In CommandEncoder::insert_debug_marker".to_string()))
.unwrap_error_sink(&encoder.error_sink, ||())
}
fn command_encoder_push_debug_group(&self, encoder: &Self::CommandEncoderId, label: &str) {
let global = &self.0;
Expand Down Expand Up @@ -1461,6 +1464,7 @@ impl crate::Context for Context {
},
PhantomData
))
.map_err(|err| err.with_context("In a RenderBundleEncoder".to_string()))
.unwrap_pretty()
}

Expand Down

0 comments on commit 2563f20

Please sign in to comment.