Skip to content

Commit ebcfd25

Browse files
authored
Downgrade resource lifetime management log level to trace. (#4772)
* Downgrade resource lifetime management log level to trace. Allow promoting it back to info via an feature flag. * Don't filter out info and warning log in the examples. * Changelog entry.
1 parent f4c6faf commit ebcfd25

File tree

14 files changed

+53
-31
lines changed

14 files changed

+53
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ By @gents83 in [#3626](https://github.com/gfx-rs/wgpu/pull/3626) and tnx also to
8282
- `TextureFormat::block_size` is deprecated, use `TextureFormat::block_copy_size` instead: By @wumpf in [#4647](https://github.com/gfx-rs/wgpu/pull/4647)
8383
- Rename of `DispatchIndirect`, `DrawIndexedIndirect`, and `DrawIndirect` types in the `wgpu::util` module to `DispatchIndirectArgs`, `DrawIndexedIndirectArgs`, and `DrawIndirectArgs`. By @cwfitzgerald in [#4723](https://github.com/gfx-rs/wgpu/pull/4723).
8484
- Make the size parameter of `encoder.clear_buffer` an `Option<u64>` instead of `Option<NonZero<u64>>`. By @nical in [#4737](https://github.com/gfx-rs/wgpu/pull/4737)
85+
- Reduce the `info` log level noise. By @nical in [#4769](https://github.com/gfx-rs/wgpu/pull/4769), [#4711](https://github.com/gfx-rs/wgpu/pull/4711) and [#4772](https://github.com/gfx-rs/wgpu/pull/4772)
8586

8687
#### Safe `Surface` creation
8788

examples/src/framework.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn init_logger() {
8080
env_logger::builder()
8181
.filter_level(log::LevelFilter::Info)
8282
// We keep wgpu at Error level, as it's very noisy.
83-
.filter_module("wgpu_core", log::LevelFilter::Error)
83+
.filter_module("wgpu_core", log::LevelFilter::Info)
8484
.filter_module("wgpu_hal", log::LevelFilter::Error)
8585
.filter_module("naga", log::LevelFilter::Error)
8686
.parse_default_env()

wgpu-core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ targets = [
3131
default = ["link"]
3232
# Log all API entry points at info instead of trace level.
3333
api_log_info = []
34+
# Log resource lifecycle management at info instead of trace level.
35+
resource_log_info = []
3436

3537
# Backends, passed through to wgpu-hal
3638
metal = ["hal/metal"]

wgpu-core/src/binding_model.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{
88
},
99
init_tracker::{BufferInitTrackerAction, TextureInitTrackerAction},
1010
resource::{Resource, ResourceInfo, ResourceType},
11+
resource_log,
1112
track::{BindGroupStates, UsageConflict},
1213
validation::{MissingBufferUsageError, MissingTextureUsageError},
1314
FastHashMap, Label,
@@ -465,8 +466,8 @@ pub struct BindGroupLayout<A: HalApi> {
465466

466467
impl<A: HalApi> Drop for BindGroupLayout<A> {
467468
fn drop(&mut self) {
468-
log::info!("Destroying BindGroupLayout {:?}", self.info.label());
469469
if let Some(raw) = self.raw.take() {
470+
resource_log!("Destroy raw BindGroupLayout {}", self.info.label());
470471
unsafe {
471472
use hal::Device;
472473
self.device.raw().destroy_bind_group_layout(raw);
@@ -606,8 +607,8 @@ pub struct PipelineLayout<A: HalApi> {
606607

607608
impl<A: HalApi> Drop for PipelineLayout<A> {
608609
fn drop(&mut self) {
609-
log::info!("Destroying PipelineLayout {:?}", self.info.label());
610610
if let Some(raw) = self.raw.take() {
611+
resource_log!("Destroy raw PipelineLayout {}", self.info.label());
611612
unsafe {
612613
use hal::Device;
613614
self.device.raw().destroy_pipeline_layout(raw);
@@ -827,8 +828,8 @@ pub struct BindGroup<A: HalApi> {
827828

828829
impl<A: HalApi> Drop for BindGroup<A> {
829830
fn drop(&mut self) {
830-
log::info!("Destroying BindGroup {:?}", self.info.label());
831831
if let Some(raw) = self.raw.take() {
832+
resource_log!("Destroy raw BindGroup {}", self.info.label());
832833
unsafe {
833834
use hal::Device;
834835
self.device.raw().destroy_bind_group(raw);

wgpu-core/src/command/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ use crate::init_tracker::BufferInitTrackerAction;
2727
use crate::resource::{Resource, ResourceInfo, ResourceType};
2828
use crate::track::{Tracker, UsageScope};
2929
use crate::{
30-
api_log, global::Global, hal_api::HalApi, id, identity::GlobalIdentityHandlerFactory, Label,
30+
api_log, global::Global, hal_api::HalApi, id, identity::GlobalIdentityHandlerFactory,
31+
resource_log, Label,
3132
};
3233

3334
use hal::CommandEncoder as _;
@@ -137,7 +138,7 @@ impl<A: HalApi> Drop for CommandBuffer<A> {
137138
if self.data.lock().is_none() {
138139
return;
139140
}
140-
log::info!("Destroying CommandBuffer {:?}", self.info.label());
141+
resource_log!("resource::CommandBuffer::drop {}", self.info.label());
141142
let mut baked = self.extract_baked_commands();
142143
unsafe {
143144
baked.encoder.reset_all(baked.list.into_iter());

wgpu-core/src/device/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
identity::{GlobalIdentityHandlerFactory, Input},
77
resource::{Buffer, BufferAccessResult},
88
resource::{BufferAccessError, BufferMapOperation},
9-
Label, DOWNLEVEL_ERROR_MESSAGE,
9+
resource_log, Label, DOWNLEVEL_ERROR_MESSAGE,
1010
};
1111

1212
use arrayvec::ArrayVec;
@@ -372,7 +372,10 @@ impl<A: HalApi> CommandAllocator<A> {
372372
}
373373

374374
fn dispose(self, device: &A::Device) {
375-
log::info!("Destroying {} command encoders", self.free_encoders.len());
375+
resource_log!(
376+
"CommandAllocator::dispose encoders {}",
377+
self.free_encoders.len()
378+
);
376379
for cmd_encoder in self.free_encoders {
377380
unsafe {
378381
device.destroy_command_encoder(cmd_encoder);

wgpu-core/src/device/queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
Buffer, BufferAccessError, BufferMapState, Resource, ResourceInfo, ResourceType,
2020
StagingBuffer, Texture, TextureInner,
2121
},
22-
track, FastHashMap, SubmissionIndex,
22+
resource_log, track, FastHashMap, SubmissionIndex,
2323
};
2424

2525
use hal::{CommandEncoder as _, Device as _, Queue as _};
@@ -468,7 +468,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
468468

469469
let fid = hub.staging_buffers.prepare::<G>(id_in);
470470
let (id, _) = fid.assign(staging_buffer);
471-
log::info!("Created StagingBuffer {:?}", id);
471+
resource_log!("Queue::create_staging_buffer {id:?}");
472472

473473
Ok((id, staging_buffer_ptr))
474474
}

wgpu-core/src/device/resource.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::{
2525
self, Buffer, QuerySet, Resource, ResourceType, Sampler, Texture, TextureView,
2626
TextureViewNotRenderableReason,
2727
},
28+
resource_log,
2829
storage::Storage,
2930
track::{BindGroupStates, TextureSelector, Tracker},
3031
validation::{self, check_buffer_usage, check_texture_usage},
@@ -140,7 +141,7 @@ impl<A: HalApi> std::fmt::Debug for Device<A> {
140141

141142
impl<A: HalApi> Drop for Device<A> {
142143
fn drop(&mut self) {
143-
log::info!("Destroying Device {:?}", self.info.label());
144+
resource_log!("Destroy raw Device {}", self.info.label());
144145
let raw = self.raw.take().unwrap();
145146
let pending_writes = self.pending_writes.lock().take().unwrap();
146147
pending_writes.dispose(&raw);

wgpu-core/src/global.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{
99
identity::GlobalIdentityHandlerFactory,
1010
instance::{Instance, Surface},
1111
registry::{Registry, RegistryReport},
12+
resource_log,
1213
storage::Element,
1314
};
1415

@@ -150,7 +151,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
150151
impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {
151152
fn drop(&mut self) {
152153
profiling::scope!("Global::drop");
153-
log::info!("Destroying Global");
154+
resource_log!("Global::drop");
154155
let mut surfaces_locked = self.surfaces.write();
155156

156157
// destroy hubs before the instance gets dropped

wgpu-core/src/instance.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
identity::{GlobalIdentityHandlerFactory, Input},
1111
present::Presentation,
1212
resource::{Resource, ResourceInfo, ResourceType},
13-
LabelHelpers, DOWNLEVEL_WARNING_MESSAGE,
13+
resource_log, LabelHelpers, DOWNLEVEL_WARNING_MESSAGE,
1414
};
1515

1616
use parking_lot::Mutex;
@@ -1082,7 +1082,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
10821082
Backend::Gl => fid.assign(Adapter::new(hal_adapter)),
10831083
_ => unreachable!(),
10841084
};
1085-
log::info!("Created Adapter {:?}", id);
1085+
resource_log!("Created Adapter {:?}", id);
10861086
id
10871087
}
10881088

@@ -1203,13 +1203,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
12031203
Err(e) => break e,
12041204
};
12051205
let (device_id, _) = device_fid.assign(device);
1206-
log::info!("Created Device {:?}", device_id);
1206+
resource_log!("Created Device {:?}", device_id);
12071207

12081208
let device = hub.devices.get(device_id).unwrap();
12091209
queue.device = Some(device.clone());
12101210

12111211
let (queue_id, _) = queue_fid.assign(queue);
1212-
log::info!("Created Queue {:?}", queue_id);
1212+
resource_log!("Created Queue {:?}", queue_id);
12131213

12141214
device.queue_id.write().replace(queue_id);
12151215

@@ -1255,13 +1255,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
12551255
Err(e) => break e,
12561256
};
12571257
let (device_id, _) = devices_fid.assign(device);
1258-
log::info!("Created Device {:?}", device_id);
1258+
resource_log!("Created Device {:?}", device_id);
12591259

12601260
let device = hub.devices.get(device_id).unwrap();
12611261
queue.device = Some(device.clone());
12621262

12631263
let (queue_id, _) = queues_fid.assign(queue);
1264-
log::info!("Created Queue {:?}", queue_id);
1264+
resource_log!("Created Queue {:?}", queue_id);
12651265

12661266
device.queue_id.write().replace(queue_id);
12671267

0 commit comments

Comments
 (0)