diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 70045d13e..8f52a4372 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -21,7 +21,7 @@ use crate::{ TextureInner, Trackable, }, resource_log, - track::{self, TrackerIndex}, + track::{self, Tracker, TrackerIndex}, FastHashMap, SubmissionIndex, }; @@ -155,6 +155,7 @@ pub enum TempResource { pub(crate) struct EncoderInFlight { raw: A::CommandEncoder, cmd_buffers: Vec, + trackers: Tracker, } impl EncoderInFlight { @@ -164,6 +165,12 @@ impl EncoderInFlight { /// reused. pub(crate) unsafe fn land(mut self) -> A::CommandEncoder { unsafe { self.raw.reset_all(self.cmd_buffers.into_iter()) }; + { + // This involves actually decrementing the ref count of all command buffer + // resources, so can be _very_ expensive. + profiling::scope!("drop command buffer trackers"); + drop(self.trackers); + } self.raw } } @@ -285,6 +292,7 @@ impl PendingWrites { Some(EncoderInFlight { raw: mem::replace(&mut self.command_encoder, new_encoder), cmd_buffers: mem::take(&mut self.executing_command_buffers), + trackers: Tracker::new(), }) } else { None @@ -1365,14 +1373,8 @@ impl Global { active_executions.push(EncoderInFlight { raw: baked.encoder, cmd_buffers: baked.list, + trackers: baked.trackers, }); - - { - // This involves actually decrementing the ref count of all command buffer - // resources, so can be _very_ expensive. - profiling::scope!("drop command buffer trackers"); - drop(baked.trackers); - } } log::trace!("Device after submission {}", submit_index);