From 9c6ae1beae2490ce44d99034f7f1faada936f3d8 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 31 Jul 2024 18:24:23 +0200 Subject: [PATCH] Log spring cleaning (#6065) Remove unused logs in wgpu-core and wgpu-hal --- CHANGELOG.md | 4 ++++ wgpu-core/src/command/bind.rs | 2 -- wgpu-core/src/command/compute.rs | 2 -- wgpu-core/src/command/mod.rs | 2 -- wgpu-core/src/command/render.rs | 3 --- wgpu-core/src/device/life.rs | 12 +--------- wgpu-core/src/device/queue.rs | 3 --- wgpu-core/src/device/resource.rs | 8 ------- wgpu-core/src/present.rs | 12 ---------- wgpu-core/src/resource.rs | 1 - wgpu-core/src/storage.rs | 3 --- wgpu-core/src/track/buffer.rs | 8 +------ wgpu-core/src/track/texture.rs | 38 -------------------------------- wgpu-hal/src/dx12/command.rs | 26 ---------------------- wgpu-hal/src/dx12/device.rs | 35 ----------------------------- 15 files changed, 6 insertions(+), 153 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81beb96854..a267e6565b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,10 @@ Bottom level categories: - Fix crash when dropping the surface after the device. By @wumpf in [#6052](https://github.com/gfx-rs/wgpu/pull/6052) - Fix error message that is thrown in create_render_pass to no longer say `compute_pass`. By @matthew-wong1 [#6041](https://github.com/gfx-rs/wgpu/pull/6041) +### Changes + +- Reduce the amount of debug and trace logs emitted by wgpu-core and wgpu-hal. By @nical in [#6065](https://github.com/gfx-rs/wgpu/issues/6065) + ### Dependency Updates #### GLES diff --git a/wgpu-core/src/command/bind.rs b/wgpu-core/src/command/bind.rs index 5e3f249301..7e3d9ce9cd 100644 --- a/wgpu-core/src/command/bind.rs +++ b/wgpu-core/src/command/bind.rs @@ -383,8 +383,6 @@ impl Binder { bind_group: &Arc>, offsets: &[wgt::DynamicOffset], ) -> &'a [EntryPayload] { - log::trace!("\tBinding [{}] = group {}", index, bind_group.error_ident()); - let payload = &mut self.payloads[index]; payload.group = Some(bind_group.clone()); payload.dynamic_offsets.clear(); diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index c92b08e72f..1d751531ac 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -269,8 +269,6 @@ impl<'scope, 'snatch_guard, 'cmd_buf, 'raw_encoder, A: HalApi> .set_and_remove_from_usage_scope_sparse(&mut self.scope.buffers, indirect_buffer); } - log::trace!("Encoding dispatch barriers"); - CommandBuffer::drain_barriers( self.raw_encoder, &mut self.intermediate_trackers, diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index e73a5bc0b0..7290330daf 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -506,7 +506,6 @@ impl CommandBuffer { } pub(crate) fn extract_baked_commands(&mut self) -> BakedCommands { - log::trace!("Extracting BakedCommands from {}", self.error_ident()); let data = self.data.lock().take().unwrap(); BakedCommands { encoder: data.encoder.raw, @@ -626,7 +625,6 @@ impl Global { cmd_buf_data.status = CommandEncoderStatus::Finished; //Note: if we want to stop tracking the swapchain texture view, // this is the place to do it. - log::trace!("Command buffer {:?}", encoder_id); None } } diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 130c04704c..f42bc02358 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1600,8 +1600,6 @@ impl Global { *status = CommandEncoderStatus::Error; encoder.open_pass(hal_label).map_pass_err(pass_scope)?; - log::trace!("Encoding render pass begin in {}", cmd_buf.error_ident()); - let info = RenderPassInfo::start( device, hal_label, @@ -1907,7 +1905,6 @@ impl Global { } } - log::trace!("Merging renderpass into {}", cmd_buf.error_ident()); let (trackers, pending_discard_init_fixups) = state .info .finish(state.raw_encoder, state.snatch_guard) diff --git a/wgpu-core/src/device/life.rs b/wgpu-core/src/device/life.rs index 3696d8abe4..b282775ac0 100644 --- a/wgpu-core/src/device/life.rs +++ b/wgpu-core/src/device/life.rs @@ -5,7 +5,7 @@ use crate::{ }, hal_api::HalApi, id, - resource::{self, Buffer, Labeled, Texture, Trackable}, + resource::{self, Buffer, Texture, Trackable}, snatch::SnatchGuard, SubmissionIndex, }; @@ -283,7 +283,6 @@ impl LifetimeTracker { let mut work_done_closures: SmallVec<_> = self.work_done_closures.drain(..).collect(); for a in self.active.drain(..done_count) { - log::debug!("Active submission {} is done", a.index); self.ready_to_map.extend(a.mapped); for encoder in a.encoders { let raw = unsafe { encoder.land() }; @@ -339,12 +338,6 @@ impl LifetimeTracker { .rev() .find(|a| a.contains_buffer(&buffer)); - log::trace!( - "Mapping of {} at submission {:?}", - buffer.error_ident(), - submission.as_deref().map(|s| s.index) - ); - submission .map_or(&mut self.ready_to_map, |a| &mut a.mapped) .push(buffer); @@ -369,8 +362,6 @@ impl LifetimeTracker { Vec::with_capacity(self.ready_to_map.len()); for buffer in self.ready_to_map.drain(..) { - let tracker_index = buffer.tracker_index(); - // This _cannot_ be inlined into the match. If it is, the lock will be held // open through the whole match, resulting in a deadlock when we try to re-lock // the buffer back to active. @@ -391,7 +382,6 @@ impl LifetimeTracker { _ => panic!("No pending mapping."), }; let status = if pending_mapping.range.start != pending_mapping.range.end { - log::debug!("Buffer {tracker_index:?} map state -> Active"); let host = pending_mapping.op.host; let size = pending_mapping.range.end - pending_mapping.range.start; match super::map_buffer( diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 625395fdc1..81c9729521 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -1187,7 +1187,6 @@ impl Global { )) .map_err(DeviceError::from)? }; - log::trace!("Stitching command buffer {:?} before submission", cmb_id); //Note: locking the trackers has to be done after the storages let mut trackers = device.trackers.lock(); @@ -1241,8 +1240,6 @@ impl Global { pending_textures: FastHashMap::default(), }); } - - log::trace!("Device after submission {}", submit_index); } } diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 045eccfbc2..6bafd6844c 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -1230,12 +1230,6 @@ impl Device { texture.hal_usage & mask_copy & mask_dimension & mask_mip_level }; - log::debug!( - "Create view for {} filters usages to {:?}", - texture.error_ident(), - usage - ); - // use the combined depth-stencil format for the view let format = if resolved_format.is_depth_stencil_component(texture.desc.format) { texture.desc.format @@ -2796,7 +2790,6 @@ impl Device { .iter() .any(|ct| ct.write_mask != first.write_mask || ct.blend != first.blend) } { - log::debug!("Color targets: {:?}", color_targets); self.require_downlevel_flags(wgt::DownlevelFlags::INDEPENDENT_BLEND)?; } } @@ -3483,7 +3476,6 @@ impl Device { let fence = guard.as_ref().unwrap(); let last_done_index = unsafe { self.raw.as_ref().unwrap().get_fence_value(fence)? }; if last_done_index < submission_index { - log::info!("Waiting for submission {:?}", submission_index); unsafe { self.raw .as_ref() diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index 7a2200eae1..e22a772680 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -230,7 +230,6 @@ impl Global { .insert_single(&texture, hal::TextureUses::UNINITIALIZED); let id = fid.assign(texture); - log::debug!("Created CURRENT Surface Texture {:?}", id); if present.acquired_texture.is_some() { return Err(SurfaceError::AlreadyAcquired); @@ -301,10 +300,6 @@ impl Global { // The texture ID got added to the device tracker by `submit()`, // and now we are moving it away. - log::debug!( - "Removing swapchain texture {:?} from the device tracker", - texture_id - ); let texture = hub.textures.unregister(texture_id); if let Some(texture) = texture { device @@ -336,8 +331,6 @@ impl Global { } }; - log::debug!("Presented. End of Frame"); - match result { Ok(()) => Ok(Status::Good), Err(err) => match err { @@ -387,11 +380,6 @@ impl Global { // The texture ID got added to the device tracker by `submit()`, // and now we are moving it away. - log::debug!( - "Removing swapchain texture {:?} from the device tracker", - texture_id - ); - let texture = hub.textures.unregister(texture_id); if let Some(texture) = texture { diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index c2138808ff..c5871ea3ad 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -617,7 +617,6 @@ impl Buffer { let device = &self.device; let snatch_guard = device.snatchable_lock.read(); let raw_buf = self.try_raw(&snatch_guard)?; - log::debug!("{} map state -> Idle", self.error_ident()); match mem::replace(&mut *self.map_state.lock(), BufferMapState::Idle) { BufferMapState::Init { staging_buffer } => { #[cfg(feature = "trace")] diff --git a/wgpu-core/src/storage.rs b/wgpu-core/src/storage.rs index f2875b3542..fda9cbd036 100644 --- a/wgpu-core/src/storage.rs +++ b/wgpu-core/src/storage.rs @@ -119,13 +119,11 @@ where } pub(crate) fn insert(&mut self, id: Id, value: Arc) { - log::trace!("User is inserting {}{:?}", T::TYPE, id); let (index, epoch, _backend) = id.unzip(); self.insert_impl(index as usize, epoch, Element::Occupied(value, epoch)) } pub(crate) fn insert_error(&mut self, id: Id) { - log::trace!("User is inserting as error {}{:?}", T::TYPE, id); let (index, epoch, _) = id.unzip(); self.insert_impl(index as usize, epoch, Element::Error(epoch)) } @@ -143,7 +141,6 @@ where } pub(crate) fn remove(&mut self, id: Id) -> Option> { - log::trace!("User is removing {}{:?}", T::TYPE, id); let (index, epoch, _) = id.unzip(); match std::mem::replace(&mut self.map[index as usize], Element::Vacant) { Element::Occupied(value, storage_epoch) => { diff --git a/wgpu-core/src/track/buffer.rs b/wgpu-core/src/track/buffer.rs index ed95f9ce8a..4920cc4cc5 100644 --- a/wgpu-core/src/track/buffer.rs +++ b/wgpu-core/src/track/buffer.rs @@ -735,8 +735,6 @@ unsafe fn insert( strict_assert_eq!(invalid_resource_state(new_start_state), false); strict_assert_eq!(invalid_resource_state(new_end_state), false); - log::trace!("\tbuf {index}: insert {new_start_state:?}..{new_end_state:?}"); - unsafe { if let Some(&mut ref mut start_state) = start_states { *start_state.get_unchecked_mut(index) = new_start_state; @@ -751,7 +749,7 @@ unsafe fn insert( #[inline(always)] unsafe fn merge( current_states: &mut [BufferUses], - index32: u32, + _index32: u32, index: usize, state_provider: BufferStateProvider<'_>, metadata_provider: ResourceMetadataProvider<'_, Arc>>, @@ -769,8 +767,6 @@ unsafe fn merge( )); } - log::trace!("\tbuf {index32}: merge {current_state:?} + {new_state:?}"); - *current_state = merged_state; Ok(()) @@ -795,8 +791,6 @@ unsafe fn barrier( selector: (), usage: current_state..new_state, }); - - log::trace!("\tbuf {index}: transition {current_state:?} -> {new_state:?}"); } #[inline(always)] diff --git a/wgpu-core/src/track/texture.rs b/wgpu-core/src/track/texture.rs index 73321687cb..592c9a6c82 100644 --- a/wgpu-core/src/track/texture.rs +++ b/wgpu-core/src/track/texture.rs @@ -1124,8 +1124,6 @@ unsafe fn insert( // check that resource states don't have any conflicts. strict_assert_eq!(invalid_resource_state(state), false); - log::trace!("\ttex {index}: insert start {state:?}"); - if let Some(start_state) = start_state { unsafe { *start_state.simple.get_unchecked_mut(index) = state }; } @@ -1141,8 +1139,6 @@ unsafe fn insert( let complex = unsafe { ComplexTextureState::from_selector_state_iter(full_range, state_iter) }; - log::trace!("\ttex {index}: insert start {complex:?}"); - if let Some(start_state) = start_state { unsafe { *start_state.simple.get_unchecked_mut(index) = TextureUses::COMPLEX }; start_state.complex.insert(index, complex.clone()); @@ -1163,8 +1159,6 @@ unsafe fn insert( // check that resource states don't have any conflicts. strict_assert_eq!(invalid_resource_state(state), false); - log::trace!("\ttex {index}: insert end {state:?}"); - // We only need to insert into the end, as there is guaranteed to be // a start state provider. unsafe { *end_state.simple.get_unchecked_mut(index) = state }; @@ -1176,8 +1170,6 @@ unsafe fn insert( ComplexTextureState::from_selector_state_iter(full_range, state_iter) }; - log::trace!("\ttex {index}: insert end {complex:?}"); - // We only need to insert into the end, as there is guaranteed to be // a start state provider. unsafe { *end_state.simple.get_unchecked_mut(index) = TextureUses::COMPLEX }; @@ -1215,8 +1207,6 @@ unsafe fn merge( (SingleOrManyStates::Single(current_simple), SingleOrManyStates::Single(new_simple)) => { let merged_state = *current_simple | new_simple; - log::trace!("\ttex {index}: merge simple {current_simple:?} + {new_simple:?}"); - if invalid_resource_state(merged_state) { return Err(ResourceUsageCompatibilityError::from_texture( unsafe { metadata_provider.get(index) }, @@ -1242,8 +1232,6 @@ unsafe fn merge( for (selector, new_state) in new_many { let merged_state = *current_simple | new_state; - log::trace!("\ttex {index}: merge {selector:?} {current_simple:?} + {new_state:?}"); - if invalid_resource_state(merged_state) { return Err(ResourceUsageCompatibilityError::from_texture( unsafe { metadata_provider.get(index) }, @@ -1280,11 +1268,6 @@ unsafe fn merge( // simple states are never unknown. let merged_state = merged_state - TextureUses::UNKNOWN; - log::trace!( - "\ttex {index}: merge mip {mip_id} layers {layers:?} \ - {current_layer_state:?} + {new_simple:?}" - ); - if invalid_resource_state(merged_state) { return Err(ResourceUsageCompatibilityError::from_texture( unsafe { metadata_provider.get(index) }, @@ -1321,11 +1304,6 @@ unsafe fn merge( continue; } - log::trace!( - "\ttex {index}: merge mip {mip_id} layers {layers:?} \ - {current_layer_state:?} + {new_state:?}" - ); - if invalid_resource_state(merged_state) { return Err(ResourceUsageCompatibilityError::from_texture( unsafe { metadata_provider.get(index) }, @@ -1373,8 +1351,6 @@ unsafe fn barrier( return; } - log::trace!("\ttex {index}: transition simple {current_simple:?} -> {new_simple:?}"); - barriers.push(PendingTransition { id: index as _, selector: texture_selector.clone(), @@ -1391,10 +1367,6 @@ unsafe fn barrier( continue; } - log::trace!( - "\ttex {index}: transition {selector:?} {current_simple:?} -> {new_state:?}" - ); - barriers.push(PendingTransition { id: index as _, selector, @@ -1415,11 +1387,6 @@ unsafe fn barrier( continue; } - log::trace!( - "\ttex {index}: transition mip {mip_id} layers {layers:?} \ - {current_layer_state:?} -> {new_simple:?}" - ); - barriers.push(PendingTransition { id: index as _, selector: TextureSelector { @@ -1449,11 +1416,6 @@ unsafe fn barrier( continue; } - log::trace!( - "\ttex {index}: transition mip {mip_id} layers {layers:?} \ - {current_layer_state:?} -> {new_state:?}" - ); - barriers.push(PendingTransition { id: index as _, selector: TextureSelector { diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index fbaa956dfb..5e05a3bcf5 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -220,7 +220,6 @@ impl super::CommandEncoder { } fn reset_signature(&mut self, layout: &super::PipelineLayoutShared) { - log::trace!("Reset signature {:?}", layout.signature); if let Some(root_index) = layout.special_constants_root_index { self.pass.root_elements[root_index as usize] = super::RootElement::SpecialConstantBuffer { @@ -315,17 +314,7 @@ impl crate::CommandEncoder for super::CommandEncoder { { self.temp.barriers.clear(); - log::trace!( - "List {:p} buffer transitions", - self.list.as_ref().unwrap().as_ptr() - ); for barrier in barriers { - log::trace!( - "\t{:p}: usage {:?}..{:?}", - barrier.buffer.resource.as_ptr(), - barrier.usage.start, - barrier.usage.end - ); let s0 = conv::map_buffer_usage_to_state(barrier.usage.start); let s1 = conv::map_buffer_usage_to_state(barrier.usage.end); if s0 != s1 { @@ -374,18 +363,7 @@ impl crate::CommandEncoder for super::CommandEncoder { { self.temp.barriers.clear(); - log::trace!( - "List {:p} texture transitions", - self.list.as_ref().unwrap().as_ptr() - ); for barrier in barriers { - log::trace!( - "\t{:p}: usage {:?}..{:?}, range {:?}", - barrier.texture.resource.as_ptr(), - barrier.usage.start, - barrier.usage.end, - barrier.range - ); let s0 = conv::map_texture_usage_to_state(barrier.usage.start); let s1 = conv::map_texture_usage_to_state(barrier.usage.end); if s0 != s1 { @@ -879,13 +857,11 @@ impl crate::CommandEncoder for super::CommandEncoder { group: &super::BindGroup, dynamic_offsets: &[wgt::DynamicOffset], ) { - log::trace!("Set group[{}]", index); let info = &layout.bind_group_infos[index as usize]; let mut root_index = info.base_root_index as usize; // Bind CBV/SRC/UAV descriptor tables if info.tables.contains(super::TableTypes::SRV_CBV_UAV) { - log::trace!("\tBind element[{}] = view", root_index); self.pass.root_elements[root_index] = super::RootElement::Table(group.handle_views.unwrap().gpu); root_index += 1; @@ -893,7 +869,6 @@ impl crate::CommandEncoder for super::CommandEncoder { // Bind Sampler descriptor tables. if info.tables.contains(super::TableTypes::SAMPLERS) { - log::trace!("\tBind element[{}] = sampler", root_index); self.pass.root_elements[root_index] = super::RootElement::Table(group.handle_samplers.unwrap().gpu); root_index += 1; @@ -906,7 +881,6 @@ impl crate::CommandEncoder for super::CommandEncoder { .zip(group.dynamic_buffers.iter()) .zip(dynamic_offsets) { - log::trace!("\tBind element[{}] = dynamic", root_index); self.pass.root_elements[root_index] = super::RootElement::DynamicOffsetBuffer { kind, address: gpu_base + offset as d3d12::GpuAddress, diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index fa3e828fba..8012086a90 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -196,7 +196,6 @@ impl super::Device { } let value = cur_value + 1; - log::debug!("Waiting for idle with value {}", value); self.present_queue.signal(&self.idler.fence, value); let hr = self .idler @@ -817,11 +816,6 @@ impl crate::Device for super::Device { } } - log::debug!( - "Creating Root Signature '{}'", - desc.label.unwrap_or_default() - ); - let mut binding_map = hlsl::BindingMap::default(); let (mut bind_cbv, mut bind_srv, mut bind_uav, mut bind_sampler) = ( hlsl::BindTarget::default(), @@ -844,11 +838,6 @@ impl crate::Device for super::Device { if pc_start != u32::MAX && pc_end != u32::MIN { let parameter_index = parameters.len(); let size = (pc_end - pc_start) / 4; - log::debug!( - "\tParam[{}] = push constant (count = {})", - parameter_index, - size, - ); parameters.push(d3d12::RootParameter::constants( d3d12::ShaderVisibility::All, native_binding(&bind_cbv), @@ -942,12 +931,6 @@ impl crate::Device for super::Device { bt.register += entry.count.map(NonZeroU32::get).unwrap_or(1); } if ranges.len() > range_base { - log::debug!( - "\tParam[{}] = views (vis = {:?}, count = {})", - parameters.len(), - visibility_view_static, - ranges.len() - range_base, - ); parameters.push(d3d12::RootParameter::descriptor_table( conv::map_visibility(visibility_view_static), &ranges[range_base..], @@ -981,12 +964,6 @@ impl crate::Device for super::Device { bind_sampler.register += entry.count.map(NonZeroU32::get).unwrap_or(1); } if ranges.len() > range_base { - log::debug!( - "\tParam[{}] = samplers (vis = {:?}, count = {})", - parameters.len(), - visibility_sampler, - ranges.len() - range_base, - ); parameters.push(d3d12::RootParameter::descriptor_table( conv::map_visibility(visibility_sampler), &ranges[range_base..], @@ -1036,12 +1013,6 @@ impl crate::Device for super::Device { ); info.dynamic_buffers.push(kind); - log::debug!( - "\tParam[{}] = dynamic {:?} (vis = {:?})", - parameters.len(), - buffer_ty, - dynamic_buffers_visibility, - ); parameters.push(d3d12::RootParameter::descriptor( parameter_ty, dynamic_buffers_visibility, @@ -1062,7 +1033,6 @@ impl crate::Device for super::Device { | crate::PipelineLayoutFlags::NUM_WORK_GROUPS, ) { let parameter_index = parameters.len(); - log::debug!("\tParam[{}] = special", parameter_index); parameters.push(d3d12::RootParameter::constants( d3d12::ShaderVisibility::All, // really needed for VS and CS only native_binding(&bind_cbv), @@ -1075,9 +1045,6 @@ impl crate::Device for super::Device { (None, None) }; - log::trace!("{:#?}", parameters); - log::trace!("Bindings {:#?}", binding_map); - let (blob, error) = self .library .serialize_root_signature( @@ -1105,8 +1072,6 @@ impl crate::Device for super::Device { .create_root_signature(blob, 0) .into_device_result("Root signature creation")?; - log::debug!("\traw = {:?}", raw); - if let Some(label) = desc.label { let cwstr = conv::map_label(label); unsafe { raw.SetName(cwstr.as_ptr()) };