From c4e067b394571d83cbce22229cf323e7d7388b83 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:29:27 +0200 Subject: [PATCH] use `.error_ident()` for `resource_log!` in Drop impls --- wgpu-core/src/binding_model.rs | 8 +++----- wgpu-core/src/command/bundle.rs | 2 +- wgpu-core/src/command/mod.rs | 2 +- wgpu-core/src/device/queue.rs | 1 + wgpu-core/src/device/resource.rs | 2 +- wgpu-core/src/pipeline.rs | 12 ++++-------- wgpu-core/src/resource.rs | 14 ++++++-------- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 508d37060..a64fe7846 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -483,7 +483,7 @@ impl Drop for BindGroupLayout { self.device.bgl_pool.remove(&self.entries); } if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw BindGroupLayout {:?}", self.info.label()); + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_bind_group_layout(raw); @@ -625,8 +625,7 @@ pub struct PipelineLayout { impl Drop for PipelineLayout { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw PipelineLayout {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_pipeline_layout(raw); @@ -861,8 +860,7 @@ pub struct BindGroup { impl Drop for BindGroup { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw BindGroup {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_bind_group(raw); diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 449da69a7..5639847ce 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -876,7 +876,7 @@ pub struct RenderBundle { impl Drop for RenderBundle { fn drop(&mut self) { - resource_log!("Destroy raw RenderBundle {:?}", self.info.label()); + resource_log!("Drop {}", self.error_ident()); } } diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index b4bac5428..65d2d76d8 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -320,10 +320,10 @@ pub struct CommandBuffer { impl Drop for CommandBuffer { fn drop(&mut self) { + resource_log!("Drop {}", self.error_ident()); if self.data.lock().is_none() { return; } - resource_log!("resource::CommandBuffer::drop {:?}", self.info.label()); let mut baked = self.extract_baked_commands(); unsafe { baked.encoder.reset_all(baked.list.into_iter()); diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 42fb158e5..6a0670dbf 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -64,6 +64,7 @@ impl ParentDevice for Queue { impl Drop for Queue { fn drop(&mut self) { + resource_log!("Drop {}", self.error_ident()); let queue = self.raw.take().unwrap(); self.device.as_ref().unwrap().release_queue(queue); } diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 67e21d6f3..23db585fd 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -161,6 +161,7 @@ impl std::fmt::Debug for Device { impl Drop for Device { fn drop(&mut self) { + resource_log!("Drop {}", self.error_ident()); let raw = self.raw.take().unwrap(); let pending_writes = self.pending_writes.lock().take().unwrap(); pending_writes.dispose(&raw); @@ -169,7 +170,6 @@ impl Drop for Device { raw.destroy_buffer(self.zero_buffer.take().unwrap()); raw.destroy_fence(self.fence.write().take().unwrap()); let queue = self.queue_to_drop.take().unwrap(); - resource_log!("Destroy raw Device {:?} and its Queue", self.info.label()); raw.exit(queue); } } diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index d78361acd..362de2f1c 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -56,8 +56,7 @@ pub struct ShaderModule { impl Drop for ShaderModule { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw ShaderModule {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_shader_module(raw); @@ -225,8 +224,7 @@ pub struct ComputePipeline { impl Drop for ComputePipeline { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw ComputePipeline {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_compute_pipeline(raw); @@ -294,8 +292,7 @@ pub struct PipelineCache { impl Drop for PipelineCache { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw PipelineCache {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_pipeline_cache(raw); @@ -554,8 +551,7 @@ pub struct RenderPipeline { impl Drop for RenderPipeline { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw RenderPipeline {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_render_pipeline(raw); diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 26848e999..412ec8969 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -472,8 +472,7 @@ pub struct Buffer { impl Drop for Buffer { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw Buffer (dropped) {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_buffer(raw); @@ -893,7 +892,7 @@ pub struct StagingBuffer { impl Drop for StagingBuffer { fn drop(&mut self) { if let Some(raw) = self.raw.lock().take() { - resource_log!("Destroy raw StagingBuffer {:?}", self.info.label()); + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_buffer(raw); @@ -997,7 +996,6 @@ impl Texture { impl Drop for Texture { fn drop(&mut self) { - resource_log!("Destroy raw Texture {:?}", self.info.label()); use hal::Device; let mut clear_mode = self.clear_mode.write(); let clear_mode = &mut *clear_mode; @@ -1027,6 +1025,7 @@ impl Drop for Texture { }; if let Some(TextureInner::Native { raw }) = self.inner.take() { + resource_log!("Destroy raw {}", self.error_ident()); unsafe { self.device.raw().destroy_texture(raw); } @@ -1542,8 +1541,7 @@ pub struct TextureView { impl Drop for TextureView { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw TextureView {:?}", self.info.label()); - + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_texture_view(raw); @@ -1682,8 +1680,8 @@ pub struct Sampler { impl Drop for Sampler { fn drop(&mut self) { - resource_log!("Destroy raw Sampler {:?}", self.info.label()); if let Some(raw) = self.raw.take() { + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_sampler(raw); @@ -1787,8 +1785,8 @@ pub struct QuerySet { impl Drop for QuerySet { fn drop(&mut self) { - resource_log!("Destroy raw QuerySet {:?}", self.info.label()); if let Some(raw) = self.raw.take() { + resource_log!("Destroy raw {}", self.error_ident()); unsafe { use hal::Device; self.device.raw().destroy_query_set(raw);