diff options
| author | 2024-02-27 09:38:14 -0500 | |
|---|---|---|
| committer | 2024-02-27 15:38:14 +0100 | |
| commit | 9bc85dda5fce187e90cbca4644ebea17cc058d7f (patch) | |
| tree | c1dcd64156fc8753988066f1bf06ab40c24bf32a /src/video_core | |
| parent | Merge pull request #13172 from liamwhite/gl-streams (diff) | |
| download | yuzu-9bc85dda5fce187e90cbca4644ebea17cc058d7f.tar.gz yuzu-9bc85dda5fce187e90cbca4644ebea17cc058d7f.tar.xz yuzu-9bc85dda5fce187e90cbca4644ebea17cc058d7f.zip | |
texture_cache: use two-pass collection for costly load resources (#13096)
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 53b4876f2..67487b463 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -72,12 +72,19 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag | |||
| 72 | 72 | ||
| 73 | template <class P> | 73 | template <class P> |
| 74 | void TextureCache<P>::RunGarbageCollector() { | 74 | void TextureCache<P>::RunGarbageCollector() { |
| 75 | bool high_priority_mode = total_used_memory >= expected_memory; | 75 | bool high_priority_mode = false; |
| 76 | bool aggressive_mode = total_used_memory >= critical_memory; | 76 | bool aggressive_mode = false; |
| 77 | const u64 ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL; | 77 | u64 ticks_to_destroy = 0; |
| 78 | size_t num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10); | 78 | size_t num_iterations = 0; |
| 79 | const auto clean_up = [this, &num_iterations, &high_priority_mode, | 79 | |
| 80 | &aggressive_mode](ImageId image_id) { | 80 | const auto Configure = [&](bool allow_aggressive) { |
| 81 | high_priority_mode = total_used_memory >= expected_memory; | ||
| 82 | aggressive_mode = allow_aggressive && total_used_memory >= critical_memory; | ||
| 83 | ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL; | ||
| 84 | num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10); | ||
| 85 | }; | ||
| 86 | const auto Cleanup = [this, &num_iterations, &high_priority_mode, | ||
| 87 | &aggressive_mode](ImageId image_id) { | ||
| 81 | if (num_iterations == 0) { | 88 | if (num_iterations == 0) { |
| 82 | return true; | 89 | return true; |
| 83 | } | 90 | } |
| @@ -123,7 +130,16 @@ void TextureCache<P>::RunGarbageCollector() { | |||
| 123 | } | 130 | } |
| 124 | return false; | 131 | return false; |
| 125 | }; | 132 | }; |
| 126 | lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, clean_up); | 133 | |
| 134 | // Try to remove anything old enough and not high priority. | ||
| 135 | Configure(false); | ||
| 136 | lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup); | ||
| 137 | |||
| 138 | // If pressure is still too high, prune aggressively. | ||
| 139 | if (total_used_memory >= critical_memory) { | ||
| 140 | Configure(true); | ||
| 141 | lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup); | ||
| 142 | } | ||
| 127 | } | 143 | } |
| 128 | 144 | ||
| 129 | template <class P> | 145 | template <class P> |