From f609e8205582e1fa9ce8d02e601e24272fe9537b Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:30:43 +0200 Subject: [PATCH] extract `pop_debug_group` from `compute_pass_end_impl` --- wgpu-core/src/command/compute.rs | 36 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index c78f63939..de088f243 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -644,21 +644,7 @@ impl Global { } ArcComputeCommand::PopDebugGroup => { let scope = PassErrorScope::PopDebugGroup; - - if state.debug_scope_depth == 0 { - return Err(ComputePassErrorInner::InvalidPopDebugGroup) - .map_pass_err(scope); - } - state.debug_scope_depth -= 1; - if !state - .device - .instance_flags - .contains(wgt::InstanceFlags::DISCARD_HAL_LABELS) - { - unsafe { - raw.end_debug_marker(); - } - } + pop_debug_group(&mut state, raw).map_pass_err(scope)?; } ArcComputeCommand::InsertDebugMarker { color: _, len } => { if !state @@ -1023,6 +1009,26 @@ fn push_debug_group( state.string_offset += len; } +fn pop_debug_group( + state: &mut State, + raw: &mut A::CommandEncoder, +) -> Result<(), ComputePassErrorInner> { + if state.debug_scope_depth == 0 { + return Err(ComputePassErrorInner::InvalidPopDebugGroup); + } + state.debug_scope_depth -= 1; + if !state + .device + .instance_flags + .contains(wgt::InstanceFlags::DISCARD_HAL_LABELS) + { + unsafe { + raw.end_debug_marker(); + } + } + Ok(()) +} + // Recording a compute pass. impl Global { pub fn compute_pass_set_bind_group(