small fix for the softlock after lru cache removal

This commit is contained in:
CamilleLaVey 2026-04-03 00:07:04 -04:00 committed by crueter
parent cc553379d8
commit 18ad42f996

View file

@ -199,7 +199,8 @@ void TextureCache<P>::RunGarbageCollector() {
const auto CollectBelow = [this](u64 threshold) { const auto CollectBelow = [this](u64 threshold) {
boost::container::small_vector<ImageId, 64> expired; boost::container::small_vector<ImageId, 64> expired;
for (auto [id, image] : slot_images) { for (auto [id, image] : slot_images) {
if (image->last_use_tick < threshold) { if (True(image->flags & ImageFlagBits::Registered) &&
image->last_use_tick < threshold) {
expired.push_back(id); expired.push_back(id);
} }
} }
@ -226,7 +227,7 @@ void TextureCache<P>::RunGarbageCollector() {
} }
Configure(false); Configure(false);
{ if (frame_tick > ticks_to_destroy) {
auto expired = CollectBelow(frame_tick - ticks_to_destroy); auto expired = CollectBelow(frame_tick - ticks_to_destroy);
for (const auto image_id : expired) { for (const auto image_id : expired) {
if (Cleanup(image_id)) { if (Cleanup(image_id)) {
@ -238,10 +239,12 @@ void TextureCache<P>::RunGarbageCollector() {
// If pressure is still too high, prune aggressively. // If pressure is still too high, prune aggressively.
if (total_used_memory >= critical_memory) { if (total_used_memory >= critical_memory) {
Configure(true); Configure(true);
auto expired = CollectBelow(frame_tick - ticks_to_destroy); if (frame_tick > ticks_to_destroy) {
for (const auto image_id : expired) { auto expired = CollectBelow(frame_tick - ticks_to_destroy);
if (Cleanup(image_id)) { for (const auto image_id : expired) {
break; if (Cleanup(image_id)) {
break;
}
} }
} }
} }