Add Tracing and Instrument Entry Points

This commit is contained in:
Connor Fitzgerald committed 2020-06-20 14:26:50 -04:00
1 parent c7be94047d
commit 1b2cf3cd22
15 files changed
+213 -9

No files matched your search

+15 -1
View File
@@ -43,6 +43,7 @@ use crate::{
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Input, Storage, Token},
id,
resource::BufferUse,
span,
track::TrackerSet,
LifeGuard, RefCount, Stored, MAX_BIND_GROUPS,
};
@@ -62,6 +63,7 @@ impl RenderBundleEncoder {
parent_id: id::DeviceId,
base: Option<BasePass<RenderCommand>>,
) -> Self {
span!(_guard, TRACE, "RenderBundleEncoder::new");
RenderBundleEncoder {
base: base.unwrap_or_else(BasePass::new),
parent_id,
@@ -481,6 +483,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
desc: &wgt::RenderBundleDescriptor<Label>,
id_in: Input<G, id::RenderBundleId>,
) -> id::RenderBundleId {
span!(_guard, TRACE, "RenderBundleEncoder::finish");
let hub = B::hub(self);
let mut token = Token::root();
let (device_guard, mut token) = hub.devices.read(&mut token);
@@ -752,7 +755,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub mod bundle_ffi {
use super::{RenderBundleEncoder, RenderCommand};
use crate::{id, RawString};
use crate::{id, RawString, span};
use std::{convert::TryInto, slice};
use wgt::{BufferAddress, BufferSize, DynamicOffset};
@@ -770,6 +773,7 @@ pub mod bundle_ffi {
offsets: *const DynamicOffset,
offset_length: usize,
) {
span!(_guard, TRACE, "RenderBundle::set_bind_group");
bundle.base.commands.push(RenderCommand::SetBindGroup {
index: index.try_into().unwrap(),
num_dynamic_offsets: offset_length.try_into().unwrap(),
@@ -786,6 +790,7 @@ pub mod bundle_ffi {
bundle: &mut RenderBundleEncoder,
pipeline_id: id::RenderPipelineId,
) {
span!(_guard, TRACE, "RenderBundle::set_pipeline");
bundle
.base
.commands
@@ -799,6 +804,7 @@ pub mod bundle_ffi {
offset: BufferAddress,
size: Option<BufferSize>,
) {
span!(_guard, TRACE, "RenderBundle::set_index_buffer");
bundle.base.commands.push(RenderCommand::SetIndexBuffer {
buffer_id,
offset,
@@ -814,6 +820,7 @@ pub mod bundle_ffi {
offset: BufferAddress,
size: Option<BufferSize>,
) {
span!(_guard, TRACE, "RenderBundle::set_vertex_buffer");
bundle.base.commands.push(RenderCommand::SetVertexBuffer {
slot,
buffer_id,
@@ -830,6 +837,7 @@ pub mod bundle_ffi {
first_vertex: u32,
first_instance: u32,
) {
span!(_guard, TRACE, "RenderBundle::draw");
bundle.base.commands.push(RenderCommand::Draw {
vertex_count,
instance_count,
@@ -847,6 +855,7 @@ pub mod bundle_ffi {
base_vertex: i32,
first_instance: u32,
) {
span!(_guard, TRACE, "RenderBundle::draw_indexed");
bundle.base.commands.push(RenderCommand::DrawIndexed {
index_count,
instance_count,
@@ -862,6 +871,7 @@ pub mod bundle_ffi {
buffer_id: id::BufferId,
offset: BufferAddress,
) {
span!(_guard, TRACE, "RenderBundle::draw_indirect");
bundle
.base
.commands
@@ -874,6 +884,7 @@ pub mod bundle_ffi {
buffer_id: id::BufferId,
offset: BufferAddress,
) {
span!(_guard, TRACE, "RenderBundle::draw_indexed_indirect");
bundle
.base
.commands
@@ -885,11 +896,13 @@ pub mod bundle_ffi {
_bundle: &mut RenderBundleEncoder,
_label: RawString,
) {
span!(_guard, TRACE, "RenderBundle::push_debug_group");
//TODO
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_pop_debug_group(_bundle: &mut RenderBundleEncoder) {
span!(_guard, TRACE, "RenderBundle::pop_debug_group");
//TODO
}
@@ -898,6 +911,7 @@ pub mod bundle_ffi {
_bundle: &mut RenderBundleEncoder,
_label: RawString,
) {
span!(_guard, TRACE, "RenderBundle::insert_debug_marker");
//TODO
}
}
+10 -1
View File
@@ -11,6 +11,7 @@ use crate::{
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Token},
id,
resource::BufferUse,
span,
};
use hal::command::CommandBuffer as _;
@@ -106,6 +107,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
encoder_id: id::CommandEncoderId,
mut base: BasePassRef<ComputeCommand>,
) {
span!(_guard, TRACE, "CommandEncoder::run_compute_pass");
let hub = B::hub(self);
let mut token = Token::root();
@@ -314,7 +316,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub mod compute_ffi {
use super::{ComputeCommand, ComputePass};
use crate::{id, RawString};
use crate::{id, RawString, span};
use std::{convert::TryInto, ffi, slice};
use wgt::{BufferAddress, DynamicOffset};
@@ -332,6 +334,7 @@ pub mod compute_ffi {
offsets: *const DynamicOffset,
offset_length: usize,
) {
span!(_guard, TRACE, "ComputePass::set_bind_group");
pass.base.commands.push(ComputeCommand::SetBindGroup {
index: index.try_into().unwrap(),
num_dynamic_offsets: offset_length.try_into().unwrap(),
@@ -347,6 +350,7 @@ pub mod compute_ffi {
pass: &mut ComputePass,
pipeline_id: id::ComputePipelineId,
) {
span!(_guard, TRACE, "ComputePass::set_pipeline");
pass.base
.commands
.push(ComputeCommand::SetPipeline(pipeline_id));
@@ -359,6 +363,7 @@ pub mod compute_ffi {
groups_y: u32,
groups_z: u32,
) {
span!(_guard, TRACE, "ComputePass::dispatch");
pass.base
.commands
.push(ComputeCommand::Dispatch([groups_x, groups_y, groups_z]));
@@ -370,6 +375,7 @@ pub mod compute_ffi {
buffer_id: id::BufferId,
offset: BufferAddress,
) {
span!(_guard, TRACE, "ComputePass::dispatch_indirect");
pass.base
.commands
.push(ComputeCommand::DispatchIndirect { buffer_id, offset });
@@ -381,6 +387,7 @@ pub mod compute_ffi {
label: RawString,
color: u32,
) {
span!(_guard, TRACE, "ComputePass::push_debug_group");
let bytes = ffi::CStr::from_ptr(label).to_bytes();
pass.base.string_data.extend_from_slice(bytes);
@@ -392,6 +399,7 @@ pub mod compute_ffi {
#[no_mangle]
pub extern "C" fn wgpu_compute_pass_pop_debug_group(pass: &mut ComputePass) {
span!(_guard, TRACE, "ComputePass::pop_debug_group");
pass.base.commands.push(ComputeCommand::PopDebugGroup);
}
@@ -401,6 +409,7 @@ pub mod compute_ffi {
label: RawString,
color: u32,
) {
span!(_guard, TRACE, "ComputePass::insert_debug_marker");
let bytes = ffi::CStr::from_ptr(label).to_bytes();
pass.base.string_data.extend_from_slice(bytes);
+9
View File
@@ -20,6 +20,7 @@ use crate::{
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Storage, Token},
id,
resource::{Buffer, Texture},
span,
track::TrackerSet,
PrivateFeatures, Stored,
};
@@ -139,6 +140,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
encoder_id: id::CommandEncoderId,
_desc: &wgt::CommandBufferDescriptor,
) -> id::CommandBufferId {
span!(_guard, TRACE, "CommandEncoder::finish");
let hub = B::hub(self);
let mut token = Token::root();
let (swap_chain_guard, mut token) = hub.swap_chains.read(&mut token);
@@ -164,6 +167,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
encoder_id: id::CommandEncoderId,
label: &str,
) {
span!(_guard, TRACE, "CommandEncoder::push_debug_group");
let hub = B::hub(self);
let mut token = Token::root();
@@ -181,6 +186,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
encoder_id: id::CommandEncoderId,
label: &str,
) {
span!(_guard, TRACE, "CommandEncoder::insert_debug_marker");
let hub = B::hub(self);
let mut token = Token::root();
@@ -194,6 +201,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
pub fn command_encoder_pop_debug_group<B: GfxBackend>(&self, encoder_id: id::CommandEncoderId) {
span!(_guard, TRACE, "CommandEncoder::pop_debug_marker");
let hub = B::hub(self);
let mut token = Token::root();
+20 -1
View File
@@ -16,6 +16,7 @@ use crate::{
id,
pipeline::PipelineFlags,
resource::{BufferUse, TextureUse, TextureViewInner},
span,
track::TrackerSet,
Stored,
};
@@ -341,6 +342,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
color_attachments: &[ColorAttachmentDescriptor],
depth_stencil_attachment: Option<&DepthStencilAttachmentDescriptor>,
) {
span!(_guard, TRACE, "CommandEncoder::run_render_pass");
let hub = B::hub(self);
let mut token = Token::root();
@@ -1296,7 +1299,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub mod render_ffi {
use super::{super::Rect, RenderCommand, RenderPass};
use crate::{id, RawString};
use crate::{id, span, RawString};
use std::{convert::TryInto, ffi, slice};
use wgt::{BufferAddress, BufferSize, Color, DynamicOffset};
@@ -1314,6 +1317,7 @@ pub mod render_ffi {
offsets: *const DynamicOffset,
offset_length: usize,
) {
span!(_guard, TRACE, "RenderPass::set_bind_group");
pass.base.commands.push(RenderCommand::SetBindGroup {
index: index.try_into().unwrap(),
num_dynamic_offsets: offset_length.try_into().unwrap(),
@@ -1329,6 +1333,7 @@ pub mod render_ffi {
pass: &mut RenderPass,
pipeline_id: id::RenderPipelineId,
) {
span!(_guard, TRACE, "RenderPass::set_pipeline");
pass.base
.commands
.push(RenderCommand::SetPipeline(pipeline_id));
@@ -1341,6 +1346,7 @@ pub mod render_ffi {
offset: BufferAddress,
size: Option<BufferSize>,
) {
span!(_guard, TRACE, "RenderPass::set_index_buffer");
pass.base.commands.push(RenderCommand::SetIndexBuffer {
buffer_id,
offset,
@@ -1356,6 +1362,7 @@ pub mod render_ffi {
offset: BufferAddress,
size: Option<BufferSize>,
) {
span!(_guard, TRACE, "RenderPass::set_vertex_buffer");
pass.base.commands.push(RenderCommand::SetVertexBuffer {
slot,
buffer_id,
@@ -1366,6 +1373,7 @@ pub mod render_ffi {
#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_blend_color(pass: &mut RenderPass, color: &Color) {
span!(_guard, TRACE, "RenderPass::set_blend_color");
pass.base
.commands
.push(RenderCommand::SetBlendColor(*color));
@@ -1373,6 +1381,7 @@ pub mod render_ffi {
#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_stencil_reference(pass: &mut RenderPass, value: u32) {
span!(_guard, TRACE, "RenderPass::set_stencil_buffer");
pass.base
.commands
.push(RenderCommand::SetStencilReference(value));
@@ -1388,6 +1397,7 @@ pub mod render_ffi {
depth_min: f32,
depth_max: f32,
) {
span!(_guard, TRACE, "RenderPass::set_viewport");
pass.base.commands.push(RenderCommand::SetViewport {
rect: Rect { x, y, w, h },
depth_min,
@@ -1403,6 +1413,7 @@ pub mod render_ffi {
w: u32,
h: u32,
) {
span!(_guard, TRACE, "RenderPass::set_scissor_rect");
pass.base
.commands
.push(RenderCommand::SetScissor(Rect { x, y, w, h }));
@@ -1416,6 +1427,7 @@ pub mod render_ffi {
first_vertex: u32,
first_instance: u32,
) {
span!(_guard, TRACE, "RenderPass::draw");
pass.base.commands.push(RenderCommand::Draw {
vertex_count,
instance_count,
@@ -1433,6 +1445,7 @@ pub mod render_ffi {
base_vertex: i32,
first_instance: u32,
) {
span!(_guard, TRACE, "RenderPass::draw_indexed");
pass.base.commands.push(RenderCommand::DrawIndexed {
index_count,
instance_count,
@@ -1448,6 +1461,7 @@ pub mod render_ffi {
buffer_id: id::BufferId,
offset: BufferAddress,
) {
span!(_guard, TRACE, "RenderPass::draw_indirect");
pass.base
.commands
.push(RenderCommand::DrawIndirect { buffer_id, offset });
@@ -1459,6 +1473,7 @@ pub mod render_ffi {
buffer_id: id::BufferId,
offset: BufferAddress,
) {
span!(_guard, TRACE, "RenderPass::draw_indexed_indirect");
pass.base
.commands
.push(RenderCommand::DrawIndexedIndirect { buffer_id, offset });
@@ -1470,6 +1485,7 @@ pub mod render_ffi {
label: RawString,
color: u32,
) {
span!(_guard, TRACE, "RenderPass::push_debug_group");
let bytes = ffi::CStr::from_ptr(label).to_bytes();
pass.base.string_data.extend_from_slice(bytes);
@@ -1481,6 +1497,7 @@ pub mod render_ffi {
#[no_mangle]
pub extern "C" fn wgpu_render_pass_pop_debug_group(pass: &mut RenderPass) {
span!(_guard, TRACE, "RenderPass::pop_debug_group");
pass.base.commands.push(RenderCommand::PopDebugGroup);
}
@@ -1490,6 +1507,7 @@ pub mod render_ffi {
label: RawString,
color: u32,
) {
span!(_guard, TRACE, "RenderPass::insert_debug_marker");
let bytes = ffi::CStr::from_ptr(label).to_bytes();
pass.base.string_data.extend_from_slice(bytes);
@@ -1505,6 +1523,7 @@ pub mod render_ffi {
render_bundle_ids: *const id::RenderBundleId,
render_bundle_ids_length: usize,
) {
span!(_guard, TRACE, "RenderPass::execute_bundles");
for &bundle_id in slice::from_raw_parts(render_bundle_ids, render_bundle_ids_length) {
pass.base
.commands
+9
View File
@@ -10,6 +10,7 @@ use crate::{
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Storage, Token},
id::{BufferId, CommandEncoderId, TextureId},
resource::{BufferUse, Texture, TextureUse},
span,
};
use hal::command::CommandBuffer as _;
@@ -266,6 +267,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
destination_offset: BufferAddress,
size: BufferAddress,
) {
span!(_guard, TRACE, "CommandEncoder::copy_buffer_to_buffer");
let hub = B::hub(self);
let mut token = Token::root();
@@ -379,6 +382,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
destination: &TextureCopyView,
copy_size: &Extent3d,
) {
span!(_guard, TRACE, "CommandEncoder::copy_buffer_to_texture");
let hub = B::hub(self);
let mut token = Token::root();
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
@@ -472,6 +477,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
destination: &BufferCopyView,
copy_size: &Extent3d,
) {
span!(_guard, TRACE, "CommandEncoder::copy_texture_to_buffer");
let hub = B::hub(self);
let mut token = Token::root();
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
@@ -573,6 +580,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
destination: &TextureCopyView,
copy_size: &Extent3d,
) {
span!(_guard, TRACE, "CommandEncoder::copy_texture_to_texture");
let hub = B::hub(self);
let mut token = Token::root();