mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-16 08:53:20 +00:00
[core] Properly recycle Device::temp_suspected
.
Change `Device::untrack` to properly reuse the `ResourceMap` allocated for prior calls. The prior code tries to do this but always leaves `Device::temp_suspected` set to a new empty `ResourceMap`, leaving the previous value to be dropped by `ResourceMap::extend`. Change `ResourceMap::extend` to take `other` by reference, rather than taking it by value and dropping it.
This commit is contained in:
parent
5f464688e6
commit
0d70a7361d
@ -93,7 +93,7 @@ impl<A: HalApi> ResourceMaps<A> {
|
||||
destroyed_textures.clear();
|
||||
}
|
||||
|
||||
pub(crate) fn extend(&mut self, mut other: Self) {
|
||||
pub(crate) fn extend(&mut self, other: &mut Self) {
|
||||
let ResourceMaps {
|
||||
buffers,
|
||||
staging_buffers,
|
||||
|
@ -485,12 +485,14 @@ impl<A: HalApi> Device<A> {
|
||||
}
|
||||
|
||||
pub(crate) fn untrack(&self, trackers: &Tracker<A>) {
|
||||
// If we have a previously allocated `ResourceMap`, just use that.
|
||||
let mut temp_suspected = self
|
||||
.temp_suspected
|
||||
.lock()
|
||||
.replace(ResourceMaps::new())
|
||||
.unwrap();
|
||||
.take()
|
||||
.unwrap_or_else(|| ResourceMaps::new());
|
||||
temp_suspected.clear();
|
||||
|
||||
// As the tracker is cleared/dropped, we need to consider all the resources
|
||||
// that it references for destruction in the next GC pass.
|
||||
{
|
||||
@ -551,7 +553,11 @@ impl<A: HalApi> Device<A> {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.lock_life().suspected_resources.extend(temp_suspected);
|
||||
self.lock_life()
|
||||
.suspected_resources
|
||||
.extend(&mut temp_suspected);
|
||||
// Save this resource map for later reuse.
|
||||
*self.temp_suspected.lock() = Some(temp_suspected);
|
||||
}
|
||||
|
||||
pub(crate) fn create_buffer(
|
||||
|
Loading…
Reference in New Issue
Block a user