Fix cache eviction logic of active image allocations

This commit is contained in:
Héctor Ramón Jiménez 2025-10-26 09:18:19 +01:00
parent b072006f1a
commit 44cfb27e41
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 16 additions and 10 deletions

View file

@ -100,17 +100,21 @@ impl Cache {
let hits = &self.hits;
self.map.retain(|k, memory| {
// Retain active allocations
if let Memory::Device { allocation, .. } = memory
&& allocation
.as_ref()
.is_some_and(|allocation| allocation.strong_count() > 0)
{
return true;
}
let retain = hits.contains(k);
if !retain
&& let Memory::Device {
entry,
bind_group,
allocation: memory,
entry, bind_group, ..
} = memory
&& memory
.as_ref()
.is_none_or(|memory| memory.strong_count() == 0)
{
if let Some(bind_group) = bind_group.take() {
on_drop(bind_group);