Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally lift API logging from trace to info level #4769

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ targets = [

[features]
default = ["link"]
# Log all API entry points at info instead of trace level.
api_log_info = []
Wumpf marked this conversation as resolved.
Show resolved Hide resolved

# Backends, passed through to wgpu-hal
metal = ["hal/metal"]
Expand Down
5 changes: 3 additions & 2 deletions wgpu-core/src/command/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{ops::Range, sync::Arc};
#[cfg(feature = "trace")]
use crate::device::trace::Command as TraceCommand;
use crate::{
api_log,
command::CommandBuffer,
get_lowest_common_denom,
global::Global,
Expand Down Expand Up @@ -76,7 +77,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
size: Option<BufferAddress>,
) -> Result<(), ClearError> {
profiling::scope!("CommandEncoder::clear_buffer");
log::trace!("CommandEncoder::clear_buffer {dst:?}");
api_log!("CommandEncoder::clear_buffer {dst:?}");

let hub = A::hub(self);

Expand Down Expand Up @@ -161,7 +162,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
subresource_range: &ImageSubresourceRange,
) -> Result<(), ClearError> {
profiling::scope!("CommandEncoder::clear_texture");
log::trace!("CommandEncoder::clear_texture {dst:?}");
api_log!("CommandEncoder::clear_texture {dst:?}");

let hub = A::hub(self);

Expand Down
10 changes: 6 additions & 4 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use crate::id::CommandBufferId;
use crate::init_tracker::BufferInitTrackerAction;
use crate::resource::{Resource, ResourceInfo, ResourceType};
use crate::track::{Tracker, UsageScope};
use crate::{global::Global, hal_api::HalApi, id, identity::GlobalIdentityHandlerFactory, Label};
use crate::{
api_log, global::Global, hal_api::HalApi, id, identity::GlobalIdentityHandlerFactory, Label,
};

use hal::CommandEncoder as _;
use parking_lot::Mutex;
Expand Down Expand Up @@ -435,7 +437,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
label: &str,
) -> Result<(), CommandEncoderError> {
profiling::scope!("CommandEncoder::push_debug_group");
log::trace!("CommandEncoder::push_debug_group {label}");
api_log!("CommandEncoder::push_debug_group {label}");

let hub = A::hub(self);

Expand Down Expand Up @@ -466,7 +468,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
label: &str,
) -> Result<(), CommandEncoderError> {
profiling::scope!("CommandEncoder::insert_debug_marker");
log::trace!("CommandEncoder::insert_debug_marker {label}");
api_log!("CommandEncoder::insert_debug_marker {label}");

let hub = A::hub(self);

Expand Down Expand Up @@ -497,7 +499,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
encoder_id: id::CommandEncoderId,
) -> Result<(), CommandEncoderError> {
profiling::scope!("CommandEncoder::pop_debug_marker");
log::trace!("CommandEncoder::pop_debug_group");
api_log!("CommandEncoder::pop_debug_group");

let hub = A::hub(self);

Expand Down
45 changes: 23 additions & 22 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::resource::Resource;
use crate::{
api_log,
binding_model::BindError,
command::{
self,
Expand Down Expand Up @@ -1410,7 +1411,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
num_dynamic_offsets,
bind_group_id,
} => {
log::trace!("RenderPass::set_bind_group {index} {bind_group_id:?}");
api_log!("RenderPass::set_bind_group {index} {bind_group_id:?}");

let scope = PassErrorScope::SetBindGroup(bind_group_id);
let max_bind_groups = device.limits.max_bind_groups;
Expand Down Expand Up @@ -1493,7 +1494,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
}
RenderCommand::SetPipeline(pipeline_id) => {
log::trace!("RenderPass::set_pipeline {pipeline_id:?}");
api_log!("RenderPass::set_pipeline {pipeline_id:?}");

let scope = PassErrorScope::SetPipelineRender(pipeline_id);
state.pipeline = Some(pipeline_id);
Expand Down Expand Up @@ -1621,7 +1622,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
offset,
size,
} => {
log::trace!("RenderPass::set_index_buffer {buffer_id:?}");
api_log!("RenderPass::set_index_buffer {buffer_id:?}");

let scope = PassErrorScope::SetIndexBuffer(buffer_id);
let buffer = info
Expand Down Expand Up @@ -1674,7 +1675,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
offset,
size,
} => {
log::trace!("RenderPass::set_vertex_buffer {slot} {buffer_id:?}");
api_log!("RenderPass::set_vertex_buffer {slot} {buffer_id:?}");

let scope = PassErrorScope::SetVertexBuffer(buffer_id);
let buffer = info
Expand Down Expand Up @@ -1737,7 +1738,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
state.vertex.update_limits();
}
RenderCommand::SetBlendConstant(ref color) => {
log::trace!("RenderPass::set_blend_constant");
api_log!("RenderPass::set_blend_constant");

state.blend_constant = OptionalState::Set;
let array = [
Expand All @@ -1751,7 +1752,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
}
RenderCommand::SetStencilReference(value) => {
log::trace!("RenderPass::set_stencil_reference {value}");
api_log!("RenderPass::set_stencil_reference {value}");

state.stencil_reference = value;
if state
Expand All @@ -1768,7 +1769,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
depth_min,
depth_max,
} => {
log::trace!("RenderPass::set_viewport {rect:?}");
api_log!("RenderPass::set_viewport {rect:?}");

let scope = PassErrorScope::SetViewport;
if rect.x < 0.0
Expand Down Expand Up @@ -1806,7 +1807,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
size_bytes,
values_offset,
} => {
log::trace!("RenderPass::set_push_constants");
api_log!("RenderPass::set_push_constants");

let scope = PassErrorScope::SetPushConstant;
let values_offset = values_offset
Expand Down Expand Up @@ -1841,7 +1842,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
}
RenderCommand::SetScissor(ref rect) => {
log::trace!("RenderPass::set_scissor_rect {rect:?}");
api_log!("RenderPass::set_scissor_rect {rect:?}");

let scope = PassErrorScope::SetScissorRect;
if rect.x + rect.w > info.extent.width
Expand All @@ -1866,7 +1867,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
first_vertex,
first_instance,
} => {
log::trace!(
api_log!(
"RenderPass::draw {vertex_count} {instance_count} {first_vertex} {first_instance}"
);

Expand Down Expand Up @@ -1910,7 +1911,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
base_vertex,
first_instance,
} => {
log::trace!("RenderPass::draw_indexed {index_count} {instance_count} {first_index} {base_vertex} {first_instance}");
api_log!("RenderPass::draw_indexed {index_count} {instance_count} {first_index} {base_vertex} {first_instance}");

let indexed = true;
let scope = PassErrorScope::Draw {
Expand Down Expand Up @@ -1958,7 +1959,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
count,
indexed,
} => {
log::trace!("RenderPass::draw_indirect (indexed:{indexed}) {buffer_id:?} {offset} {count:?}");
api_log!("RenderPass::draw_indirect (indexed:{indexed}) {buffer_id:?} {offset} {count:?}");

let scope = PassErrorScope::Draw {
indexed,
Expand Down Expand Up @@ -2032,7 +2033,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
max_count,
indexed,
} => {
log::trace!("RenderPass::multi_draw_indirect_count (indexed:{indexed}) {buffer_id:?} {offset} {count_buffer_id:?} {count_buffer_offset:?} {max_count:?}");
api_log!("RenderPass::multi_draw_indirect_count (indexed:{indexed}) {buffer_id:?} {offset} {count_buffer_id:?} {count_buffer_offset:?} {max_count:?}");

let scope = PassErrorScope::Draw {
indexed,
Expand Down Expand Up @@ -2148,15 +2149,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
)
.unwrap();

log::trace!("RenderPass::push_debug_group {label:?}");
api_log!("RenderPass::push_debug_group {label:?}");
unsafe {
raw.begin_debug_marker(label);
}
}
string_offset += len;
}
RenderCommand::PopDebugGroup => {
log::trace!("RenderPass::pop_debug_group");
api_log!("RenderPass::pop_debug_group");

let scope = PassErrorScope::PopDebugGroup;
if state.debug_scope_depth == 0 {
Expand All @@ -2176,7 +2177,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&base.string_data[string_offset..string_offset + len],
)
.unwrap();
log::trace!("RenderPass::insert_debug_marker {label:?}");
api_log!("RenderPass::insert_debug_marker {label:?}");
unsafe {
raw.insert_debug_marker(label);
}
Expand All @@ -2187,7 +2188,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
query_set_id,
query_index,
} => {
log::trace!("RenderPass::write_timestamps {query_set_id:?} {query_index}");
api_log!("RenderPass::write_timestamps {query_set_id:?} {query_index}");
let scope = PassErrorScope::WriteTimestamp;

device
Expand All @@ -2210,7 +2211,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.map_pass_err(scope)?;
}
RenderCommand::BeginOcclusionQuery { query_index } => {
log::trace!("RenderPass::begin_occlusion_query {query_index}");
api_log!("RenderPass::begin_occlusion_query {query_index}");
let scope = PassErrorScope::BeginOcclusionQuery;

let query_set_id = occlusion_query_set_id
Expand All @@ -2234,7 +2235,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.map_pass_err(scope)?;
}
RenderCommand::EndOcclusionQuery => {
log::trace!("RenderPass::end_occlusion_query");
api_log!("RenderPass::end_occlusion_query");
let scope = PassErrorScope::EndOcclusionQuery;

end_occlusion_query(raw, &*query_set_guard, &mut active_query)
Expand All @@ -2244,7 +2245,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
query_set_id,
query_index,
} => {
log::trace!("RenderPass::begin_pipeline_statistics_query {query_set_id:?} {query_index}");
api_log!("RenderPass::begin_pipeline_statistics_query {query_set_id:?} {query_index}");
let scope = PassErrorScope::BeginPipelineStatisticsQuery;

let query_set = tracker
Expand All @@ -2264,14 +2265,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.map_pass_err(scope)?;
}
RenderCommand::EndPipelineStatisticsQuery => {
log::trace!("RenderPass::end_pipeline_statistics_query");
api_log!("RenderPass::end_pipeline_statistics_query");
let scope = PassErrorScope::EndPipelineStatisticsQuery;

end_pipeline_statistics_query(raw, &*query_set_guard, &mut active_query)
.map_pass_err(scope)?;
}
RenderCommand::ExecuteBundle(bundle_id) => {
log::trace!("RenderPass::execute_bundle {bundle_id:?}");
api_log!("RenderPass::execute_bundle {bundle_id:?}");
let scope = PassErrorScope::ExecuteBundle;
let bundle: &command::RenderBundle<A> = tracker
.bundles
Expand Down
19 changes: 19 additions & 0 deletions wgpu-core/src/command/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "trace")]
use crate::device::trace::Command as TraceCommand;
use crate::{
api_log,
command::{clear_texture, CommandBuffer, CommandEncoderError},
conv,
device::{Device, MissingDownlevelFlags},
Expand Down Expand Up @@ -567,6 +568,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
size: BufferAddress,
) -> Result<(), CopyError> {
profiling::scope!("CommandEncoder::copy_buffer_to_buffer");
api_log!(
"CommandEncoder::copy_buffer_to_buffer {source:?} -> {destination:?} {size:?}bytes"
);

if source == destination {
return Err(TransferError::SameSourceDestinationBuffer.into());
Expand Down Expand Up @@ -727,6 +731,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
copy_size: &Extent3d,
) -> Result<(), CopyError> {
profiling::scope!("CommandEncoder::copy_buffer_to_texture");
api_log!(
"CommandEncoder::copy_buffer_to_texture {:?} -> {:?} {copy_size:?}",
source.buffer,
destination.texture
);

let hub = A::hub(self);

Expand Down Expand Up @@ -885,6 +894,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
copy_size: &Extent3d,
) -> Result<(), CopyError> {
profiling::scope!("CommandEncoder::copy_texture_to_buffer");
api_log!(
"CommandEncoder::copy_texture_to_buffer {:?} -> {:?} {copy_size:?}",
source.texture,
destination.buffer
);

let hub = A::hub(self);

Expand Down Expand Up @@ -1055,6 +1069,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
copy_size: &Extent3d,
) -> Result<(), CopyError> {
profiling::scope!("CommandEncoder::copy_texture_to_texture");
api_log!(
"CommandEncoder::copy_texture_to_texture {:?} -> {:?} {copy_size:?}",
source.texture,
destination.texture
);

let hub = A::hub(self);

Expand Down
Loading
Loading