From 954ad2a61ee597b67b978b36898f008885d3adb0 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 14 Jun 2021 11:58:36 +0200 Subject: Reaper: Setup settings and final tuning. --- src/video_core/texture_cache/image_base.h | 8 ++-- src/video_core/texture_cache/texture_cache.h | 55 +++++++++++++++------------- 2 files changed, 34 insertions(+), 29 deletions(-) (limited to 'src/video_core/texture_cache') diff --git a/src/video_core/texture_cache/image_base.h b/src/video_core/texture_cache/image_base.h index 40c047ea1..e326cab71 100644 --- a/src/video_core/texture_cache/image_base.h +++ b/src/video_core/texture_cache/image_base.h @@ -27,10 +27,10 @@ enum class ImageFlagBits : u32 { Picked = 1 << 7, ///< Temporary flag to mark the image as picked // Garbage Collection Flags - BadOverlap = 1 << 8, ///< This image overlaps other but doesn't fit, has higher - ///< garbage collection priority - Alias = 1 << 9, ///< This image has aliases and has priority on garbage - ///< collection + BadOverlap = 1 << 8, ///< This image overlaps other but doesn't fit, has higher + ///< garbage collection priority + Alias = 1 << 9, ///< This image has aliases and has priority on garbage + ///< collection }; DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index cf48f7b02..8685f4418 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -22,6 +22,7 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "common/logging/log.h" +#include "common/settings.h" #include "video_core/compatible_formats.h" #include "video_core/delayed_destruction_ring.h" #include "video_core/dirty_flags.h" @@ -384,6 +385,15 @@ TextureCache

::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface& template void TextureCache

::TickFrame() { + const bool enabled_gc = Settings::values.use_caches_gc.GetValue(); + if (!enabled_gc) { + // @Note(Blinkhawk): compile error with SCOPE_EXIT on msvc. + sentenced_images.Tick(); + sentenced_framebuffers.Tick(); + sentenced_image_view.Tick(); + ++frame_tick; + return; + } const bool high_priority_mode = total_used_memory >= expected_memory; const bool aggressive_mode = total_used_memory >= critical_memory; const u64 ticks_to_destroy = high_priority_mode ? 60 : 100; @@ -397,22 +407,20 @@ void TextureCache

::TickFrame() { } const auto [image_id, image] = *deletion_iterator; const bool is_alias = True(image->flags & ImageFlagBits::Alias); - if (is_alias && image->aliased_images.size() <= 1) { - ++deletion_iterator; - continue; - } const bool is_bad_overlap = True(image->flags & ImageFlagBits::BadOverlap); const bool must_download = image->IsSafeDownload(); - const u64 ticks_needed = is_bad_overlap ? ticks_to_destroy >> 4 : ticks_to_destroy; - const bool should_care = - aggressive_mode || is_bad_overlap || is_alias || (high_priority_mode && !must_download); + bool should_care = is_bad_overlap || is_alias || (high_priority_mode && !must_download); + const u64 ticks_needed = + is_bad_overlap + ? ticks_to_destroy >> 4 + : ((should_care && aggressive_mode) ? ticks_to_destroy >> 1 : ticks_to_destroy); + should_care |= aggressive_mode; if (should_care && image->frame_tick + ticks_needed < frame_tick) { if (is_bad_overlap) { const bool overlap_check = std::ranges::all_of(image->overlapping_images, [&](const ImageId& overlap_id) { auto& overlap = slot_images[overlap_id]; - return (overlap.frame_tick >= image->frame_tick) && - (overlap.modification_tick > image->modification_tick); + return overlap.frame_tick >= image->frame_tick; }); if (!overlap_check) { ++deletion_iterator; @@ -420,23 +428,20 @@ void TextureCache

::TickFrame() { } } if (!is_bad_overlap && must_download) { - if (is_alias) { - const bool alias_check = - std::ranges::all_of(image->aliased_images, [&](const AliasedImage& alias) { - auto& alias_image = slot_images[alias.id]; - return (alias_image.frame_tick >= image->frame_tick) && - (alias_image.modification_tick > image->modification_tick); - }); - if (!alias_check) { - ++deletion_iterator; - continue; - } + const bool alias_check = + std::ranges::none_of(image->aliased_images, [&](const AliasedImage& alias) { + auto& alias_image = slot_images[alias.id]; + return (alias_image.frame_tick < image->frame_tick) || + (alias_image.modification_tick < image->modification_tick); + }); + + if (alias_check) { + auto map = runtime.DownloadStagingBuffer(image->unswizzled_size_bytes); + const auto copies = FullDownloadCopies(image->info); + image->DownloadMemory(map, copies); + runtime.Finish(); + SwizzleImage(gpu_memory, image->gpu_addr, image->info, copies, map.mapped_span); } - auto map = runtime.DownloadStagingBuffer(image->unswizzled_size_bytes); - const auto copies = FullDownloadCopies(image->info); - image->DownloadMemory(map, copies); - runtime.Finish(); - SwizzleImage(gpu_memory, image->gpu_addr, image->info, copies, map.mapped_span); } if (True(image->flags & ImageFlagBits::Tracked)) { UntrackImage(*image); -- cgit v1.2.3