summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2021-06-14 13:42:22 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2021-06-16 21:35:03 +0200
commit0dd98842bf87bdd0735d187f8d183ef7593ad747 (patch)
tree9198ce2e52bb44cef14ee2f6da76d4995c73c852 /src
parentReaper: Setup settings and final tuning. (diff)
downloadyuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar
yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar.gz
yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar.bz2
yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar.lz
yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar.xz
yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar.zst
yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.zip
Diffstat (limited to 'src')
-rw-r--r--src/common/common_sizes.h1
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h13
-rw-r--r--src/video_core/surface.cpp7
-rw-r--r--src/video_core/surface.h2
-rw-r--r--src/video_core/texture_cache/texture_cache.h38
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.ui2
6 files changed, 43 insertions, 20 deletions
diff --git a/src/common/common_sizes.h b/src/common/common_sizes.h
index 7e9fd968b..d07b7ee5a 100644
--- a/src/common/common_sizes.h
+++ b/src/common/common_sizes.h
@@ -24,6 +24,7 @@ enum : u64 {
Size_128_MB = 128ULL * Size_1_MB,
Size_448_MB = 448ULL * Size_1_MB,
Size_507_MB = 507ULL * Size_1_MB,
+ Size_512_MB = 512ULL * Size_1_MB,
Size_562_MB = 562ULL * Size_1_MB,
Size_1554_MB = 1554ULL * Size_1_MB,
Size_2048_MB = 2048ULL * Size_1_MB,
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index a8fb21d92..82a4a10d6 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -16,6 +16,7 @@
#include <boost/container/small_vector.hpp>
+#include "common/common_sizes.h"
#include "common/common_types.h"
#include "common/div_ceil.h"
#include "common/microprofile.h"
@@ -65,8 +66,8 @@ class BufferCache {
static constexpr BufferId NULL_BUFFER_ID{0};
- static constexpr u64 expected_memory = 512ULL * 1024ULL * 1024ULL;
- static constexpr u64 critical_memory = 1024ULL * 1024ULL * 1024ULL;
+ static constexpr u64 EXPECTED_MEMORY = Common::Size_512_MB;
+ static constexpr u64 CRITICAL_MEMORY = Common::Size_1_GB;
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
@@ -368,13 +369,13 @@ void BufferCache<P>::TickFrame() {
const bool skip_preferred = hits * 256 < shots * 251;
uniform_buffer_skip_cache_size = skip_preferred ? DEFAULT_SKIP_CACHE_SIZE : 0;
- const bool activate_gc = enabled_gc && total_used_memory >= expected_memory;
+ const bool activate_gc = enabled_gc && total_used_memory >= EXPECTED_MEMORY;
if (!activate_gc) {
return;
}
- const bool agressive_gc = total_used_memory >= critical_memory;
- const u64 ticks_to_destroy = agressive_gc ? 60 : 120;
- int num_iterations = agressive_gc ? 64 : 32;
+ const bool aggressive_gc = total_used_memory >= CRITICAL_MEMORY;
+ const u64 ticks_to_destroy = aggressive_gc ? 60 : 120;
+ int num_iterations = aggressive_gc ? 64 : 32;
for (; num_iterations > 0; --num_iterations) {
if (deletion_iterator == slot_buffers.end()) {
deletion_iterator = slot_buffers.begin();
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index 6308aef94..eb1746265 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -283,4 +283,11 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
return {DefaultBlockWidth(format), DefaultBlockHeight(format)};
}
+u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) {
+ constexpr u64 RGBA8_PIXEL_SIZE = 4;
+ const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) *
+ static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE;
+ return (base_size * base_block_size) / BytesPerBlock(format);
+}
+
} // namespace VideoCore::Surface
diff --git a/src/video_core/surface.h b/src/video_core/surface.h
index c40ab89d0..1503db81f 100644
--- a/src/video_core/surface.h
+++ b/src/video_core/surface.h
@@ -462,4 +462,6 @@ bool IsPixelFormatSRGB(PixelFormat format);
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
+u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format);
+
} // namespace VideoCore::Surface
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 8685f4418..8ff6f4e01 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -20,6 +20,7 @@
#include "common/alignment.h"
#include "common/common_funcs.h"
+#include "common/common_sizes.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "common/settings.h"
@@ -76,8 +77,8 @@ class TextureCache {
/// Sampler ID for bugged sampler ids
static constexpr SamplerId NULL_SAMPLER_ID{0};
- static constexpr u64 expected_memory = 1024ULL * 1024ULL * 1024ULL;
- static constexpr u64 critical_memory = 2 * 1024ULL * 1024ULL * 1024ULL;
+ static constexpr u64 EXPECTED_MEMORY = Common::Size_1_GB;
+ static constexpr u64 CRITICAL_MEMORY = Common::Size_2_GB;
using Runtime = typename P::Runtime;
using Image = typename P::Image;
@@ -394,8 +395,8 @@ void TextureCache<P>::TickFrame() {
++frame_tick;
return;
}
- const bool high_priority_mode = total_used_memory >= expected_memory;
- const bool aggressive_mode = total_used_memory >= critical_memory;
+ 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;
int num_iterations = aggressive_mode ? 256 : (high_priority_mode ? 128 : 64);
for (; num_iterations > 0; --num_iterations) {
@@ -405,7 +406,8 @@ void TextureCache<P>::TickFrame() {
break;
}
}
- const auto [image_id, image] = *deletion_iterator;
+ auto [image_id, image_tmp] = *deletion_iterator;
+ Image* image = image_tmp; // fix clang error.
const bool is_alias = True(image->flags & ImageFlagBits::Alias);
const bool is_bad_overlap = True(image->flags & ImageFlagBits::BadOverlap);
const bool must_download = image->IsSafeDownload();
@@ -417,8 +419,8 @@ void TextureCache<P>::TickFrame() {
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) {
+ const bool overlap_check = std::ranges::all_of(
+ image->overlapping_images, [&, image](const ImageId& overlap_id) {
auto& overlap = slot_images[overlap_id];
return overlap.frame_tick >= image->frame_tick;
});
@@ -428,8 +430,8 @@ void TextureCache<P>::TickFrame() {
}
}
if (!is_bad_overlap && must_download) {
- const bool alias_check =
- std::ranges::none_of(image->aliased_images, [&](const AliasedImage& alias) {
+ const bool alias_check = std::ranges::none_of(
+ image->aliased_images, [&, image](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);
@@ -1275,8 +1277,13 @@ void TextureCache<P>::RegisterImage(ImageId image_id) {
image.flags |= ImageFlagBits::Registered;
ForEachPage(image.cpu_addr, image.guest_size_bytes,
[this, image_id](u64 page) { page_table[page].push_back(image_id); });
- total_used_memory +=
- Common::AlignUp(std::max(image.guest_size_bytes, image.unswizzled_size_bytes), 1024);
+ u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes);
+ if ((IsPixelFormatASTC(image.info.format) &&
+ True(image.flags & ImageFlagBits::AcceleratedUpload)) ||
+ True(image.flags & ImageFlagBits::Converted)) {
+ tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format);
+ }
+ total_used_memory += Common::AlignUp(tentative_size, 1024);
}
template <class P>
@@ -1286,8 +1293,13 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) {
"Trying to unregister an already registered image");
image.flags &= ~ImageFlagBits::Registered;
image.flags &= ~ImageFlagBits::BadOverlap;
- total_used_memory -=
- Common::AlignUp(std::max(image.guest_size_bytes, image.unswizzled_size_bytes), 1024);
+ u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes);
+ if ((IsPixelFormatASTC(image.info.format) &&
+ True(image.flags & ImageFlagBits::AcceleratedUpload)) ||
+ True(image.flags & ImageFlagBits::Converted)) {
+ tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format);
+ }
+ total_used_memory -= Common::AlignUp(tentative_size, 1024);
ForEachPage(image.cpu_addr, image.guest_size_bytes, [this, image_id](u64 page) {
const auto page_it = page_table.find(page);
if (page_it == page_table.end()) {
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui
index 3566e9bfa..4bab3d074 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.ui
+++ b/src/yuzu/configuration/configure_graphics_advanced.ui
@@ -106,7 +106,7 @@
<item>
<widget class="QCheckBox" name="use_caches_gc">
<property name="toolTip">
- <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>
+ <string>Enables garbage collection for the GPU caches, this will try to keep VRAM within 3-4 GB by flushing the least used textures/buffers. May cause issues in a few games.</string>
</property>
<property name="text">
<string>Enable GPU caches garbage collection (unsafe)</string>