mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
[core] Refactor LifetimeTracker::triage_resources
.
Check whether the resource is abandoned first, since none of the rest of the work is necessary otherwise. Rename `non_referenced_resources` to `last_resources`. This function copes with various senses in which the resource might be referenced or not. Instead, `last_resources` is the name of the `ActiveSubmission` member this may point to, which is more specific. Move the use of `last_resources` immediately after its production.
This commit is contained in:
parent
64777d4fd8
commit
8d73e5a9cd
@ -493,20 +493,23 @@ impl<A: HalApi> LifetimeTracker<A> {
|
|||||||
{
|
{
|
||||||
let mut removed_resources = Vec::new();
|
let mut removed_resources = Vec::new();
|
||||||
resources_map.retain(|&index, resource| {
|
resources_map.retain(|&index, resource| {
|
||||||
|
if !trackers.remove_abandoned(index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this resource is used by commands in flight, save
|
||||||
|
// it in that submission's `last_resources` list.
|
||||||
let submit_index = resource.as_info().submission_index();
|
let submit_index = resource.as_info().submission_index();
|
||||||
let non_referenced_resources = active
|
let last_resources = active
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|a| a.index == submit_index)
|
.find(|a| a.index == submit_index)
|
||||||
.map(|a| &mut a.last_resources);
|
.map(|a| &mut a.last_resources);
|
||||||
|
if let Some(last_resources) = last_resources {
|
||||||
let is_removed = trackers.remove_abandoned(index);
|
get_resource_map(last_resources).insert(index, resource.clone());
|
||||||
if is_removed {
|
|
||||||
removed_resources.push(resource.clone());
|
|
||||||
if let Some(resources) = non_referenced_resources {
|
|
||||||
get_resource_map(resources).insert(index, resource.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
!is_removed
|
|
||||||
|
removed_resources.push(resource.clone());
|
||||||
|
false
|
||||||
});
|
});
|
||||||
removed_resources
|
removed_resources
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user