From 3be86226ae2f3a6269e9b527ed4e9029f976108e Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Fri, 29 Sep 2023 12:35:19 +0200 Subject: [PATCH] Trace logging adjustments --- wgpu-core/src/command/render.rs | 80 ++++++++++++++++++--------------- wgpu-core/src/device/global.rs | 12 ++--- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 9e2c533893..2c310ed043 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1314,7 +1314,10 @@ impl Global { timestamp_writes: Option<&RenderPassTimestampWrites>, occlusion_query_set_id: Option, ) -> Result<(), RenderPassError> { - profiling::scope!("CommandEncoder::run_render_pass"); + profiling::scope!( + "CommandEncoder::run_render_pass {}", + base.label.unwrap_or("") + ); let init_scope = PassErrorScope::Pass(encoder_id); let hub = A::hub(self); @@ -1423,6 +1426,8 @@ impl Global { num_dynamic_offsets, bind_group_id, } => { + log::trace!("RenderPass::set_bind_group {index} {bind_group_id:?}"); + let scope = PassErrorScope::SetBindGroup(bind_group_id); let max_bind_groups = device.limits.max_bind_groups; if index >= max_bind_groups { @@ -1501,6 +1506,8 @@ impl Global { } } RenderCommand::SetPipeline(pipeline_id) => { + log::trace!("RenderPass::set_pipeline {pipeline_id:?}"); + let scope = PassErrorScope::SetPipelineRender(pipeline_id); state.pipeline = Some(pipeline_id); @@ -1620,6 +1627,8 @@ impl Global { offset, size, } => { + log::trace!("RenderPass::set_index_buffer {buffer_id:?}"); + let scope = PassErrorScope::SetIndexBuffer(buffer_id); let buffer: &Buffer = info .usage_scope @@ -1666,6 +1675,8 @@ impl Global { offset, size, } => { + log::trace!("RenderPass::set_vertex_buffer {slot} {buffer_id:?}"); + let scope = PassErrorScope::SetVertexBuffer(buffer_id); let buffer: &Buffer = info .usage_scope @@ -1713,6 +1724,8 @@ impl Global { state.vertex.update_limits(); } RenderCommand::SetBlendConstant(ref color) => { + log::trace!("RenderPass::set_blend_constant"); + state.blend_constant = OptionalState::Set; let array = [ color.r as f32, @@ -1725,6 +1738,8 @@ impl Global { } } RenderCommand::SetStencilReference(value) => { + log::trace!("RenderPass::set_stencil_reference {value}"); + state.stencil_reference = value; if state .pipeline_flags @@ -1740,6 +1755,8 @@ impl Global { depth_min, depth_max, } => { + log::trace!("RenderPass::set_viewport {rect:?}"); + let scope = PassErrorScope::SetViewport; if rect.x < 0.0 || rect.y < 0.0 @@ -1776,6 +1793,8 @@ impl Global { size_bytes, values_offset, } => { + log::trace!("RenderPass::set_push_constants"); + let scope = PassErrorScope::SetPushConstant; let values_offset = values_offset .ok_or(RenderPassErrorInner::InvalidValuesOffset) @@ -1804,6 +1823,8 @@ impl Global { } } RenderCommand::SetScissor(ref rect) => { + log::trace!("RenderPass::set_scissor_rect {rect:?}"); + let scope = PassErrorScope::SetScissorRect; if rect.x + rect.w > info.extent.width || rect.y + rect.h > info.extent.height @@ -1827,6 +1848,10 @@ impl Global { first_vertex, first_instance, } => { + log::trace!( + "RenderPass::draw {vertex_count} {instance_count} {first_vertex} {first_instance}" + ); + let indexed = false; let scope = PassErrorScope::Draw { indexed, @@ -1869,6 +1894,8 @@ impl Global { base_vertex, first_instance, } => { + log::trace!("RenderPass::draw_indexed {index_count} {instance_count} {first_index} {base_vertex} {first_instance}"); + let indexed = true; let scope = PassErrorScope::Draw { indexed, @@ -1917,6 +1944,8 @@ impl Global { count, indexed, } => { + log::trace!("RenderPass::draw_indirect (indexed:{indexed}) {buffer_id:?} {offset} {count:?}"); + let scope = PassErrorScope::Draw { indexed, indirect: true, @@ -1991,6 +2020,8 @@ impl Global { max_count, indexed, } => { + log::trace!("RenderPass::multi_draw_indirect_count (indexed:{indexed}) {buffer_id:?} {offset} {count_buffer_id:?} {count_buffer_offset:?} {max_count:?}"); + let scope = PassErrorScope::Draw { indexed, indirect: true, @@ -2104,12 +2135,16 @@ impl Global { let label = str::from_utf8(&base.string_data[string_offset..string_offset + len]) .unwrap(); + + log::trace!("RenderPass::push_debug_group {label:?}"); string_offset += len; unsafe { raw.begin_debug_marker(label); } } RenderCommand::PopDebugGroup => { + log::trace!("RenderPass::pop_debug_group"); + let scope = PassErrorScope::PopDebugGroup; if state.debug_scope_depth == 0 { return Err(RenderPassErrorInner::InvalidPopDebugGroup) @@ -2124,6 +2159,7 @@ impl Global { let label = str::from_utf8(&base.string_data[string_offset..string_offset + len]) .unwrap(); + log::trace!("RenderPass::insert_debug_marker {label:?}"); string_offset += len; unsafe { raw.insert_debug_marker(label); @@ -2133,6 +2169,7 @@ impl Global { query_set_id, query_index, } => { + log::trace!("RenderPass::write_timestamps {query_set_id:?} {query_index}"); let scope = PassErrorScope::WriteTimestamp; device @@ -2156,6 +2193,7 @@ impl Global { .map_pass_err(scope)?; } RenderCommand::BeginOcclusionQuery { query_index } => { + log::trace!("RenderPass::begin_occlusion_query {query_index}"); let scope = PassErrorScope::BeginOcclusionQuery; let query_set_id = occlusion_query_set_id @@ -2180,6 +2218,7 @@ impl Global { .map_pass_err(scope)?; } RenderCommand::EndOcclusionQuery => { + log::trace!("RenderPass::end_occlusion_query"); let scope = PassErrorScope::EndOcclusionQuery; end_occlusion_query(raw, &*query_set_guard, &mut active_query) @@ -2189,6 +2228,7 @@ impl Global { query_set_id, query_index, } => { + log::trace!("RenderPass::begin_pipeline_statistics_query {query_set_id:?} {query_index}"); let scope = PassErrorScope::BeginPipelineStatisticsQuery; let query_set = cmd_buf @@ -2209,12 +2249,14 @@ impl Global { .map_pass_err(scope)?; } RenderCommand::EndPipelineStatisticsQuery => { + log::trace!("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:?}"); let scope = PassErrorScope::ExecuteBundle; let bundle: &command::RenderBundle = cmd_buf .trackers @@ -2393,7 +2435,6 @@ 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; } @@ -2411,7 +2452,6 @@ pub mod render_ffi { offset: BufferAddress, size: Option, ) { - log::trace!("RenderPass::set_vertex_buffer {buffer_id:?}"); pass.base.commands.push(RenderCommand::SetVertexBuffer { slot, buffer_id, @@ -2428,13 +2468,11 @@ pub mod render_ffi { offset: BufferAddress, size: Option, ) { - 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)); @@ -2442,7 +2480,6 @@ pub mod render_ffi { #[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)); @@ -2458,7 +2495,6 @@ 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, @@ -2474,7 +2510,6 @@ 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 })); @@ -2492,7 +2527,6 @@ 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, @@ -2530,10 +2564,6 @@ 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, @@ -2551,7 +2581,6 @@ 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, @@ -2567,7 +2596,6 @@ 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, @@ -2582,7 +2610,6 @@ 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, @@ -2598,7 +2625,6 @@ 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, @@ -2614,7 +2640,6 @@ 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, @@ -2632,7 +2657,6 @@ 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 { @@ -2654,7 +2678,6 @@ 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 { @@ -2677,10 +2700,7 @@ pub mod render_ffi { label: RawString, color: u32, ) { - let cstr = unsafe { ffi::CStr::from_ptr(label) }; - log::trace!("RenderPass::push_debug_group {cstr:?}"); - - let bytes = cstr.to_bytes(); + let bytes = unsafe { ffi::CStr::from_ptr(label) }.to_bytes(); pass.base.string_data.extend_from_slice(bytes); pass.base.commands.push(RenderCommand::PushDebugGroup { @@ -2691,7 +2711,6 @@ 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); } @@ -2705,10 +2724,7 @@ pub mod render_ffi { label: RawString, color: u32, ) { - let cstr = unsafe { ffi::CStr::from_ptr(label) }; - log::trace!("RenderPass::insert_debug_marker {cstr:?}"); - - let bytes = cstr.to_bytes(); + let bytes = unsafe { ffi::CStr::from_ptr(label) }.to_bytes(); pass.base.string_data.extend_from_slice(bytes); pass.base.commands.push(RenderCommand::InsertDebugMarker { @@ -2723,7 +2739,6 @@ 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, @@ -2735,7 +2750,6 @@ 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 }); @@ -2743,7 +2757,6 @@ pub mod render_ffi { #[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); } @@ -2753,7 +2766,6 @@ 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 { @@ -2764,7 +2776,6 @@ 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); @@ -2780,7 +2791,6 @@ 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) } { diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 50ef913295..a9be65ae8f 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -262,7 +262,7 @@ impl Global { }; let id = fid.assign(buffer, &mut token); - log::trace!("Device::create_buffer -> {:?}", id); + log::trace!("Device::create_buffer -> {:?}", id.0); device .trackers @@ -616,7 +616,7 @@ impl Global { let ref_count = texture.life_guard.add_ref(); let id = fid.assign(texture, &mut token); - log::trace!("Device::create_texture -> {id:?}"); + log::trace!("Device::create_texture -> {:?}", id.0); device.trackers.lock().textures.insert_single( id.0, @@ -696,7 +696,7 @@ impl Global { let ref_count = texture.life_guard.add_ref(); let id = fid.assign(texture, &mut token); - log::trace!("Device::create_texture -> {id:?}"); + log::trace!("Device::create_texture -> {:?}", id.0); device.trackers.lock().textures.insert_single( id.0, @@ -756,7 +756,7 @@ impl Global { let ref_count = buffer.life_guard.add_ref(); let id = fid.assign(buffer, &mut token); - log::trace!("Device::create_buffer -> {id:?}"); + log::trace!("Device::create_buffer -> {:?}", id.0); device .trackers @@ -1869,7 +1869,7 @@ impl Global { let ref_count = pipeline.life_guard.add_ref(); let id = fid.assign(pipeline, &mut token); - log::trace!("Device::create_render_pipeline -> {id:?}"); + log::trace!("Device::create_render_pipeline -> {:?}", id.0); device .trackers @@ -2014,7 +2014,7 @@ impl Global { let ref_count = pipeline.life_guard.add_ref(); let id = fid.assign(pipeline, &mut token); - log::trace!("Device::create_compute_pipeline -> {id:?}"); + log::trace!("Device::create_compute_pipeline -> {:?}", id.0); device .trackers