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(