From 10cf23b5112ca22b37659d883be9eeada63fb3e6 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:20:51 +0200 Subject: [PATCH] extract `pop_debug_group` from `render_pass_end_impl` --- wgpu-core/src/command/render.rs | 36 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 391fdba49..232738e91 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1679,23 +1679,8 @@ impl Global { push_debug_group(&mut state, &base.string_data, len); } ArcRenderCommand::PopDebugGroup => { - api_log!("RenderPass::pop_debug_group"); - let scope = PassErrorScope::PopDebugGroup; - if state.debug_scope_depth == 0 { - return Err(RenderPassErrorInner::InvalidPopDebugGroup) - .map_pass_err(scope); - } - state.debug_scope_depth -= 1; - if !state - .device - .instance_flags - .contains(wgt::InstanceFlags::DISCARD_HAL_LABELS) - { - unsafe { - state.raw_encoder.end_debug_marker(); - } - } + pop_debug_group(&mut state).map_pass_err(scope)?; } ArcRenderCommand::InsertDebugMarker { color: _, len } => { if !state @@ -2627,6 +2612,25 @@ fn push_debug_group(state: &mut State, string_data: &[u8], len: us state.string_offset += len; } +fn pop_debug_group(state: &mut State) -> Result<(), RenderPassErrorInner> { + api_log!("RenderPass::pop_debug_group"); + + if state.debug_scope_depth == 0 { + return Err(RenderPassErrorInner::InvalidPopDebugGroup); + } + state.debug_scope_depth -= 1; + if !state + .device + .instance_flags + .contains(wgt::InstanceFlags::DISCARD_HAL_LABELS) + { + unsafe { + state.raw_encoder.end_debug_marker(); + } + } + Ok(()) +} + impl Global { pub fn render_pass_set_bind_group( &self,