mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-09 22:58:54 +02:00
[texture_cache] Adjusted GC logic for the iterations with older or obsolete textures
This commit is contained in:
parent
90fd089e58
commit
cb851cf091
1 changed files with 13 additions and 1 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <bit>
|
||||
|
|
@ -128,7 +129,7 @@ void TextureCache<P>::RunGarbageCollector() {
|
|||
if (num_iterations == 0) {
|
||||
return true;
|
||||
}
|
||||
--num_iterations;
|
||||
|
||||
auto& image = slot_images[image_id];
|
||||
|
||||
// Never delete recently allocated sparse textures (within 3 frames)
|
||||
|
|
@ -156,6 +157,8 @@ void TextureCache<P>::RunGarbageCollector() {
|
|||
return false;
|
||||
}
|
||||
|
||||
--num_iterations;
|
||||
|
||||
if (must_download && !is_large_sparse) {
|
||||
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes);
|
||||
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
||||
|
|
@ -185,6 +188,12 @@ void TextureCache<P>::RunGarbageCollector() {
|
|||
return false;
|
||||
};
|
||||
|
||||
const auto SortByAge = [this](auto& vec) {
|
||||
std::sort(vec.begin(), vec.end(), [this](ImageId a, ImageId b) {
|
||||
return slot_images[a].last_use_tick < slot_images[b].last_use_tick;
|
||||
});
|
||||
};
|
||||
|
||||
// Single pass: collect all candidates, classified by tier
|
||||
const u64 normal_threshold = frame_tick > ticks_to_destroy ? frame_tick - ticks_to_destroy : 0;
|
||||
const u64 aggressive_threshold = frame_tick > 10 ? frame_tick - 10 : 0;
|
||||
|
|
@ -208,6 +217,9 @@ void TextureCache<P>::RunGarbageCollector() {
|
|||
}
|
||||
}
|
||||
|
||||
SortByAge(expired);
|
||||
SortByAge(aggressive_expired);
|
||||
|
||||
// Tier 1: large sparse textures under memory pressure
|
||||
for (const auto image_id : sparse_candidates) {
|
||||
auto& image = slot_images[image_id];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue