| 738 | } |
| 739 | |
| 740 | void GSgetMemoryStats(SmallStringBase& info) |
| 741 | { |
| 742 | if (!g_texture_cache) |
| 743 | { |
| 744 | info.assign(""); |
| 745 | return; |
| 746 | } |
| 747 | |
| 748 | // Get megabyte values. Round negligible values to 0.1 MB to avoid swamping. |
| 749 | const auto get_MB = [](const double bytes) { |
| 750 | return (bytes <= 0.0 ? bytes : std::max(0.1, bytes / static_cast<double>(_1mb))); |
| 751 | }; |
| 752 | |
| 753 | const auto format_precision = [](const double megabytes) -> std::string { |
| 754 | return (megabytes < 10.0 ? |
| 755 | fmt::format("{:.1f}", megabytes) : |
| 756 | fmt::format("{:.0f}", std::round(megabytes))); |
| 757 | }; |
| 758 | |
| 759 | const double targets_MB = get_MB(static_cast<double>(g_texture_cache->GetTargetMemoryUsage())); |
| 760 | const double sources_MB = get_MB(static_cast<double>(g_texture_cache->GetSourceMemoryUsage())); |
| 761 | const double pool_MB = get_MB(static_cast<double>(g_gs_device->GetPoolMemoryUsage())); |
| 762 | |
| 763 | if (GSConfig.TexturePreloading == TexturePreloadingLevel::Full) |
| 764 | { |
| 765 | const double hashcache_MB = get_MB(static_cast<double>(g_texture_cache->GetHashCacheMemoryUsage())); |
| 766 | const double total_MB = targets_MB + sources_MB + hashcache_MB + pool_MB; |
| 767 | info.format("VRAM: {} MB | TGT: {} MB | SRC: {} MB | HC: {} MB | PL: {} MB", |
| 768 | format_precision(total_MB), |
| 769 | format_precision(targets_MB), |
| 770 | format_precision(sources_MB), |
| 771 | format_precision(hashcache_MB), |
| 772 | format_precision(pool_MB)); |
| 773 | } |
| 774 | else |
| 775 | { |
| 776 | const double total_MB = targets_MB + sources_MB + pool_MB; |
| 777 | info.format("VRAM: {} MB | TGT: {} MB | SRC: {} MB | PL: {} MB", |
| 778 | format_precision(total_MB), |
| 779 | format_precision(targets_MB), |
| 780 | format_precision(sources_MB), |
| 781 | format_precision(pool_MB)); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | void GSgetTitleStats(std::string& info) |
| 786 | { |
no test coverage detected