@@ -468,6 +468,20 @@ impl<A: HalApi> LifetimeTracker<A> {
468
468
}
469
469
470
470
impl < A : HalApi > LifetimeTracker < A > {
471
+ /// Remove abandoned resources from `resources_map` and return them.
472
+ ///
473
+ /// Consult `trackers` to see which resources in `resources_map` are
474
+ /// abandoned (that is, referenced only by `resources_map` and `trackers`
475
+ /// itself) and remove them from `resources_map`.
476
+ ///
477
+ /// If the abandoned resources are in use by a command submission still in
478
+ /// flight, as listed in `active`, add them to that submission's
479
+ /// `ActiveSubmission::last_resources` map.
480
+ ///
481
+ /// Use `get_resource_map` to find the appropriate member of
482
+ /// `ActiveSubmission::last_resources` to hold resources of type `R`.
483
+ ///
484
+ /// Return a vector of all the abandoned resources that were removed.
471
485
fn triage_resources < R > (
472
486
resources_map : & mut FastHashMap < TrackerIndex , Arc < R > > ,
473
487
active : & mut [ ActiveSubmission < A > ] ,
@@ -584,6 +598,12 @@ impl<A: HalApi> LifetimeTracker<A> {
584
598
& mut trackers. views ,
585
599
|maps| & mut maps. texture_views ,
586
600
) ;
601
+ // You might be tempted to add the view's parent texture to
602
+ // suspected_resources here, but don't. Texture views get dropped all
603
+ // the time, and once a texture is added to
604
+ // `LifetimeTracker::suspected_resources` it remains there until it's
605
+ // actually dropped, which for long-lived textures could be at the end
606
+ // of execution.
587
607
self
588
608
}
589
609
@@ -782,7 +802,8 @@ impl<A: HalApi> LifetimeTracker<A> {
782
802
pub ( crate ) fn triage_suspected ( & mut self , trackers : & Mutex < Tracker < A > > ) {
783
803
profiling:: scope!( "triage_suspected" ) ;
784
804
785
- //NOTE: the order is important to release resources that depends between each other!
805
+ // NOTE: The order in which resource types are processed here is
806
+ // crucial. See "Entrained resources" in this function's doc comment.
786
807
self . triage_suspected_render_bundles ( trackers) ;
787
808
self . triage_suspected_compute_pipelines ( trackers) ;
788
809
self . triage_suspected_render_pipelines ( trackers) ;
0 commit comments