From 6c56613045a8ddef933f5a5d2bb379bbaea141a6 Mon Sep 17 00:00:00 2001 From: Mikko Lehtonen Date: Tue, 12 Jan 2021 22:23:17 +0200 Subject: [PATCH] Merge PassErrorScope::Draw* and Dispatch* variants --- wgpu-core/src/command/bundle.rs | 24 ++++++++++++++++++++---- wgpu-core/src/command/compute.rs | 10 ++++++++-- wgpu-core/src/command/mod.rs | 23 +++++++++++------------ wgpu-core/src/command/render.rs | 28 ++++++++++++++++++---------- 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 35e8e9d63..6481e7bd4 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -312,7 +312,11 @@ impl RenderBundleEncoder { first_vertex, first_instance, } => { - let scope = PassErrorScope::Draw(state.pipeline.last_state); + let scope = PassErrorScope::Draw { + indexed: false, + indirect: false, + pipeline: state.pipeline.last_state, + }; let vertex_limits = state.vertex_limits(); let last_vertex = first_vertex + vertex_count; if last_vertex > vertex_limits.vertex_limit { @@ -343,7 +347,11 @@ impl RenderBundleEncoder { base_vertex: _, first_instance, } => { - let scope = PassErrorScope::DrawIndexed(state.pipeline.last_state); + let scope = PassErrorScope::Draw { + indexed: true, + indirect: false, + pipeline: state.pipeline.last_state, + }; //TODO: validate that base_vertex + max_index() is within the provided range let vertex_limits = state.vertex_limits(); let index_limit = state.index.limit(); @@ -375,7 +383,11 @@ impl RenderBundleEncoder { count: None, indexed: false, } => { - let scope = PassErrorScope::DrawIndirect(state.pipeline.last_state); + let scope = PassErrorScope::Draw { + indexed: false, + indirect: true, + pipeline: state.pipeline.last_state, + }; let buffer = state .trackers .buffers @@ -394,7 +406,11 @@ impl RenderBundleEncoder { count: None, indexed: true, } => { - let scope = PassErrorScope::DrawIndexedIndirect(state.pipeline.last_state); + let scope = PassErrorScope::Draw { + indexed: true, + indirect: true, + pipeline: state.pipeline.last_state, + }; let buffer = state .trackers .buffers diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 9d0f10c5c..fb1e8fddb 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -442,7 +442,10 @@ impl Global { unsafe { raw.push_compute_constants(&pipeline_layout.raw, offset, data_slice) } } ComputeCommand::Dispatch(groups) => { - let scope = PassErrorScope::Dispatch(state.pipeline.last_state); + let scope = PassErrorScope::Dispatch { + indirect: false, + pipeline: state.pipeline.last_state, + }; state.is_ready().map_pass_err(scope)?; state @@ -459,7 +462,10 @@ impl Global { } } ComputeCommand::DispatchIndirect { buffer_id, offset } => { - let scope = PassErrorScope::DispatchIndirect(state.pipeline.last_state); + let scope = PassErrorScope::Dispatch { + indirect: true, + pipeline: state.pipeline.last_state, + }; state.is_ready().map_pass_err(scope)?; diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 28df01c36..b9cfbde0c 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -361,20 +361,19 @@ pub enum PassErrorScope { SetViewport, #[error("In a set_scissor_rect command")] SetScissorRect, - #[error("In a draw command")] - Draw(Option), - #[error("In a draw_indexed command")] - DrawIndexed(Option), - #[error("In a draw_indirect command")] - DrawIndirect(Option), - #[error("In a draw_indexed_indirect command")] - DrawIndexedIndirect(Option), + #[error("In a draw command, indexed:{indexed} indirect:{indirect}")] + Draw { + indexed: bool, + indirect: bool, + pipeline: Option, + }, #[error("In a execute_bundle command")] ExecuteBundle, - #[error("In a dispatch command")] - Dispatch(Option), - #[error("In a dispatch_indirect command")] - DispatchIndirect(Option), + #[error("In a dispatch command, indirect:{indirect}")] + Dispatch { + indirect: bool, + pipeline: Option, + }, #[error("In a pop_debug_group command")] PopDebugGroup, } diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 4e8b658e6..30fc7e962 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1543,7 +1543,11 @@ impl Global { first_vertex, first_instance, } => { - let scope = PassErrorScope::Draw(state.pipeline.last_state); + let scope = PassErrorScope::Draw { + indexed: false, + indirect: false, + pipeline: state.pipeline.last_state, + }; state.is_ready().map_pass_err(scope)?; let last_vertex = first_vertex + vertex_count; let vertex_limit = state.vertex.vertex_limit; @@ -1580,7 +1584,11 @@ impl Global { base_vertex, first_instance, } => { - let scope = PassErrorScope::DrawIndexed(state.pipeline.last_state); + let scope = PassErrorScope::Draw { + indexed: true, + indirect: false, + pipeline: state.pipeline.last_state, + }; state.is_ready().map_pass_err(scope)?; //TODO: validate that base_vertex + max_index() is within the provided range @@ -1618,10 +1626,10 @@ impl Global { count, indexed, } => { - let scope = if indexed { - PassErrorScope::DrawIndexedIndirect(state.pipeline.last_state) - } else { - PassErrorScope::DrawIndirect(state.pipeline.last_state) + let scope = PassErrorScope::Draw { + indexed, + indirect: true, + pipeline: state.pipeline.last_state, }; state.is_ready().map_pass_err(scope)?; @@ -1694,10 +1702,10 @@ impl Global { max_count, indexed, } => { - let scope = if indexed { - PassErrorScope::DrawIndexedIndirect(state.pipeline.last_state) - } else { - PassErrorScope::DrawIndirect(state.pipeline.last_state) + let scope = PassErrorScope::Draw { + indexed, + indirect: true, + pipeline: state.pipeline.last_state, }; state.is_ready().map_pass_err(scope)?;