Deallocate atlas entries and remove padding

This commit is contained in:
Héctor Ramón Jiménez 2020-02-26 20:10:19 +01:00
parent 48d70280eb
commit d06d06e050
5 changed files with 82 additions and 44 deletions

View file

@ -95,10 +95,21 @@ impl Cache {
}
}
pub fn trim(&mut self) {
pub fn trim(&mut self, atlas: &mut Atlas) {
let hits = &self.hits;
self.map.retain(|k, _| hits.contains(k));
self.map.retain(|k, memory| {
let retain = hits.contains(k);
if !retain {
if let Memory::Device(entry) = memory {
atlas.remove(entry);
}
}
retain
});
self.hits.clear();
}