From 0dd417e5f25bdfd8a3b08f5100b09c134f88ddeb Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 20 Feb 2020 03:55:25 +0100 Subject: [PATCH] Add more game window title options --- Utilities/sysinfo.cpp | 48 ++++++++++++++++++++++--------- Utilities/sysinfo.h | 6 ++++ rpcs3/Emu/title.cpp | 39 ++++++++++++++----------- rpcs3/Emu/title.h | 1 + rpcs3/rpcs3_version.cpp | 23 ++++++++++++++- rpcs3/rpcs3_version.h | 3 +- rpcs3/rpcs3qt/settings_dialog.cpp | 5 ++++ 7 files changed, 93 insertions(+), 32 deletions(-) diff --git a/Utilities/sysinfo.cpp b/Utilities/sysinfo.cpp index 70836d0416..72962af93c 100755 --- a/Utilities/sysinfo.cpp +++ b/Utilities/sysinfo.cpp @@ -75,9 +75,8 @@ bool utils::has_clwb() return g_value; } -std::string utils::get_system_info() +std::string utils::get_cpu_brand() { - std::string result; std::string brand; if (get_cpuid(0x80000000, 0)[0] >= 0x80000004) @@ -101,18 +100,16 @@ std::string utils::get_system_info() brand.erase(brand.begin() + found); } -#ifdef _WIN32 - ::SYSTEM_INFO sysInfo; - ::GetNativeSystemInfo(&sysInfo); - ::MEMORYSTATUSEX memInfo; - memInfo.dwLength = sizeof(memInfo); - ::GlobalMemoryStatusEx(&memInfo); - const u32 num_proc = sysInfo.dwNumberOfProcessors; - const u64 mem_total = memInfo.ullTotalPhys; -#else - const u32 num_proc = ::sysconf(_SC_NPROCESSORS_ONLN); - const u64 mem_total = ::sysconf(_SC_PHYS_PAGES) * ::sysconf(_SC_PAGE_SIZE); -#endif + return brand; +} + +std::string utils::get_system_info() +{ + std::string result; + + const std::string brand = get_cpu_brand(); + const u64 mem_total = get_total_memory(); + const u32 num_proc = get_thread_count(); fmt::append(result, "%s | %d Threads | %.2f GiB RAM", brand, num_proc, mem_total / (1024.0f * 1024 * 1024)); @@ -242,3 +239,26 @@ ullong utils::get_tsc_freq() return 0; #endif } + +u64 utils::get_total_memory() +{ +#ifdef _WIN32 + ::MEMORYSTATUSEX memInfo; + memInfo.dwLength = sizeof(memInfo); + ::GlobalMemoryStatusEx(&memInfo); + return memInfo.ullTotalPhys; +#else + return ::sysconf(_SC_PHYS_PAGES) * ::sysconf(_SC_PAGE_SIZE); +#endif +} + +u32 utils::get_thread_count() +{ +#ifdef _WIN32 + ::SYSTEM_INFO sysInfo; + ::GetNativeSystemInfo(&sysInfo); + return sysInfo.dwNumberOfProcessors; +#else + return ::sysconf(_SC_NPROCESSORS_ONLN); +#endif +} diff --git a/Utilities/sysinfo.h b/Utilities/sysinfo.h index 3eab517be5..b56c2a3942 100755 --- a/Utilities/sysinfo.h +++ b/Utilities/sysinfo.h @@ -47,6 +47,8 @@ namespace utils bool has_clwb(); + std::string get_cpu_brand(); + std::string get_system_info(); std::string get_firmware_version(); @@ -54,4 +56,8 @@ namespace utils std::string get_OS_version(); ullong get_tsc_freq(); + + u64 get_total_memory(); + + u32 get_thread_count(); } diff --git a/rpcs3/Emu/title.cpp b/rpcs3/Emu/title.cpp index 8162aacf4b..c79f6bbbbe 100644 --- a/rpcs3/Emu/title.cpp +++ b/rpcs3/Emu/title.cpp @@ -1,27 +1,12 @@ #include "stdafx.h" #include "title.h" #include "rpcs3_version.h" +#include "Utilities/sysinfo.h" namespace rpcs3 { std::string get_formatted_title(const title_format_data& title_data) { - // Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash - std::string version = rpcs3::get_version().to_string(); - const auto last_minus = version.find_last_of('-'); - - // Add branch and commit hash to version on frame unless it's master. - if (rpcs3::get_branch() != "master"sv && rpcs3::get_branch() != "HEAD"sv) - { - version = version.substr(0, ~last_minus ? last_minus + 9 : last_minus); - version += '-'; - version += rpcs3::get_branch(); - } - else - { - version = version.substr(0, last_minus); - } - // Parse title format string std::string title_string; @@ -71,6 +56,7 @@ namespace rpcs3 } case 'V': { + static const std::string version = rpcs3::get_version_and_branch(); title_string += version; break; } @@ -79,6 +65,27 @@ namespace rpcs3 fmt::append(title_string, "%.2f", title_data.fps); break; } + case 'G': + { + title_string += title_data.vulkan_adapter; + break; + } + case 'C': + { + static const std::string brand = utils::get_cpu_brand(); + title_string += brand; + break; + } + case 'c': + { + fmt::append(title_string, "%d", utils::get_thread_count()); + break; + } + case 'M': + { + fmt::append(title_string, "%.2f", utils::get_total_memory() / (1024.0f * 1024 * 1024)); + break; + } default: { title_string += '%'; diff --git a/rpcs3/Emu/title.h b/rpcs3/Emu/title.h index b6a3d58ca2..6a226983ba 100644 --- a/rpcs3/Emu/title.h +++ b/rpcs3/Emu/title.h @@ -10,6 +10,7 @@ namespace rpcs3 std::string title; std::string title_id; std::string renderer; + std::string vulkan_adapter; double fps = .0; }; diff --git a/rpcs3/rpcs3_version.cpp b/rpcs3/rpcs3_version.cpp index 1d6026a354..f475421e27 100644 --- a/rpcs3/rpcs3_version.cpp +++ b/rpcs3/rpcs3_version.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "rpcs3_version.h" #include "git-version.h" #include "Utilities/StrUtil.h" @@ -26,4 +26,25 @@ namespace rpcs3 static constexpr utils::version version{ 0, 0, 8, utils::version_type::alpha, 1, RPCS3_GIT_VERSION }; return version; } + + std::string get_version_and_branch() + { + // Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash + std::string version = rpcs3::get_version().to_string(); + const auto last_minus = version.find_last_of('-'); + + // Add branch and commit hash to version on frame unless it's master. + if (rpcs3::get_branch() != "master"sv && rpcs3::get_branch() != "HEAD"sv) + { + version = version.substr(0, ~last_minus ? last_minus + 9 : last_minus); + version += '-'; + version += rpcs3::get_branch(); + } + else + { + version = version.substr(0, last_minus); + } + + return version; + } } diff --git a/rpcs3/rpcs3_version.h b/rpcs3/rpcs3_version.h index 28eca23008..1324f92e29 100644 --- a/rpcs3/rpcs3_version.h +++ b/rpcs3/rpcs3_version.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include @@ -8,4 +8,5 @@ namespace rpcs3 std::string_view get_branch(); std::pair get_commit_and_hash(); const utils::version& get_version(); + std::string get_version_and_branch(); } diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 3b3128586d..3422758e69 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -1304,6 +1304,7 @@ settings_dialog::settings_dialog(std::shared_ptr guiSettings, std: rpcs3::title_format_data title_data; title_data.format = sstr(new_format); title_data.renderer = xemu_settings->GetSetting(emu_settings::Renderer); + title_data.vulkan_adapter = xemu_settings->GetSetting(emu_settings::VulkanAdapter); title_data.fps = 60.; if (game) @@ -1326,6 +1327,10 @@ settings_dialog::settings_dialog(std::shared_ptr guiSettings, std: const std::vector> window_title_glossary = { + { "%G", tr("GPU Model") }, + { "%C", tr("CPU Model") }, + { "%c", tr("Thread Count") }, + { "%M", tr("System Memory") }, { "%F", tr("Framerate") }, { "%R", tr("Renderer") }, { "%T", tr("Title") },