From c72af7b57f5ef547d79b9774a5832ce17c48faab Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:28:46 +0200 Subject: [PATCH] extract `push_debug_group` from `compute_pass_end_impl` --- wgpu-core/src/command/compute.rs | 37 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 7c3789ec8f..c78f639394 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -640,21 +640,7 @@ impl Global { .map_pass_err(scope)?; } ArcComputeCommand::PushDebugGroup { color: _, len } => { - state.debug_scope_depth += 1; - if !state - .device - .instance_flags - .contains(wgt::InstanceFlags::DISCARD_HAL_LABELS) - { - let label = str::from_utf8( - &base.string_data[state.string_offset..state.string_offset + len], - ) - .unwrap(); - unsafe { - raw.begin_debug_marker(label); - } - } - state.string_offset += len; + push_debug_group(&mut state, raw, &base.string_data, len); } ArcComputeCommand::PopDebugGroup => { let scope = PassErrorScope::PopDebugGroup; @@ -1016,6 +1002,27 @@ fn dispatch_indirect( Ok(()) } +fn push_debug_group( + state: &mut State, + raw: &mut A::CommandEncoder, + string_data: &[u8], + len: usize, +) { + state.debug_scope_depth += 1; + if !state + .device + .instance_flags + .contains(wgt::InstanceFlags::DISCARD_HAL_LABELS) + { + let label = + str::from_utf8(&string_data[state.string_offset..state.string_offset + len]).unwrap(); + unsafe { + raw.begin_debug_marker(label); + } + } + state.string_offset += len; +} + // Recording a compute pass. impl Global { pub fn compute_pass_set_bind_group(