Implemented automatic deallocation of texture space for dropped allocations

This commit is contained in:
Malte Veerman 2020-01-19 18:06:46 +01:00 committed by Héctor Ramón Jiménez
parent 8f9f44b9e8
commit 4617da2818
3 changed files with 88 additions and 85 deletions

View file

@ -91,17 +91,9 @@ impl Cache {
memory
}
pub fn trim(&mut self, texture_array: &mut TextureArray) {
pub fn trim(&mut self) {
let hits = &self.hits;
for (id, mem) in &self.map {
if let Memory::Device(allocation) = mem {
if !hits.contains(&id) {
texture_array.deallocate(allocation);
}
}
}
self.map.retain(|k, _| hits.contains(k));
self.hits.clear();
}