summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-06-14 11:58:36 +0200
committerGravatar Fernando Sahmkow2021-06-16 21:35:03 +0200
commit954ad2a61ee597b67b978b36898f008885d3adb0 (patch)
tree4d0a3600e090c942bc3f553fdbdd7c24229a985e
parentReaper: Tune it up to be an smart GC. (diff)
downloadyuzu-954ad2a61ee597b67b978b36898f008885d3adb0.tar.gz
yuzu-954ad2a61ee597b67b978b36898f008885d3adb0.tar.xz
yuzu-954ad2a61ee597b67b978b36898f008885d3adb0.zip
Reaper: Setup settings and final tuning.
-rw-r--r--src/common/settings.cpp2
-rw-r--r--src/common/settings.h1
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h7
-rw-r--r--src/video_core/texture_cache/image_base.h8
-rw-r--r--src/video_core/texture_cache/texture_cache.h55
-rw-r--r--src/yuzu/configuration/config.cpp2
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.cpp6
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.h1
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.ui10
-rw-r--r--src/yuzu_cmd/default_ini.h4
10 files changed, 64 insertions, 32 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 9ec71eced..ab5cbe67b 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -59,6 +59,7 @@ void LogSettings() {
59 log_setting("Renderer_UseVsync", values.use_vsync.GetValue()); 59 log_setting("Renderer_UseVsync", values.use_vsync.GetValue());
60 log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue()); 60 log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue());
61 log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); 61 log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
62 log_setting("Renderer_UseGarbageCollection", values.use_caches_gc.GetValue());
62 log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); 63 log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue());
63 log_setting("Audio_OutputEngine", values.sink_id); 64 log_setting("Audio_OutputEngine", values.sink_id);
64 log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue()); 65 log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue());
@@ -141,6 +142,7 @@ void RestoreGlobalState(bool is_powered_on) {
141 values.use_assembly_shaders.SetGlobal(true); 142 values.use_assembly_shaders.SetGlobal(true);
142 values.use_asynchronous_shaders.SetGlobal(true); 143 values.use_asynchronous_shaders.SetGlobal(true);
143 values.use_fast_gpu_time.SetGlobal(true); 144 values.use_fast_gpu_time.SetGlobal(true);
145 values.use_caches_gc.SetGlobal(true);
144 values.bg_red.SetGlobal(true); 146 values.bg_red.SetGlobal(true);
145 values.bg_green.SetGlobal(true); 147 values.bg_green.SetGlobal(true);
146 values.bg_blue.SetGlobal(true); 148 values.bg_blue.SetGlobal(true);
diff --git a/src/common/settings.h b/src/common/settings.h
index 6198f2d9f..a1c0bf3ad 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -152,6 +152,7 @@ struct Values {
152 Setting<bool> use_assembly_shaders; 152 Setting<bool> use_assembly_shaders;
153 Setting<bool> use_asynchronous_shaders; 153 Setting<bool> use_asynchronous_shaders;
154 Setting<bool> use_fast_gpu_time; 154 Setting<bool> use_fast_gpu_time;
155 Setting<bool> use_caches_gc;
155 156
156 Setting<float> bg_red; 157 Setting<float> bg_red;
157 Setting<float> bg_green; 158 Setting<float> bg_green;
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index b4fa85c5b..a8fb21d92 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -350,9 +350,10 @@ BufferCache<P>::BufferCache(VideoCore::RasterizerInterface& rasterizer_,
350 350
351template <class P> 351template <class P>
352void BufferCache<P>::TickFrame() { 352void BufferCache<P>::TickFrame() {
353 const bool enabled_gc = Settings::values.use_caches_gc.GetValue();
353 SCOPE_EXIT({ 354 SCOPE_EXIT({
354 ++frame_tick; 355 ++frame_tick;
355 delayed_destruction_ring.Tick(); 356 delayed_destruction_ring.Tick();
356 }); 357 });
357 // Calculate hits and shots and move hit bits to the right 358 // Calculate hits and shots and move hit bits to the right
358 const u32 hits = std::reduce(uniform_cache_hits.begin(), uniform_cache_hits.end()); 359 const u32 hits = std::reduce(uniform_cache_hits.begin(), uniform_cache_hits.end());
@@ -367,7 +368,7 @@ void BufferCache<P>::TickFrame() {
367 const bool skip_preferred = hits * 256 < shots * 251; 368 const bool skip_preferred = hits * 256 < shots * 251;
368 uniform_buffer_skip_cache_size = skip_preferred ? DEFAULT_SKIP_CACHE_SIZE : 0; 369 uniform_buffer_skip_cache_size = skip_preferred ? DEFAULT_SKIP_CACHE_SIZE : 0;
369 370
370 const bool activate_gc = total_used_memory >= expected_memory; 371 const bool activate_gc = enabled_gc && total_used_memory >= expected_memory;
371 if (!activate_gc) { 372 if (!activate_gc) {
372 return; 373 return;
373 } 374 }
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 {
27 Picked = 1 << 7, ///< Temporary flag to mark the image as picked 27 Picked = 1 << 7, ///< Temporary flag to mark the image as picked
28 28
29 // Garbage Collection Flags 29 // Garbage Collection Flags
30 BadOverlap = 1 << 8, ///< This image overlaps other but doesn't fit, has higher 30 BadOverlap = 1 << 8, ///< This image overlaps other but doesn't fit, has higher
31 ///< garbage collection priority 31 ///< garbage collection priority
32 Alias = 1 << 9, ///< This image has aliases and has priority on garbage 32 Alias = 1 << 9, ///< This image has aliases and has priority on garbage
33 ///< collection 33 ///< collection
34}; 34};
35DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) 35DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits)
36 36
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 @@
22#include "common/common_funcs.h" 22#include "common/common_funcs.h"
23#include "common/common_types.h" 23#include "common/common_types.h"
24#include "common/logging/log.h" 24#include "common/logging/log.h"
25#include "common/settings.h"
25#include "video_core/compatible_formats.h" 26#include "video_core/compatible_formats.h"
26#include "video_core/delayed_destruction_ring.h" 27#include "video_core/delayed_destruction_ring.h"
27#include "video_core/dirty_flags.h" 28#include "video_core/dirty_flags.h"
@@ -384,6 +385,15 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface&
384 385
385template <class P> 386template <class P>
386void TextureCache<P>::TickFrame() { 387void TextureCache<P>::TickFrame() {
388 const bool enabled_gc = Settings::values.use_caches_gc.GetValue();
389 if (!enabled_gc) {
390 // @Note(Blinkhawk): compile error with SCOPE_EXIT on msvc.
391 sentenced_images.Tick();
392 sentenced_framebuffers.Tick();
393 sentenced_image_view.Tick();
394 ++frame_tick;
395 return;
396 }
387 const bool high_priority_mode = total_used_memory >= expected_memory; 397 const bool high_priority_mode = total_used_memory >= expected_memory;
388 const bool aggressive_mode = total_used_memory >= critical_memory; 398 const bool aggressive_mode = total_used_memory >= critical_memory;
389 const u64 ticks_to_destroy = high_priority_mode ? 60 : 100; 399 const u64 ticks_to_destroy = high_priority_mode ? 60 : 100;
@@ -397,22 +407,20 @@ void TextureCache<P>::TickFrame() {
397 } 407 }
398 const auto [image_id, image] = *deletion_iterator; 408 const auto [image_id, image] = *deletion_iterator;
399 const bool is_alias = True(image->flags & ImageFlagBits::Alias); 409 const bool is_alias = True(image->flags & ImageFlagBits::Alias);
400 if (is_alias && image->aliased_images.size() <= 1) {
401 ++deletion_iterator;
402 continue;
403 }
404 const bool is_bad_overlap = True(image->flags & ImageFlagBits::BadOverlap); 410 const bool is_bad_overlap = True(image->flags & ImageFlagBits::BadOverlap);
405 const bool must_download = image->IsSafeDownload(); 411 const bool must_download = image->IsSafeDownload();
406 const u64 ticks_needed = is_bad_overlap ? ticks_to_destroy >> 4 : ticks_to_destroy; 412 bool should_care = is_bad_overlap || is_alias || (high_priority_mode && !must_download);
407 const bool should_care = 413 const u64 ticks_needed =
408 aggressive_mode || is_bad_overlap || is_alias || (high_priority_mode && !must_download); 414 is_bad_overlap
415 ? ticks_to_destroy >> 4
416 : ((should_care && aggressive_mode) ? ticks_to_destroy >> 1 : ticks_to_destroy);
417 should_care |= aggressive_mode;
409 if (should_care && image->frame_tick + ticks_needed < frame_tick) { 418 if (should_care && image->frame_tick + ticks_needed < frame_tick) {
410 if (is_bad_overlap) { 419 if (is_bad_overlap) {
411 const bool overlap_check = 420 const bool overlap_check =
412 std::ranges::all_of(image->overlapping_images, [&](const ImageId& overlap_id) { 421 std::ranges::all_of(image->overlapping_images, [&](const ImageId& overlap_id) {
413 auto& overlap = slot_images[overlap_id]; 422 auto& overlap = slot_images[overlap_id];
414 return (overlap.frame_tick >= image->frame_tick) && 423 return overlap.frame_tick >= image->frame_tick;
415 (overlap.modification_tick > image->modification_tick);
416 }); 424 });
417 if (!overlap_check) { 425 if (!overlap_check) {
418 ++deletion_iterator; 426 ++deletion_iterator;
@@ -420,23 +428,20 @@ void TextureCache<P>::TickFrame() {
420 } 428 }
421 } 429 }
422 if (!is_bad_overlap && must_download) { 430 if (!is_bad_overlap && must_download) {
423 if (is_alias) { 431 const bool alias_check =
424 const bool alias_check = 432 std::ranges::none_of(image->aliased_images, [&](const AliasedImage& alias) {
425 std::ranges::all_of(image->aliased_images, [&](const AliasedImage& alias) { 433 auto& alias_image = slot_images[alias.id];
426 auto& alias_image = slot_images[alias.id]; 434 return (alias_image.frame_tick < image->frame_tick) ||
427 return (alias_image.frame_tick >= image->frame_tick) && 435 (alias_image.modification_tick < image->modification_tick);
428 (alias_image.modification_tick > image->modification_tick); 436 });
429 }); 437
430 if (!alias_check) { 438 if (alias_check) {
431 ++deletion_iterator; 439 auto map = runtime.DownloadStagingBuffer(image->unswizzled_size_bytes);
432 continue; 440 const auto copies = FullDownloadCopies(image->info);
433 } 441 image->DownloadMemory(map, copies);
442 runtime.Finish();
443 SwizzleImage(gpu_memory, image->gpu_addr, image->info, copies, map.mapped_span);
434 } 444 }
435 auto map = runtime.DownloadStagingBuffer(image->unswizzled_size_bytes);
436 const auto copies = FullDownloadCopies(image->info);
437 image->DownloadMemory(map, copies);
438 runtime.Finish();
439 SwizzleImage(gpu_memory, image->gpu_addr, image->info, copies, map.mapped_span);
440 } 445 }
441 if (True(image->flags & ImageFlagBits::Tracked)) { 446 if (True(image->flags & ImageFlagBits::Tracked)) {
442 UntrackImage(*image); 447 UntrackImage(*image);
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 916a22724..57843ac5a 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -817,6 +817,7 @@ void Config::ReadRendererValues() {
817 QStringLiteral("use_asynchronous_shaders"), false); 817 QStringLiteral("use_asynchronous_shaders"), false);
818 ReadSettingGlobal(Settings::values.use_fast_gpu_time, QStringLiteral("use_fast_gpu_time"), 818 ReadSettingGlobal(Settings::values.use_fast_gpu_time, QStringLiteral("use_fast_gpu_time"),
819 true); 819 true);
820 ReadSettingGlobal(Settings::values.use_caches_gc, QStringLiteral("use_caches_gc"), false);
820 ReadSettingGlobal(Settings::values.bg_red, QStringLiteral("bg_red"), 0.0); 821 ReadSettingGlobal(Settings::values.bg_red, QStringLiteral("bg_red"), 0.0);
821 ReadSettingGlobal(Settings::values.bg_green, QStringLiteral("bg_green"), 0.0); 822 ReadSettingGlobal(Settings::values.bg_green, QStringLiteral("bg_green"), 0.0);
822 ReadSettingGlobal(Settings::values.bg_blue, QStringLiteral("bg_blue"), 0.0); 823 ReadSettingGlobal(Settings::values.bg_blue, QStringLiteral("bg_blue"), 0.0);
@@ -1401,6 +1402,7 @@ void Config::SaveRendererValues() {
1401 Settings::values.use_asynchronous_shaders, false); 1402 Settings::values.use_asynchronous_shaders, false);
1402 WriteSettingGlobal(QStringLiteral("use_fast_gpu_time"), Settings::values.use_fast_gpu_time, 1403 WriteSettingGlobal(QStringLiteral("use_fast_gpu_time"), Settings::values.use_fast_gpu_time,
1403 true); 1404 true);
1405 WriteSettingGlobal(QStringLiteral("use_caches_gc"), Settings::values.use_caches_gc, false);
1404 // Cast to double because Qt's written float values are not human-readable 1406 // Cast to double because Qt's written float values are not human-readable
1405 WriteSettingGlobal(QStringLiteral("bg_red"), Settings::values.bg_red, 0.0); 1407 WriteSettingGlobal(QStringLiteral("bg_red"), Settings::values.bg_red, 0.0);
1406 WriteSettingGlobal(QStringLiteral("bg_green"), Settings::values.bg_green, 0.0); 1408 WriteSettingGlobal(QStringLiteral("bg_green"), Settings::values.bg_green, 0.0);
diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp
index 35bf9c6be..a9e611125 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.cpp
+++ b/src/yuzu/configuration/configure_graphics_advanced.cpp
@@ -30,6 +30,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
30 ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); 30 ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue());
31 ui->use_assembly_shaders->setChecked(Settings::values.use_assembly_shaders.GetValue()); 31 ui->use_assembly_shaders->setChecked(Settings::values.use_assembly_shaders.GetValue());
32 ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue()); 32 ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue());
33 ui->use_caches_gc->setChecked(Settings::values.use_caches_gc.GetValue());
33 ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue()); 34 ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue());
34 35
35 if (Settings::IsConfiguringGlobal()) { 36 if (Settings::IsConfiguringGlobal()) {
@@ -62,6 +63,8 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
62 ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, 63 ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders,
63 ui->use_asynchronous_shaders, 64 ui->use_asynchronous_shaders,
64 use_asynchronous_shaders); 65 use_asynchronous_shaders);
66 ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_caches_gc, ui->use_caches_gc,
67 use_caches_gc);
65 ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time, 68 ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time,
66 ui->use_fast_gpu_time, use_fast_gpu_time); 69 ui->use_fast_gpu_time, use_fast_gpu_time);
67 70
@@ -101,6 +104,7 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
101 ui->use_asynchronous_shaders->setEnabled( 104 ui->use_asynchronous_shaders->setEnabled(
102 Settings::values.use_asynchronous_shaders.UsingGlobal()); 105 Settings::values.use_asynchronous_shaders.UsingGlobal());
103 ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal()); 106 ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal());
107 ui->use_caches_gc->setEnabled(Settings::values.use_caches_gc.UsingGlobal());
104 ui->anisotropic_filtering_combobox->setEnabled( 108 ui->anisotropic_filtering_combobox->setEnabled(
105 Settings::values.max_anisotropy.UsingGlobal()); 109 Settings::values.max_anisotropy.UsingGlobal());
106 110
@@ -115,6 +119,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
115 use_asynchronous_shaders); 119 use_asynchronous_shaders);
116 ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time, 120 ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time,
117 Settings::values.use_fast_gpu_time, use_fast_gpu_time); 121 Settings::values.use_fast_gpu_time, use_fast_gpu_time);
122 ConfigurationShared::SetColoredTristate(ui->use_caches_gc, Settings::values.use_caches_gc,
123 use_caches_gc);
118 ConfigurationShared::SetColoredComboBox( 124 ConfigurationShared::SetColoredComboBox(
119 ui->gpu_accuracy, ui->label_gpu_accuracy, 125 ui->gpu_accuracy, ui->label_gpu_accuracy,
120 static_cast<int>(Settings::values.gpu_accuracy.GetValue(true))); 126 static_cast<int>(Settings::values.gpu_accuracy.GetValue(true)));
diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h
index e61b571c7..9148aacf2 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.h
+++ b/src/yuzu/configuration/configure_graphics_advanced.h
@@ -38,4 +38,5 @@ private:
38 ConfigurationShared::CheckState use_assembly_shaders; 38 ConfigurationShared::CheckState use_assembly_shaders;
39 ConfigurationShared::CheckState use_asynchronous_shaders; 39 ConfigurationShared::CheckState use_asynchronous_shaders;
40 ConfigurationShared::CheckState use_fast_gpu_time; 40 ConfigurationShared::CheckState use_fast_gpu_time;
41 ConfigurationShared::CheckState use_caches_gc;
41}; 42};
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui
index 846a30586..3566e9bfa 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.ui
+++ b/src/yuzu/configuration/configure_graphics_advanced.ui
@@ -104,6 +104,16 @@
104 </widget> 104 </widget>
105 </item> 105 </item>
106 <item> 106 <item>
107 <widget class="QCheckBox" name="use_caches_gc">
108 <property name="toolTip">
109 <string>Enables garbage collection for the GPU caches, this will try to keep VRAM within 3-4Gb and flush least used textures/buffers. This option may be unsafe on a few games</string>
110 </property>
111 <property name="text">
112 <string>Enable GPU caches garbage collection (unsafe)</string>
113 </property>
114 </widget>
115 </item>
116 <item>
107 <widget class="QWidget" name="af_layout" native="true"> 117 <widget class="QWidget" name="af_layout" native="true">
108 <layout class="QHBoxLayout" name="horizontalLayout_1"> 118 <layout class="QHBoxLayout" name="horizontalLayout_1">
109 <property name="leftMargin"> 119 <property name="leftMargin">
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index efa1b1d18..839919062 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -227,6 +227,10 @@ use_asynchronous_gpu_emulation =
227# 0: Off, 1 (default): On 227# 0: Off, 1 (default): On
228use_vsync = 228use_vsync =
229 229
230# Whether to use garbage collection or not.
231# 0 (default): Off, 1: On
232use_caches_gc =
233
230# The clear color for the renderer. What shows up on the sides of the bottom screen. 234# The clear color for the renderer. What shows up on the sides of the bottom screen.
231# Must be in range of 0.0-1.0. Defaults to 1.0 for all. 235# Must be in range of 0.0-1.0. Defaults to 1.0 for all.
232bg_red = 236bg_red =