diff options
| author | 2024-02-20 23:19:27 -0300 | |
|---|---|---|
| committer | 2024-02-20 23:19:27 -0300 | |
| commit | e0c17a21138ba4379a5c77b40a7d3fd7414ca605 (patch) | |
| tree | 798f8678677cabd7c9048ed06022997a804a1aa5 | |
| parent | Merge pull request #13091 from t895/device-renaming (diff) | |
| parent | texture_cache: tweak iteration tracking change (diff) | |
| download | yuzu-e0c17a21138ba4379a5c77b40a7d3fd7414ca605.tar.gz yuzu-e0c17a21138ba4379a5c77b40a7d3fd7414ca605.tar.xz yuzu-e0c17a21138ba4379a5c77b40a7d3fd7414ca605.zip | |
Merge pull request #10529 from liamwhite/critical-spacing
caches: make critical reclamation less eager and possible in more cases
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 2 | ||||
| -rw-r--r-- | src/video_core/surface.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/surface.h | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 6 |
4 files changed, 17 insertions, 7 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 296c90e85..ed7a5b27e 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -35,7 +35,7 @@ BufferCache<P>::BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, R | |||
| 35 | const s64 min_spacing_critical = device_local_memory - 512_MiB; | 35 | const s64 min_spacing_critical = device_local_memory - 512_MiB; |
| 36 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); | 36 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); |
| 37 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; | 37 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; |
| 38 | const s64 min_vacancy_critical = (3 * mem_threshold) / 10; | 38 | const s64 min_vacancy_critical = (2 * mem_threshold) / 10; |
| 39 | minimum_memory = static_cast<u64>( | 39 | minimum_memory = static_cast<u64>( |
| 40 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), | 40 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), |
| 41 | DEFAULT_EXPECTED_MEMORY)); | 41 | DEFAULT_EXPECTED_MEMORY)); |
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 5b3c7aa5a..9055b1b92 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include "common/common_types.h" | 4 | #include "common/common_types.h" |
| 5 | #include "common/math_util.h" | 5 | #include "common/math_util.h" |
| 6 | #include "common/settings.h" | ||
| 6 | #include "video_core/surface.h" | 7 | #include "video_core/surface.h" |
| 7 | 8 | ||
| 8 | namespace VideoCore::Surface { | 9 | namespace VideoCore::Surface { |
| @@ -400,11 +401,20 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) { | |||
| 400 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; | 401 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; |
| 401 | } | 402 | } |
| 402 | 403 | ||
| 403 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) { | 404 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format) { |
| 404 | constexpr u64 RGBA8_PIXEL_SIZE = 4; | 405 | constexpr u64 RGBA8_PIXEL_SIZE = 4; |
| 405 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * | 406 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * |
| 406 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; | 407 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; |
| 407 | return (base_size * base_block_size) / BytesPerBlock(format); | 408 | const u64 uncompressed_size = (base_size * base_block_size) / BytesPerBlock(format); |
| 409 | |||
| 410 | switch (Settings::values.astc_recompression.GetValue()) { | ||
| 411 | case Settings::AstcRecompression::Bc1: | ||
| 412 | return uncompressed_size / 8; | ||
| 413 | case Settings::AstcRecompression::Bc3: | ||
| 414 | return uncompressed_size / 4; | ||
| 415 | default: | ||
| 416 | return uncompressed_size; | ||
| 417 | } | ||
| 408 | } | 418 | } |
| 409 | 419 | ||
| 410 | } // namespace VideoCore::Surface | 420 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index a5e8e2f62..ec9cd2fbf 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -517,6 +517,6 @@ size_t PixelComponentSizeBitsInteger(PixelFormat format); | |||
| 517 | 517 | ||
| 518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); | 518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); |
| 519 | 519 | ||
| 520 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); | 520 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format); |
| 521 | 521 | ||
| 522 | } // namespace VideoCore::Surface | 522 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 01c3561c9..53b4876f2 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -55,7 +55,7 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag | |||
| 55 | const s64 min_spacing_critical = device_local_memory - 512_MiB; | 55 | const s64 min_spacing_critical = device_local_memory - 512_MiB; |
| 56 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); | 56 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); |
| 57 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; | 57 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; |
| 58 | const s64 min_vacancy_critical = (3 * mem_threshold) / 10; | 58 | const s64 min_vacancy_critical = (2 * mem_threshold) / 10; |
| 59 | expected_memory = static_cast<u64>( | 59 | expected_memory = static_cast<u64>( |
| 60 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), | 60 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), |
| 61 | DEFAULT_EXPECTED_MEMORY)); | 61 | DEFAULT_EXPECTED_MEMORY)); |
| @@ -1979,7 +1979,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) { | |||
| 1979 | if ((IsPixelFormatASTC(image.info.format) && | 1979 | if ((IsPixelFormatASTC(image.info.format) && |
| 1980 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 1980 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
| 1981 | True(image.flags & ImageFlagBits::Converted)) { | 1981 | True(image.flags & ImageFlagBits::Converted)) { |
| 1982 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 1982 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
| 1983 | } | 1983 | } |
| 1984 | total_used_memory += Common::AlignUp(tentative_size, 1024); | 1984 | total_used_memory += Common::AlignUp(tentative_size, 1024); |
| 1985 | image.lru_index = lru_cache.Insert(image_id, frame_tick); | 1985 | image.lru_index = lru_cache.Insert(image_id, frame_tick); |
| @@ -2149,7 +2149,7 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) { | |||
| 2149 | if ((IsPixelFormatASTC(image.info.format) && | 2149 | if ((IsPixelFormatASTC(image.info.format) && |
| 2150 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 2150 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
| 2151 | True(image.flags & ImageFlagBits::Converted)) { | 2151 | True(image.flags & ImageFlagBits::Converted)) { |
| 2152 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 2152 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
| 2153 | } | 2153 | } |
| 2154 | total_used_memory -= Common::AlignUp(tentative_size, 1024); | 2154 | total_used_memory -= Common::AlignUp(tentative_size, 1024); |
| 2155 | const GPUVAddr gpu_addr = image.gpu_addr; | 2155 | const GPUVAddr gpu_addr = image.gpu_addr; |