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 logging to LifetimeTracker::triage_suspected. #2569

Merged
merged 2 commits into from
Apr 1, 2022
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
12 changes: 11 additions & 1 deletion wgpu-core/src/device/life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ impl<A: HalApi> LifetimeTracker<A> {

while let Some(id) = self.suspected_resources.render_bundles.pop() {
if trackers.bundles.remove_abandoned(id) {
log::debug!("Bundle {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyRenderBundle(id.0));
Expand All @@ -463,6 +464,7 @@ impl<A: HalApi> LifetimeTracker<A> {

while let Some(id) = self.suspected_resources.bind_groups.pop() {
if trackers.bind_groups.remove_abandoned(id) {
log::debug!("Bind group {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyBindGroup(id.0));
Expand Down Expand Up @@ -494,6 +496,7 @@ impl<A: HalApi> LifetimeTracker<A> {
let mut list = mem::take(&mut self.suspected_resources.texture_views);
for id in list.drain(..) {
if trackers.views.remove_abandoned(id) {
log::debug!("Texture view {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyTextureView(id.0));
Expand All @@ -520,6 +523,7 @@ impl<A: HalApi> LifetimeTracker<A> {

for id in self.suspected_resources.textures.drain(..) {
if trackers.textures.remove_abandoned(id) {
log::debug!("Texture {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyTexture(id.0));
Expand Down Expand Up @@ -556,6 +560,7 @@ impl<A: HalApi> LifetimeTracker<A> {

for id in self.suspected_resources.samplers.drain(..) {
if trackers.samplers.remove_abandoned(id) {
log::debug!("Sampler {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroySampler(id.0));
Expand All @@ -580,11 +585,11 @@ impl<A: HalApi> LifetimeTracker<A> {

for id in self.suspected_resources.buffers.drain(..) {
if trackers.buffers.remove_abandoned(id) {
log::debug!("Buffer {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyBuffer(id.0));
}
log::debug!("Buffer {:?} is detached", id);

if let Some(res) = hub.buffers.unregister_locked(id.0, &mut *guard) {
let submit_index = res.life_guard.life_count();
Expand All @@ -608,6 +613,7 @@ impl<A: HalApi> LifetimeTracker<A> {

for id in self.suspected_resources.compute_pipelines.drain(..) {
if trackers.compute_pipes.remove_abandoned(id) {
log::debug!("Compute pipeline {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyComputePipeline(id.0));
Expand All @@ -632,6 +638,7 @@ impl<A: HalApi> LifetimeTracker<A> {

for id in self.suspected_resources.render_pipelines.drain(..) {
if trackers.render_pipes.remove_abandoned(id) {
log::debug!("Render pipeline {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyRenderPipeline(id.0));
Expand Down Expand Up @@ -660,6 +667,7 @@ impl<A: HalApi> LifetimeTracker<A> {
{
//Note: this has to happen after all the suspected pipelines are destroyed
if ref_count.load() == 1 {
log::debug!("Pipeline layout {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyPipelineLayout(id.0));
Expand All @@ -684,6 +692,7 @@ impl<A: HalApi> LifetimeTracker<A> {
//Note: same BGL can appear multiple times in the list, but only the last
// encounter could drop the refcount to 0.
if guard[id].multi_ref_count.dec_and_check_empty() {
log::debug!("Bind group layout {:?} will be destroyed", id);
#[cfg(feature = "trace")]
if let Some(t) = trace {
t.lock().add(trace::Action::DestroyBindGroupLayout(id.0));
Expand All @@ -701,6 +710,7 @@ impl<A: HalApi> LifetimeTracker<A> {

for id in self.suspected_resources.query_sets.drain(..) {
if trackers.query_sets.remove_abandoned(id) {
log::debug!("Query set {:?} will be destroyed", id);
// #[cfg(feature = "trace")]
// trace.map(|t| t.lock().add(trace::Action::DestroyComputePipeline(id.0)));
if let Some(res) = hub.query_sets.unregister_locked(id.0, &mut *guard) {
Expand Down
16 changes: 15 additions & 1 deletion wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3320,11 +3320,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn buffer_drop<A: HalApi>(&self, buffer_id: id::BufferId, wait: bool) {
profiling::scope!("drop", "Buffer");
log::debug!("buffer {:?} is dropped", buffer_id);

let hub = A::hub(self);
let mut token = Token::root();

log::info!("Buffer {:?} is dropped", buffer_id);
let (ref_count, last_submit_index, device_id) = {
let (mut buffer_guard, _) = hub.buffers.write(&mut token);
match buffer_guard.get_mut(buffer_id) {
Expand Down Expand Up @@ -3562,6 +3562,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn texture_drop<A: HalApi>(&self, texture_id: id::TextureId, wait: bool) {
profiling::scope!("drop", "Texture");
log::debug!("texture {:?} is dropped", texture_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -3667,6 +3668,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
wait: bool,
) -> Result<(), resource::TextureViewDestroyError> {
profiling::scope!("drop", "TextureView");
log::debug!("texture view {:?} is dropped", texture_view_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -3760,6 +3762,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn sampler_drop<A: HalApi>(&self, sampler_id: id::SamplerId) {
profiling::scope!("drop", "Sampler");
log::debug!("sampler {:?} is dropped", sampler_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -3859,6 +3862,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn bind_group_layout_drop<A: HalApi>(&self, bind_group_layout_id: id::BindGroupLayoutId) {
profiling::scope!("drop", "BindGroupLayout");
log::debug!("bind group layout {:?} is dropped", bind_group_layout_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -3932,6 +3936,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn pipeline_layout_drop<A: HalApi>(&self, pipeline_layout_id: id::PipelineLayoutId) {
profiling::scope!("drop", "PipelineLayout");
log::debug!("pipeline layout {:?} is dropped", pipeline_layout_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -4026,6 +4031,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn bind_group_drop<A: HalApi>(&self, bind_group_id: id::BindGroupId) {
profiling::scope!("drop", "BindGroup");
log::debug!("bind group {:?} is dropped", bind_group_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -4166,6 +4172,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn shader_module_drop<A: HalApi>(&self, shader_module_id: id::ShaderModuleId) {
profiling::scope!("drop", "ShaderModule");
log::debug!("shader module {:?} is dropped", shader_module_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -4240,6 +4247,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn command_encoder_drop<A: HalApi>(&self, command_encoder_id: id::CommandEncoderId) {
profiling::scope!("drop", "CommandEncoder");
log::debug!("command encoder {:?} is dropped", command_encoder_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand All @@ -4256,6 +4264,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn command_buffer_drop<A: HalApi>(&self, command_buffer_id: id::CommandBufferId) {
profiling::scope!("drop", "CommandBuffer");
log::debug!("command buffer {:?} is dropped", command_buffer_id);
self.command_encoder_drop::<A>(command_buffer_id)
}

Expand Down Expand Up @@ -4334,6 +4343,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn render_bundle_drop<A: HalApi>(&self, render_bundle_id: id::RenderBundleId) {
profiling::scope!("drop", "RenderBundle");
log::debug!("render bundle {:?} is dropped", render_bundle_id);
let hub = A::hub(self);
let mut token = Token::root();

Expand Down Expand Up @@ -4410,6 +4420,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn query_set_drop<A: HalApi>(&self, query_set_id: id::QuerySetId) {
profiling::scope!("drop", "QuerySet");
log::debug!("query set {:?} is dropped", query_set_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down Expand Up @@ -4542,6 +4553,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn render_pipeline_drop<A: HalApi>(&self, render_pipeline_id: id::RenderPipelineId) {
profiling::scope!("drop", "RenderPipeline");
log::debug!("render pipeline {:?} is dropped", render_pipeline_id);
let hub = A::hub(self);
let mut token = Token::root();
let (device_guard, mut token) = hub.devices.read(&mut token);
Expand Down Expand Up @@ -4673,6 +4685,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn compute_pipeline_drop<A: HalApi>(&self, compute_pipeline_id: id::ComputePipelineId) {
profiling::scope!("drop", "ComputePipeline");
log::debug!("compute pipeline {:?} is dropped", compute_pipeline_id);
let hub = A::hub(self);
let mut token = Token::root();
let (device_guard, mut token) = hub.devices.read(&mut token);
Expand Down Expand Up @@ -4967,6 +4980,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pub fn device_drop<A: HalApi>(&self, device_id: id::DeviceId) {
profiling::scope!("drop", "Device");
log::debug!("device {:?} is dropped", device_id);

let hub = A::hub(self);
let mut token = Token::root();
Expand Down