From 459e835250ac919b2b01e27e723497b77d373b0a Mon Sep 17 00:00:00 2001 From: Mikko Lehtonen Date: Sat, 21 Nov 2020 23:39:05 +0200 Subject: [PATCH] Add Ids to PassErrorScope Also makes it pub, and the places it is used. Tweak some error messages. --- wgpu-core/src/command/bundle.rs | 10 +++++----- wgpu-core/src/command/compute.rs | 8 ++++---- wgpu-core/src/command/draw.rs | 2 +- wgpu-core/src/command/mod.rs | 14 ++++++++------ wgpu-core/src/command/render.rs | 12 ++++++------ wgpu-core/src/device/mod.rs | 6 +++--- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index fd7f65a4e..7e22267ea 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -680,7 +680,7 @@ where #[derive(Clone, Debug, Error)] #[error("{scope}")] pub struct RenderBundleError { - scope: PassErrorScope, + pub scope: PassErrorScope, #[source] inner: RenderBundleErrorInner, } @@ -745,7 +745,7 @@ impl Global { num_dynamic_offsets, bind_group_id, } => { - let scope = PassErrorScope::SetBindGroup; + let scope = PassErrorScope::SetBindGroup(bind_group_id); let max_bind_groups = device.limits.max_bind_groups; if (index as u32) >= max_bind_groups { @@ -790,7 +790,7 @@ impl Global { .map_pass_err(scope)?; } RenderCommand::SetPipeline(pipeline_id) => { - let scope = PassErrorScope::SetPipeline; + let scope = PassErrorScope::SetPipelineRender(pipeline_id); if state.pipeline.set_and_check_redundant(pipeline_id) { continue; } @@ -828,7 +828,7 @@ impl Global { offset, size, } => { - let scope = PassErrorScope::SetIndexBuffer; + let scope = PassErrorScope::SetIndexBuffer(buffer_id); let buffer = state .trackers .buffers @@ -849,7 +849,7 @@ impl Global { offset, size, } => { - let scope = PassErrorScope::SetVertexBuffer; + let scope = PassErrorScope::SetVertexBuffer(buffer_id); let buffer = state .trackers .buffers diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 3b164c15a..1ab9df251 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -148,7 +148,7 @@ pub enum ComputePassErrorInner { #[derive(Clone, Debug, Error)] #[error("{scope}")] pub struct ComputePassError { - scope: PassErrorScope, + pub scope: PassErrorScope, #[source] inner: ComputePassErrorInner, } @@ -234,7 +234,7 @@ impl Global { mut base: BasePassRef, ) -> Result<(), ComputePassError> { span!(_guard, INFO, "CommandEncoder::run_compute_pass"); - let scope = PassErrorScope::Pass; + let scope = PassErrorScope::Pass(encoder_id); let hub = B::hub(self); let mut token = Token::root(); @@ -273,7 +273,7 @@ impl Global { num_dynamic_offsets, bind_group_id, } => { - let scope = PassErrorScope::SetBindGroup; + let scope = PassErrorScope::SetBindGroup(bind_group_id); let max_bind_groups = cmd_buf.limits.max_bind_groups; if (index as u32) >= max_bind_groups { @@ -324,7 +324,7 @@ impl Global { } } ComputeCommand::SetPipeline(pipeline_id) => { - let scope = PassErrorScope::SetPipeline; + let scope = PassErrorScope::SetPipelineCompute(pipeline_id); if state.pipeline.set_and_check_redundant(pipeline_id) { continue; diff --git a/wgpu-core/src/command/draw.rs b/wgpu-core/src/command/draw.rs index 9f2ca4d79..30c19fef7 100644 --- a/wgpu-core/src/command/draw.rs +++ b/wgpu-core/src/command/draw.rs @@ -57,7 +57,7 @@ pub enum RenderCommandError { InvalidDynamicOffsetCount { actual: usize, expected: usize }, #[error("render pipeline {0:?} is invalid")] InvalidPipeline(id::RenderPipelineId), - #[error("render pipeline is incompatible, {0}")] + #[error("Render pipeline is incompatible with render pass")] IncompatiblePipeline(#[from] crate::device::RenderPassCompatibilityError), #[error("pipeline is not compatible with the depth-stencil read-only render pass")] IncompatibleReadOnlyDepthStencil, diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 4cf0435dc..523b0ebd2 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -315,21 +315,23 @@ trait MapPassErr { } #[derive(Clone, Copy, Debug, Error)] -enum PassErrorScope { +pub enum PassErrorScope { #[error("In a bundle parameter")] Bundle, #[error("In a pass parameter")] - Pass, + Pass(id::CommandEncoderId), #[error("In a set_bind_group command")] - SetBindGroup, + SetBindGroup(id::BindGroupId), #[error("In a set_pipeline command")] - SetPipeline, + SetPipelineRender(id::RenderPipelineId), + #[error("In a set_pipeline command")] + SetPipelineCompute(id::ComputePipelineId), #[error("In a set_push_constant command")] SetPushConstant, #[error("In a set_vertex_buffer command")] - SetVertexBuffer, + SetVertexBuffer(id::BufferId), #[error("In a set_index_buffer command")] - SetIndexBuffer, + SetIndexBuffer(id::BufferId), #[error("In a set_viewport command")] SetViewport, #[error("In a set_scissor_rect command")] diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 4c7182822..2fe621c17 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -396,7 +396,7 @@ impl From for RenderPassErrorInner { #[derive(Clone, Debug, Error)] #[error("{scope}")] pub struct RenderPassError { - scope: PassErrorScope, + pub scope: PassErrorScope, #[source] inner: RenderPassErrorInner, } @@ -449,7 +449,7 @@ impl Global { depth_stencil_attachment: Option<&DepthStencilAttachmentDescriptor>, ) -> Result<(), RenderPassError> { span!(_guard, INFO, "CommandEncoder::run_render_pass"); - let scope = PassErrorScope::Pass; + let scope = PassErrorScope::Pass(encoder_id); let hub = B::hub(self); let mut token = Token::root(); @@ -1003,7 +1003,7 @@ impl Global { num_dynamic_offsets, bind_group_id, } => { - let scope = PassErrorScope::SetBindGroup; + let scope = PassErrorScope::SetBindGroup(bind_group_id); let max_bind_groups = device.limits.max_bind_groups; if (index as u32) >= max_bind_groups { return Err(RenderCommandError::BindGroupIndexOutOfRange { @@ -1055,7 +1055,7 @@ impl Global { }; } RenderCommand::SetPipeline(pipeline_id) => { - let scope = PassErrorScope::SetPipeline; + let scope = PassErrorScope::SetPipelineRender(pipeline_id); if state.pipeline.set_and_check_redundant(pipeline_id) { continue; } @@ -1197,7 +1197,7 @@ impl Global { offset, size, } => { - let scope = PassErrorScope::SetIndexBuffer; + let scope = PassErrorScope::SetIndexBuffer(buffer_id); let buffer = trackers .buffers .use_extend(&*buffer_guard, buffer_id, (), BufferUse::INDEX) @@ -1236,7 +1236,7 @@ impl Global { offset, size, } => { - let scope = PassErrorScope::SetVertexBuffer; + let scope = PassErrorScope::SetVertexBuffer(buffer_id); let buffer = trackers .buffers .use_extend(&*buffer_guard, buffer_id, (), BufferUse::VERTEX) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 7be7cfb6d..7c7ebe26c 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -117,14 +117,14 @@ pub(crate) struct RenderPassContext { } #[derive(Clone, Debug, Error)] pub enum RenderPassCompatibilityError { - #[error("incompatible color attachment: {0:?} != {1:?}")] + #[error("Incompatible color attachment: {0:?} != {1:?}")] IncompatibleColorAttachment( ArrayVec<[TextureFormat; MAX_COLOR_TARGETS]>, ArrayVec<[TextureFormat; MAX_COLOR_TARGETS]>, ), - #[error("incompatible depth-stencil attachment: {0:?} != {1:?}")] + #[error("Incompatible depth-stencil attachment: {0:?} != {1:?}")] IncompatibleDepthStencilAttachment(Option, Option), - #[error("incompatible sample count: {0:?} != {1:?}")] + #[error("Incompatible sample count: {0:?} != {1:?}")] IncompatibleSampleCount(u8, u8), }