From add09fb33ce3c6362f21be6eb977221f5bd282d3 Mon Sep 17 00:00:00 2001 From: Mikko Lehtonen Date: Sat, 21 Nov 2020 23:42:17 +0200 Subject: [PATCH] [rs] Handle PassErrorScope Ids --- wgpu/Cargo.toml | 4 +-- wgpu/src/backend/error.rs | 66 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 81a1b13464..f1e33eb986 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -26,14 +26,14 @@ vulkan-portability = ["wgc/gfx-backend-vulkan", "gfx-backend-vulkan"] package = "wgpu-core" #version = "0.6" git = "https://github.com/gfx-rs/wgpu" -rev = "9d35aea08eb5cdd5ad408e8a13838a7beab11ad3" +rev = "feac96d3151f08188bdd270fdf021117944c01b0" features = ["raw-window-handle"] [dependencies.wgt] package = "wgpu-types" #version = "0.6" git = "https://github.com/gfx-rs/wgpu" -rev = "9d35aea08eb5cdd5ad408e8a13838a7beab11ad3" +rev = "feac96d3151f08188bdd270fdf021117944c01b0" [dependencies] arrayvec = "0.5" diff --git a/wgpu/src/backend/error.rs b/wgpu/src/backend/error.rs index 0158964f85..bb662f3da4 100644 --- a/wgpu/src/backend/error.rs +++ b/wgpu/src/backend/error.rs @@ -37,9 +37,18 @@ fn fmt_pretty_any(error: &(dyn Error + 'static), context: &Context) -> String { if let Some(pretty_err) = error.downcast_ref::() { return pretty_err.fmt_pretty(context); } + if let Some(pretty_err) = error.downcast_ref::() { + return pretty_err.fmt_pretty(context); + } if let Some(pretty_err) = error.downcast_ref::() { return pretty_err.fmt_pretty(context); } + if let Some(pretty_err) = error.downcast_ref::() { + return pretty_err.fmt_pretty(context); + } + if let Some(pretty_err) = error.downcast_ref::() { + return pretty_err.fmt_pretty(context); + } if let Some(pretty_err) = error.downcast_ref::() { return pretty_err.fmt_pretty(context); } @@ -175,6 +184,29 @@ impl PrettyError for wgc::command::RenderPassErrorInner { } } +impl PrettyError for wgc::command::RenderPassError { + fn fmt_pretty(&self, context: &Context) -> String { + // This error is wrapper for the inner error, + // but the scope has useful labels + format_error_line(self) + &self.scope.fmt_pretty(context) + } +} + +impl PrettyError for wgc::command::ComputePassError { + fn fmt_pretty(&self, context: &Context) -> String { + // This error is wrapper for the inner error, + // but the scope has useful labels + format_error_line(self) + &self.scope.fmt_pretty(context) + } +} +impl PrettyError for wgc::command::RenderBundleError { + fn fmt_pretty(&self, context: &Context) -> String { + // This error is wrapper for the inner error, + // but the scope has useful labels + format_error_line(self) + &self.scope.fmt_pretty(context) + } +} + impl PrettyError for wgc::command::ComputePassErrorInner { fn fmt_pretty(&self, context: &Context) -> String { let global = context.global(); @@ -236,3 +268,37 @@ impl PrettyError for wgc::command::TransferError { ret } } + +impl PrettyError for wgc::command::PassErrorScope { + fn fmt_pretty(&self, context: &Context) -> String { + // This error is not in the error chain, only notes are needed + let global = context.global(); + match *self { + Self::Pass(id) => { + let name = wgc::gfx_select!(id => global.command_buffer_label(id)); + format_label_line("command buffer", &name) + } + Self::SetBindGroup(id) => { + let name = wgc::gfx_select!(id => global.bind_group_label(id)); + format_label_line("bind group", &name) + } + Self::SetPipelineRender(id) => { + let name = wgc::gfx_select!(id => global.render_pipeline_label(id)); + format_label_line("render pipeline", &name) + } + Self::SetPipelineCompute(id) => { + let name = wgc::gfx_select!(id => global.compute_pipeline_label(id)); + format_label_line("compute pipeline", &name) + } + Self::SetVertexBuffer(id) => { + let name = wgc::gfx_select!(id => global.buffer_label(id)); + format_label_line("buffer", &name) + } + Self::SetIndexBuffer(id) => { + let name = wgc::gfx_select!(id => global.buffer_label(id)); + format_label_line("buffer", &name) + } + _ => String::new(), + } + } +}