[rs] Handle PassErrorScope Ids

This commit is contained in:
Mikko Lehtonen 2020-11-21 23:42:17 +02:00
parent dc61d7fb22
commit add09fb33c
2 changed files with 68 additions and 2 deletions

View File

@ -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"

View File

@ -37,9 +37,18 @@ fn fmt_pretty_any(error: &(dyn Error + 'static), context: &Context) -> String {
if let Some(pretty_err) = error.downcast_ref::<wgc::command::RenderPassErrorInner>() {
return pretty_err.fmt_pretty(context);
}
if let Some(pretty_err) = error.downcast_ref::<wgc::command::RenderPassError>() {
return pretty_err.fmt_pretty(context);
}
if let Some(pretty_err) = error.downcast_ref::<wgc::command::ComputePassErrorInner>() {
return pretty_err.fmt_pretty(context);
}
if let Some(pretty_err) = error.downcast_ref::<wgc::command::ComputePassError>() {
return pretty_err.fmt_pretty(context);
}
if let Some(pretty_err) = error.downcast_ref::<wgc::command::RenderBundleError>() {
return pretty_err.fmt_pretty(context);
}
if let Some(pretty_err) = error.downcast_ref::<wgc::command::TransferError>() {
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(),
}
}
}