diff options
| author | 2021-06-17 00:29:48 +0200 | |
|---|---|---|
| committer | 2021-06-17 00:29:48 +0200 | |
| commit | ca6f47c6862a24dfa78f3d25c8b7819636218cdd (patch) | |
| tree | d45fea664fa1e1d4de04b206289f638ffe1ceedc /src/video_core/buffer_cache | |
| parent | Reaper: Address Feedback. (diff) | |
| download | yuzu-ca6f47c6862a24dfa78f3d25c8b7819636218cdd.tar.gz yuzu-ca6f47c6862a24dfa78f3d25c8b7819636218cdd.tar.xz yuzu-ca6f47c6862a24dfa78f3d25c8b7819636218cdd.zip | |
Reaper: Change memory restrictions on TC depending on host memory on VK.
Diffstat (limited to 'src/video_core/buffer_cache')
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 82a4a10d6..6d04d00da 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -106,6 +106,8 @@ public: | |||
| 106 | 106 | ||
| 107 | void TickFrame(); | 107 | void TickFrame(); |
| 108 | 108 | ||
| 109 | void RunGarbageCollector(); | ||
| 110 | |||
| 109 | void WriteMemory(VAddr cpu_addr, u64 size); | 111 | void WriteMemory(VAddr cpu_addr, u64 size); |
| 110 | 112 | ||
| 111 | void CachedWriteMemory(VAddr cpu_addr, u64 size); | 113 | void CachedWriteMemory(VAddr cpu_addr, u64 size); |
| @@ -350,29 +352,7 @@ BufferCache<P>::BufferCache(VideoCore::RasterizerInterface& rasterizer_, | |||
| 350 | } | 352 | } |
| 351 | 353 | ||
| 352 | template <class P> | 354 | template <class P> |
| 353 | void BufferCache<P>::TickFrame() { | 355 | void BufferCache<P>::RunGarbageCollector() { |
| 354 | const bool enabled_gc = Settings::values.use_caches_gc.GetValue(); | ||
| 355 | SCOPE_EXIT({ | ||
| 356 | ++frame_tick; | ||
| 357 | delayed_destruction_ring.Tick(); | ||
| 358 | }); | ||
| 359 | // Calculate hits and shots and move hit bits to the right | ||
| 360 | const u32 hits = std::reduce(uniform_cache_hits.begin(), uniform_cache_hits.end()); | ||
| 361 | const u32 shots = std::reduce(uniform_cache_shots.begin(), uniform_cache_shots.end()); | ||
| 362 | std::copy_n(uniform_cache_hits.begin(), uniform_cache_hits.size() - 1, | ||
| 363 | uniform_cache_hits.begin() + 1); | ||
| 364 | std::copy_n(uniform_cache_shots.begin(), uniform_cache_shots.size() - 1, | ||
| 365 | uniform_cache_shots.begin() + 1); | ||
| 366 | uniform_cache_hits[0] = 0; | ||
| 367 | uniform_cache_shots[0] = 0; | ||
| 368 | |||
| 369 | const bool skip_preferred = hits * 256 < shots * 251; | ||
| 370 | uniform_buffer_skip_cache_size = skip_preferred ? DEFAULT_SKIP_CACHE_SIZE : 0; | ||
| 371 | |||
| 372 | const bool activate_gc = enabled_gc && total_used_memory >= EXPECTED_MEMORY; | ||
| 373 | if (!activate_gc) { | ||
| 374 | return; | ||
| 375 | } | ||
| 376 | const bool aggressive_gc = total_used_memory >= CRITICAL_MEMORY; | 356 | const bool aggressive_gc = total_used_memory >= CRITICAL_MEMORY; |
| 377 | const u64 ticks_to_destroy = aggressive_gc ? 60 : 120; | 357 | const u64 ticks_to_destroy = aggressive_gc ? 60 : 120; |
| 378 | int num_iterations = aggressive_gc ? 64 : 32; | 358 | int num_iterations = aggressive_gc ? 64 : 32; |
| @@ -393,6 +373,28 @@ void BufferCache<P>::TickFrame() { | |||
| 393 | } | 373 | } |
| 394 | 374 | ||
| 395 | template <class P> | 375 | template <class P> |
| 376 | void BufferCache<P>::TickFrame() { | ||
| 377 | // Calculate hits and shots and move hit bits to the right | ||
| 378 | const u32 hits = std::reduce(uniform_cache_hits.begin(), uniform_cache_hits.end()); | ||
| 379 | const u32 shots = std::reduce(uniform_cache_shots.begin(), uniform_cache_shots.end()); | ||
| 380 | std::copy_n(uniform_cache_hits.begin(), uniform_cache_hits.size() - 1, | ||
| 381 | uniform_cache_hits.begin() + 1); | ||
| 382 | std::copy_n(uniform_cache_shots.begin(), uniform_cache_shots.size() - 1, | ||
| 383 | uniform_cache_shots.begin() + 1); | ||
| 384 | uniform_cache_hits[0] = 0; | ||
| 385 | uniform_cache_shots[0] = 0; | ||
| 386 | |||
| 387 | const bool skip_preferred = hits * 256 < shots * 251; | ||
| 388 | uniform_buffer_skip_cache_size = skip_preferred ? DEFAULT_SKIP_CACHE_SIZE : 0; | ||
| 389 | |||
| 390 | if (Settings::values.use_caches_gc.GetValue() && total_used_memory >= EXPECTED_MEMORY) { | ||
| 391 | RunGarbageCollector(); | ||
| 392 | } | ||
| 393 | ++frame_tick; | ||
| 394 | delayed_destruction_ring.Tick(); | ||
| 395 | } | ||
| 396 | |||
| 397 | template <class P> | ||
| 396 | void BufferCache<P>::WriteMemory(VAddr cpu_addr, u64 size) { | 398 | void BufferCache<P>::WriteMemory(VAddr cpu_addr, u64 size) { |
| 397 | ForEachBufferInRange(cpu_addr, size, [&](BufferId, Buffer& buffer) { | 399 | ForEachBufferInRange(cpu_addr, size, [&](BufferId, Buffer& buffer) { |
| 398 | buffer.MarkRegionAsCpuModified(cpu_addr, size); | 400 | buffer.MarkRegionAsCpuModified(cpu_addr, size); |