From cb67ef654265d836918fcad4181366c05dd37ead Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 15 Dec 2020 17:28:19 -0500 Subject: [PATCH] Clean up render pass labels --- wgpu-core/src/command/allocator.rs | 4 +++- wgpu-core/src/command/mod.rs | 2 ++ wgpu-core/src/command/render.rs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/command/allocator.rs b/wgpu-core/src/command/allocator.rs index da6f1749e..62a87e0dc 100644 --- a/wgpu-core/src/command/allocator.rs +++ b/wgpu-core/src/command/allocator.rs @@ -118,12 +118,14 @@ impl CommandAllocator { used_swap_chain: None, limits, private_features, + has_labels: label.is_some(), #[cfg(feature = "trace")] commands: if enable_tracing { Some(Vec::new()) } else { None }, + #[cfg(debug_assertions)] label: label.to_string_or_default(), }) } @@ -209,7 +211,7 @@ impl CommandAllocator { ) { // Record this command buffer as pending let mut inner = self.inner.lock(); - let clear_label = !cmd_buf.label.is_empty(); + let clear_label = cmd_buf.has_labels; inner .pools .get_mut(&cmd_buf.recorded_thread_id) diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index d5093904d..867696a9e 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -45,8 +45,10 @@ pub struct CommandBuffer { pub(crate) used_swap_chain: Option<(Stored, B::Framebuffer)>, limits: wgt::Limits, private_features: PrivateFeatures, + has_labels: bool, #[cfg(feature = "trace")] pub(crate) commands: Option>, + #[cfg(debug_assertions)] pub(crate) label: String, } diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 78cd9c950..2e7c28f30 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -499,6 +499,7 @@ impl Global { unsafe { if let Some(ref label) = base.label { + cmd_buf.has_labels = true; device.raw.set_command_buffer_name(&mut raw, label); } raw.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);