diff options
| author | 2021-06-14 13:42:22 +0200 | |
|---|---|---|
| committer | 2021-06-16 21:35:03 +0200 | |
| commit | 0dd98842bf87bdd0735d187f8d183ef7593ad747 (patch) | |
| tree | 9198ce2e52bb44cef14ee2f6da76d4995c73c852 /src/video_core/texture_cache | |
| parent | Reaper: Setup settings and final tuning. (diff) | |
| download | yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar.gz yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.tar.xz yuzu-0dd98842bf87bdd0735d187f8d183ef7593ad747.zip | |
Reaper: Address Feedback.
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 38 |
1 files changed, 25 insertions, 13 deletions
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 @@ | |||
| 20 | 20 | ||
| 21 | #include "common/alignment.h" | 21 | #include "common/alignment.h" |
| 22 | #include "common/common_funcs.h" | 22 | #include "common/common_funcs.h" |
| 23 | #include "common/common_sizes.h" | ||
| 23 | #include "common/common_types.h" | 24 | #include "common/common_types.h" |
| 24 | #include "common/logging/log.h" | 25 | #include "common/logging/log.h" |
| 25 | #include "common/settings.h" | 26 | #include "common/settings.h" |
| @@ -76,8 +77,8 @@ class TextureCache { | |||
| 76 | /// Sampler ID for bugged sampler ids | 77 | /// Sampler ID for bugged sampler ids |
| 77 | static constexpr SamplerId NULL_SAMPLER_ID{0}; | 78 | static constexpr SamplerId NULL_SAMPLER_ID{0}; |
| 78 | 79 | ||
| 79 | static constexpr u64 expected_memory = 1024ULL * 1024ULL * 1024ULL; | 80 | static constexpr u64 EXPECTED_MEMORY = Common::Size_1_GB; |
| 80 | static constexpr u64 critical_memory = 2 * 1024ULL * 1024ULL * 1024ULL; | 81 | static constexpr u64 CRITICAL_MEMORY = Common::Size_2_GB; |
| 81 | 82 | ||
| 82 | using Runtime = typename P::Runtime; | 83 | using Runtime = typename P::Runtime; |
| 83 | using Image = typename P::Image; | 84 | using Image = typename P::Image; |
| @@ -394,8 +395,8 @@ void TextureCache<P>::TickFrame() { | |||
| 394 | ++frame_tick; | 395 | ++frame_tick; |
| 395 | return; | 396 | return; |
| 396 | } | 397 | } |
| 397 | const bool high_priority_mode = total_used_memory >= expected_memory; | 398 | const bool high_priority_mode = total_used_memory >= EXPECTED_MEMORY; |
| 398 | const bool aggressive_mode = total_used_memory >= critical_memory; | 399 | const bool aggressive_mode = total_used_memory >= CRITICAL_MEMORY; |
| 399 | const u64 ticks_to_destroy = high_priority_mode ? 60 : 100; | 400 | const u64 ticks_to_destroy = high_priority_mode ? 60 : 100; |
| 400 | int num_iterations = aggressive_mode ? 256 : (high_priority_mode ? 128 : 64); | 401 | int num_iterations = aggressive_mode ? 256 : (high_priority_mode ? 128 : 64); |
| 401 | for (; num_iterations > 0; --num_iterations) { | 402 | for (; num_iterations > 0; --num_iterations) { |
| @@ -405,7 +406,8 @@ void TextureCache<P>::TickFrame() { | |||
| 405 | break; | 406 | break; |
| 406 | } | 407 | } |
| 407 | } | 408 | } |
| 408 | const auto [image_id, image] = *deletion_iterator; | 409 | auto [image_id, image_tmp] = *deletion_iterator; |
| 410 | Image* image = image_tmp; // fix clang error. | ||
| 409 | const bool is_alias = True(image->flags & ImageFlagBits::Alias); | 411 | const bool is_alias = True(image->flags & ImageFlagBits::Alias); |
| 410 | const bool is_bad_overlap = True(image->flags & ImageFlagBits::BadOverlap); | 412 | const bool is_bad_overlap = True(image->flags & ImageFlagBits::BadOverlap); |
| 411 | const bool must_download = image->IsSafeDownload(); | 413 | const bool must_download = image->IsSafeDownload(); |
| @@ -417,8 +419,8 @@ void TextureCache<P>::TickFrame() { | |||
| 417 | should_care |= aggressive_mode; | 419 | should_care |= aggressive_mode; |
| 418 | if (should_care && image->frame_tick + ticks_needed < frame_tick) { | 420 | if (should_care && image->frame_tick + ticks_needed < frame_tick) { |
| 419 | if (is_bad_overlap) { | 421 | if (is_bad_overlap) { |
| 420 | const bool overlap_check = | 422 | const bool overlap_check = std::ranges::all_of( |
| 421 | std::ranges::all_of(image->overlapping_images, [&](const ImageId& overlap_id) { | 423 | image->overlapping_images, [&, image](const ImageId& overlap_id) { |
| 422 | auto& overlap = slot_images[overlap_id]; | 424 | auto& overlap = slot_images[overlap_id]; |
| 423 | return overlap.frame_tick >= image->frame_tick; | 425 | return overlap.frame_tick >= image->frame_tick; |
| 424 | }); | 426 | }); |
| @@ -428,8 +430,8 @@ void TextureCache<P>::TickFrame() { | |||
| 428 | } | 430 | } |
| 429 | } | 431 | } |
| 430 | if (!is_bad_overlap && must_download) { | 432 | if (!is_bad_overlap && must_download) { |
| 431 | const bool alias_check = | 433 | const bool alias_check = std::ranges::none_of( |
| 432 | std::ranges::none_of(image->aliased_images, [&](const AliasedImage& alias) { | 434 | image->aliased_images, [&, image](const AliasedImage& alias) { |
| 433 | auto& alias_image = slot_images[alias.id]; | 435 | auto& alias_image = slot_images[alias.id]; |
| 434 | return (alias_image.frame_tick < image->frame_tick) || | 436 | return (alias_image.frame_tick < image->frame_tick) || |
| 435 | (alias_image.modification_tick < image->modification_tick); | 437 | (alias_image.modification_tick < image->modification_tick); |
| @@ -1275,8 +1277,13 @@ void TextureCache<P>::RegisterImage(ImageId image_id) { | |||
| 1275 | image.flags |= ImageFlagBits::Registered; | 1277 | image.flags |= ImageFlagBits::Registered; |
| 1276 | ForEachPage(image.cpu_addr, image.guest_size_bytes, | 1278 | ForEachPage(image.cpu_addr, image.guest_size_bytes, |
| 1277 | [this, image_id](u64 page) { page_table[page].push_back(image_id); }); | 1279 | [this, image_id](u64 page) { page_table[page].push_back(image_id); }); |
| 1278 | total_used_memory += | 1280 | u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes); |
| 1279 | Common::AlignUp(std::max(image.guest_size_bytes, image.unswizzled_size_bytes), 1024); | 1281 | if ((IsPixelFormatASTC(image.info.format) && |
| 1282 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | ||
| 1283 | True(image.flags & ImageFlagBits::Converted)) { | ||
| 1284 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | ||
| 1285 | } | ||
| 1286 | total_used_memory += Common::AlignUp(tentative_size, 1024); | ||
| 1280 | } | 1287 | } |
| 1281 | 1288 | ||
| 1282 | template <class P> | 1289 | template <class P> |
| @@ -1286,8 +1293,13 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) { | |||
| 1286 | "Trying to unregister an already registered image"); | 1293 | "Trying to unregister an already registered image"); |
| 1287 | image.flags &= ~ImageFlagBits::Registered; | 1294 | image.flags &= ~ImageFlagBits::Registered; |
| 1288 | image.flags &= ~ImageFlagBits::BadOverlap; | 1295 | image.flags &= ~ImageFlagBits::BadOverlap; |
| 1289 | total_used_memory -= | 1296 | u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes); |
| 1290 | Common::AlignUp(std::max(image.guest_size_bytes, image.unswizzled_size_bytes), 1024); | 1297 | if ((IsPixelFormatASTC(image.info.format) && |
| 1298 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | ||
| 1299 | True(image.flags & ImageFlagBits::Converted)) { | ||
| 1300 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | ||
| 1301 | } | ||
| 1302 | total_used_memory -= Common::AlignUp(tentative_size, 1024); | ||
| 1291 | ForEachPage(image.cpu_addr, image.guest_size_bytes, [this, image_id](u64 page) { | 1303 | ForEachPage(image.cpu_addr, image.guest_size_bytes, [this, image_id](u64 page) { |
| 1292 | const auto page_it = page_table.find(page); | 1304 | const auto page_it = page_table.find(page); |
| 1293 | if (page_it == page_table.end()) { | 1305 | if (page_it == page_table.end()) { |