From 3ff680261d69d9ee1216645c5dbcfed681340cf7 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:31:48 +0200 Subject: [PATCH] extract `insert_debug_marker` from `compute_pass_end_impl` --- wgpu-core/src/command/compute.rs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index de088f243..7fd521715 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -647,18 +647,7 @@ impl Global { pop_debug_group(&mut state, raw).map_pass_err(scope)?; } ArcComputeCommand::InsertDebugMarker { color: _, len } => { - 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.insert_debug_marker(label) } - } - state.string_offset += len; + insert_debug_marker(&mut state, raw, &base.string_data, len); } ArcComputeCommand::WriteTimestamp { query_set, @@ -1029,6 +1018,24 @@ fn pop_debug_group( Ok(()) } +fn insert_debug_marker( + state: &mut State, + raw: &mut A::CommandEncoder, + string_data: &[u8], + len: usize, +) { + 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.insert_debug_marker(label) } + } + state.string_offset += len; +} + // Recording a compute pass. impl Global { pub fn compute_pass_set_bind_group(