|
|
@ -6,6 +6,7 @@ |
|
|
|
|
|
|
|
|
#pragma once |
|
|
#pragma once |
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm> |
|
|
#include <limits> |
|
|
#include <limits> |
|
|
#include <optional> |
|
|
#include <optional> |
|
|
#include <bit> |
|
|
#include <bit> |
|
|
@ -128,7 +129,7 @@ void TextureCache<P>::RunGarbageCollector() { |
|
|
if (num_iterations == 0) { |
|
|
if (num_iterations == 0) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
--num_iterations; |
|
|
|
|
|
|
|
|
|
|
|
auto& image = slot_images[image_id]; |
|
|
auto& image = slot_images[image_id]; |
|
|
|
|
|
|
|
|
// Never delete recently allocated sparse textures (within 3 frames) |
|
|
// Never delete recently allocated sparse textures (within 3 frames) |
|
|
@ -156,6 +157,8 @@ void TextureCache<P>::RunGarbageCollector() { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
--num_iterations; |
|
|
|
|
|
|
|
|
if (must_download && !is_large_sparse) { |
|
|
if (must_download && !is_large_sparse) { |
|
|
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes); |
|
|
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes); |
|
|
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info)); |
|
|
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info)); |
|
|
@ -185,6 +188,12 @@ void TextureCache<P>::RunGarbageCollector() { |
|
|
return false; |
|
|
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 |
|
|
// 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 normal_threshold = frame_tick > ticks_to_destroy ? frame_tick - ticks_to_destroy : 0; |
|
|
const u64 aggressive_threshold = frame_tick > 10 ? frame_tick - 10 : 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 |
|
|
// Tier 1: large sparse textures under memory pressure |
|
|
for (const auto image_id : sparse_candidates) { |
|
|
for (const auto image_id : sparse_candidates) { |
|
|
auto& image = slot_images[image_id]; |
|
|
auto& image = slot_images[image_id]; |
|
|
|