From ec0274639e0326294f23b9e9f753d09ed6fab8b1 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 2 Apr 2022 20:30:05 -0700 Subject: [PATCH] Prefix every wgpu-generated label with `(wgpu internal)`. This is intended to help developers new to wgpu or to graphics debugging quickly recognize in a debugging tool which items are wgpu-generated, as opposed to either part of their program or part of the platform graphics system. I also removed existing marker-like text such as leading underscores and angle brackets. --- wgpu-core/src/command/clear.rs | 2 +- wgpu-core/src/command/render.rs | 2 +- wgpu-core/src/device/mod.rs | 8 +++++--- wgpu-core/src/device/queue.rs | 8 ++++---- wgpu-core/src/present.rs | 2 +- wgpu-hal/src/gles/device.rs | 8 ++++++-- wgpu-hal/src/metal/mod.rs | 4 ++-- wgpu/src/util/belt.rs | 2 +- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/wgpu-core/src/command/clear.rs b/wgpu-core/src/command/clear.rs index 6a4ec98226..0bd909c76e 100644 --- a/wgpu-core/src/command/clear.rs +++ b/wgpu-core/src/command/clear.rs @@ -450,7 +450,7 @@ fn clear_texture_via_render_passes( }; unsafe { encoder.begin_render_pass(&hal::RenderPassDescriptor { - label: Some("clear_texture clear pass"), + label: Some("(wgpu internal) clear_texture clear pass"), extent, sample_count, color_attachments, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 3046a7a23b..3187d4bbc8 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -982,7 +982,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> { ) }; let desc = hal::RenderPassDescriptor { - label: Some("Zero init discarded depth/stencil aspect"), + label: Some("(wgpu internal) Zero init discarded depth/stencil aspect"), extent: view.extent, sample_count: view.samples, color_attachments: &[], diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 62fa2386c4..b951c318bd 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -356,7 +356,7 @@ impl Device { let zero_buffer = unsafe { open.device .create_buffer(&hal::BufferDescriptor { - label: Some("wgpu zero init buffer"), + label: Some("(wgpu internal) zero init buffer"), size: ZERO_BUFFER_SIZE, usage: hal::BufferUses::COPY_SRC | hal::BufferUses::COPY_DST, memory_flags: hal::MemoryFlags::empty(), @@ -784,7 +784,7 @@ impl Device { for mip_level in 0..desc.mip_level_count { for array_layer in 0..desc.size.depth_or_array_layers { let desc = hal::TextureViewDescriptor { - label: Some("clear texture view"), + label: Some("(wgpu internal) clear texture view"), format: desc.format, dimension, usage, @@ -3107,7 +3107,9 @@ impl Global { } else { // buffer needs staging area for initialization only let stage_desc = wgt::BufferDescriptor { - label: Some(Cow::Borrowed("")), + label: Some(Cow::Borrowed( + "(wgpu internal) initializing unmappable buffer", + )), size: desc.size, usage: wgt::BufferUsages::MAP_WRITE | wgt::BufferUsages::COPY_SRC, mapped_at_creation: false, diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index b242e5b683..572f49e5dc 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -174,7 +174,7 @@ impl PendingWrites { if !self.is_active { unsafe { self.command_encoder - .begin_encoding(Some("_PendingWrites")) + .begin_encoding(Some("(wgpu internal) PendingWrites")) .unwrap(); } self.is_active = true; @@ -196,7 +196,7 @@ impl super::Device { fn prepare_stage(&mut self, size: wgt::BufferAddress) -> Result, DeviceError> { profiling::scope!("prepare_stage"); let stage_desc = hal::BufferDescriptor { - label: Some("_Staging"), + label: Some("(wgpu internal) Staging"), size, usage: hal::BufferUses::MAP_WRITE | hal::BufferUses::COPY_SRC, memory_flags: hal::MemoryFlags::TRANSIENT, @@ -754,7 +754,7 @@ impl Global { unsafe { baked .encoder - .begin_encoding(Some("_Transit")) + .begin_encoding(Some("(wgpu internal) Transit")) .map_err(DeviceError::from)? }; log::trace!("Stitching command buffer {:?} before submission", cmb_id); @@ -785,7 +785,7 @@ impl Global { unsafe { baked .encoder - .begin_encoding(Some("_Present")) + .begin_encoding(Some("(wgpu internal) Present")) .map_err(DeviceError::from)? }; let texture_barriers = trackers diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index 17bdf467a9..833e65d6be 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -126,7 +126,7 @@ impl Global { let (texture_id, status) = match unsafe { suf.raw.acquire_texture(FRAME_TIMEOUT_MS) } { Ok(Some(ast)) => { let clear_view_desc = hal::TextureViewDescriptor { - label: Some("clear surface texture view"), + label: Some("(wgpu internal) clear surface texture view"), format: config.format, dimension: wgt::TextureViewDimension::D2, usage: hal::TextureUses::COLOR_TARGET, diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 29a6155f14..bc6111077b 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -213,8 +213,12 @@ impl super::Device { }; let shader_src = format!("#version {} es \n void main(void) {{}}", version,); log::info!("Only vertex shader is present. Creating an empty fragment shader",); - let shader = - Self::compile_shader(gl, &shader_src, naga::ShaderStage::Fragment, Some("_dummy"))?; + let shader = Self::compile_shader( + gl, + &shader_src, + naga::ShaderStage::Fragment, + Some("(wgpu internal) dummy fragment shader"), + )?; shaders_to_delete.push(shader); } diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 84c1e20929..5c4f6338b0 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -338,7 +338,7 @@ impl crate::Queue for Queue { .to_owned() } }; - raw.set_label("_Signal"); + raw.set_label("(wgpu internal) Signal"); raw.add_completed_handler(&block); fence.maintain(); @@ -370,7 +370,7 @@ impl crate::Queue for Queue { let queue = &self.raw.lock(); objc::rc::autoreleasepool(|| { let command_buffer = queue.new_command_buffer(); - command_buffer.set_label("_Present"); + command_buffer.set_label("(wgpu internal) Present"); // https://developer.apple.com/documentation/quartzcore/cametallayer/1478157-presentswithtransaction?language=objc if !texture.present_with_transaction { diff --git a/wgpu/src/util/belt.rs b/wgpu/src/util/belt.rs index d735d18474..6aa89c7a3e 100644 --- a/wgpu/src/util/belt.rs +++ b/wgpu/src/util/belt.rs @@ -115,7 +115,7 @@ impl StagingBelt { let size = self.chunk_size.max(size.get()); Chunk { buffer: device.create_buffer(&BufferDescriptor { - label: Some("staging"), + label: Some("(wgpu internal) StagingBelt staging buffer"), size, usage: BufferUsages::MAP_WRITE | BufferUsages::COPY_SRC, mapped_at_creation: true,