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

Add trace level logging to most API entry points #4183

Merged
merged 2 commits into from
Sep 28, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ By @wumpf in [#4147](https://github.com/gfx-rs/wgpu/pull/4147)
- Make `WGPU_POWER_PREF=none` a valid value. By @fornwall in [4076](https://github.com/gfx-rs/wgpu/pull/4076)
- Support dual source blending in OpenGL ES, Metal, Vulkan & DX12. By @freqmod in [4022](https://github.com/gfx-rs/wgpu/pull/4022)
- Add stub support for device destroy and device validity. By @bradwerth in [4163](https://github.com/gfx-rs/wgpu/pull/4163)
- Add trace-level logging for most entry points in wgpu-core By @nical in [4183](https://github.com/gfx-rs/wgpu/pull/4183)

#### Vulkan

Expand Down
4 changes: 3 additions & 1 deletion wgpu-core/src/command/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
offset: BufferAddress,
size: Option<BufferSize>,
) -> Result<(), ClearError> {
profiling::scope!("CommandEncoder::fill_buffer");
profiling::scope!("CommandEncoder::clear_buffer");
log::trace!("CommandEncoder::clear_buffer {dst:?}");

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -158,6 +159,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
subresource_range: &ImageSubresourceRange,
) -> Result<(), ClearError> {
profiling::scope!("CommandEncoder::clear_texture");
log::trace!("CommandEncoder::clear_texture {dst:?}");

let hub = A::hub(self);
let mut token = Token::root();
Expand Down
3 changes: 3 additions & 0 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
label: &str,
) -> Result<(), CommandEncoderError> {
profiling::scope!("CommandEncoder::push_debug_group");
log::trace!("CommandEncoder::push_debug_group {label}");

let hub = A::hub(self);
let mut token = Token::root();
Expand All @@ -416,6 +417,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
label: &str,
) -> Result<(), CommandEncoderError> {
profiling::scope!("CommandEncoder::insert_debug_marker");
log::trace!("CommandEncoder::insert_debug_marker {label}");

let hub = A::hub(self);
let mut token = Token::root();
Expand All @@ -440,6 +442,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
encoder_id: id::CommandEncoderId,
) -> Result<(), CommandEncoderError> {
profiling::scope!("CommandEncoder::pop_debug_marker");
log::trace!("CommandEncoder::pop_debug_group");

let hub = A::hub(self);
let mut token = Token::root();
Expand Down
36 changes: 34 additions & 2 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,7 @@ pub mod render_ffi {
pass: &mut RenderPass,
pipeline_id: id::RenderPipelineId,
) {
log::trace!("RenderPass::set_pipeline {pipeline_id:?}");
if pass.current_pipeline.set_and_check_redundant(pipeline_id) {
return;
}
Expand All @@ -2410,6 +2411,7 @@ pub mod render_ffi {
offset: BufferAddress,
size: Option<BufferSize>,
) {
log::trace!("RenderPass::set_vertex_buffer {buffer_id:?}");
pass.base.commands.push(RenderCommand::SetVertexBuffer {
slot,
buffer_id,
Expand All @@ -2426,18 +2428,21 @@ pub mod render_ffi {
offset: BufferAddress,
size: Option<BufferSize>,
) {
log::trace!("RenderPass::set_index_buffer {buffer:?}");
pass.set_index_buffer(buffer, index_format, offset, size);
}

#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_blend_constant(pass: &mut RenderPass, color: &Color) {
log::trace!("RenderPass::set_blend_constant");
pass.base
.commands
.push(RenderCommand::SetBlendConstant(*color));
}

#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_stencil_reference(pass: &mut RenderPass, value: u32) {
log::trace!("RenderPass::set_stencil_reference {value}");
pass.base
.commands
.push(RenderCommand::SetStencilReference(value));
Expand All @@ -2453,6 +2458,7 @@ pub mod render_ffi {
depth_min: f32,
depth_max: f32,
) {
log::trace!("RenderPass::set_viewport {x} {y} {w} {h}");
pass.base.commands.push(RenderCommand::SetViewport {
rect: Rect { x, y, w, h },
depth_min,
Expand All @@ -2468,6 +2474,7 @@ pub mod render_ffi {
w: u32,
h: u32,
) {
log::trace!("RenderPass::set_scissor_rect {x} {y} {w} {h}");
pass.base
.commands
.push(RenderCommand::SetScissor(Rect { x, y, w, h }));
Expand All @@ -2485,6 +2492,7 @@ pub mod render_ffi {
size_bytes: u32,
data: *const u8,
) {
log::trace!("RenderPass::set_push_constants");
assert_eq!(
offset & (wgt::PUSH_CONSTANT_ALIGNMENT - 1),
0,
Expand Down Expand Up @@ -2522,6 +2530,10 @@ pub mod render_ffi {
first_vertex: u32,
first_instance: u32,
) {
log::trace!(
"RenderPass::draw {vertex_count} {instance_count} {first_vertex} {first_instance}"
);

pass.base.commands.push(RenderCommand::Draw {
vertex_count,
instance_count,
Expand All @@ -2539,6 +2551,7 @@ pub mod render_ffi {
base_vertex: i32,
first_instance: u32,
) {
log::trace!("RenderPass::draw_indexed {index_count} {instance_count} {first_index} {base_vertex} {first_instance}");
pass.base.commands.push(RenderCommand::DrawIndexed {
index_count,
instance_count,
Expand All @@ -2554,6 +2567,7 @@ pub mod render_ffi {
buffer_id: id::BufferId,
offset: BufferAddress,
) {
log::trace!("RenderPass::draw_indirect {buffer_id:?} {offset}");
pass.base.commands.push(RenderCommand::MultiDrawIndirect {
buffer_id,
offset,
Expand All @@ -2568,6 +2582,7 @@ pub mod render_ffi {
buffer_id: id::BufferId,
offset: BufferAddress,
) {
log::trace!("RenderPass::draw_indexed_indirect {buffer_id:?} {offset}");
pass.base.commands.push(RenderCommand::MultiDrawIndirect {
buffer_id,
offset,
Expand All @@ -2583,6 +2598,7 @@ pub mod render_ffi {
offset: BufferAddress,
count: u32,
) {
log::trace!("RenderPass::multi_draw_indirect {buffer_id:?} {offset} {count}");
pass.base.commands.push(RenderCommand::MultiDrawIndirect {
buffer_id,
offset,
Expand All @@ -2598,6 +2614,7 @@ pub mod render_ffi {
offset: BufferAddress,
count: u32,
) {
log::trace!("RenderPass::multi_draw_indexed_indirect {buffer_id:?} {offset} {count}");
pass.base.commands.push(RenderCommand::MultiDrawIndirect {
buffer_id,
offset,
Expand All @@ -2615,6 +2632,7 @@ pub mod render_ffi {
count_buffer_offset: BufferAddress,
max_count: u32,
) {
log::trace!("RenderPass::multi_draw_indirect_count {buffer_id:?} {offset} {count_buffer_id:?} {count_buffer_offset} {max_count}");
pass.base
.commands
.push(RenderCommand::MultiDrawIndirectCount {
Expand All @@ -2636,6 +2654,7 @@ pub mod render_ffi {
count_buffer_offset: BufferAddress,
max_count: u32,
) {
log::trace!("RenderPass::multi_draw_indexed_indirect_count {buffer_id:?} {offset} {count_buffer_id:?} {count_buffer_offset} {max_count}");
pass.base
.commands
.push(RenderCommand::MultiDrawIndirectCount {
Expand All @@ -2658,7 +2677,10 @@ pub mod render_ffi {
label: RawString,
color: u32,
) {
let bytes = unsafe { ffi::CStr::from_ptr(label) }.to_bytes();
let cstr = unsafe { ffi::CStr::from_ptr(label) };
log::trace!("RenderPass::push_debug_group {cstr:?}");

let bytes = cstr.to_bytes();
pass.base.string_data.extend_from_slice(bytes);

pass.base.commands.push(RenderCommand::PushDebugGroup {
Expand All @@ -2669,6 +2691,7 @@ pub mod render_ffi {

#[no_mangle]
pub extern "C" fn wgpu_render_pass_pop_debug_group(pass: &mut RenderPass) {
log::trace!("RenderPass::pop_debug_group");
pass.base.commands.push(RenderCommand::PopDebugGroup);
}

Expand All @@ -2682,7 +2705,10 @@ pub mod render_ffi {
label: RawString,
color: u32,
) {
let bytes = unsafe { ffi::CStr::from_ptr(label) }.to_bytes();
let cstr = unsafe { ffi::CStr::from_ptr(label) };
log::trace!("RenderPass::insert_debug_marker {cstr:?}");

let bytes = cstr.to_bytes();
pass.base.string_data.extend_from_slice(bytes);

pass.base.commands.push(RenderCommand::InsertDebugMarker {
Expand All @@ -2697,6 +2723,7 @@ pub mod render_ffi {
query_set_id: id::QuerySetId,
query_index: u32,
) {
log::trace!("RenderPass::write_timestamps {query_set_id:?} {query_index}");
pass.base.commands.push(RenderCommand::WriteTimestamp {
query_set_id,
query_index,
Expand All @@ -2708,13 +2735,15 @@ pub mod render_ffi {
pass: &mut RenderPass,
query_index: u32,
) {
log::trace!("RenderPass::begin_occlusion_query {query_index}");
pass.base
.commands
.push(RenderCommand::BeginOcclusionQuery { query_index });
}

#[no_mangle]
pub extern "C" fn wgpu_render_pass_end_occlusion_query(pass: &mut RenderPass) {
log::trace!("RenderPass::end_occlusion_query");
pass.base.commands.push(RenderCommand::EndOcclusionQuery);
}

Expand All @@ -2724,6 +2753,7 @@ pub mod render_ffi {
query_set_id: id::QuerySetId,
query_index: u32,
) {
log::trace!("RenderPass::begin_pipeline_statistics_query {query_set_id:?} {query_index}");
pass.base
.commands
.push(RenderCommand::BeginPipelineStatisticsQuery {
Expand All @@ -2734,6 +2764,7 @@ pub mod render_ffi {

#[no_mangle]
pub extern "C" fn wgpu_render_pass_end_pipeline_statistics_query(pass: &mut RenderPass) {
log::trace!("RenderPass::end_pipeline_statistics_query");
pass.base
.commands
.push(RenderCommand::EndPipelineStatisticsQuery);
Expand All @@ -2749,6 +2780,7 @@ pub mod render_ffi {
render_bundle_ids: *const id::RenderBundleId,
render_bundle_ids_length: usize,
) {
log::trace!("RenderPass::execute_bundles");
for &bundle_id in
unsafe { slice::from_raw_parts(render_bundle_ids, render_bundle_ids_length) }
{
Expand Down
Loading