From ce7b1576e04c8130e9e4b6182f564d3fcd8f751f Mon Sep 17 00:00:00 2001 From: nastys Date: Sat, 5 Mar 2022 17:32:35 +0100 Subject: [PATCH] Low Power Mode detection Change low to reduced Low Power Mode detection Fix namespace space Low Power Mode detection Fix namespace space Low Power Mode detection --- darwin/util/sysinfo_darwin.mm | 8 ++++++++ rpcs3/main.cpp | 11 +++++++++++ rpcs3/util/sysinfo.cpp | 14 ++++++++++++++ rpcs3/util/sysinfo.hpp | 2 ++ 4 files changed, 35 insertions(+) diff --git a/darwin/util/sysinfo_darwin.mm b/darwin/util/sysinfo_darwin.mm index 67599f9d2c..e398b69d03 100644 --- a/darwin/util/sysinfo_darwin.mm +++ b/darwin/util/sysinfo_darwin.mm @@ -19,3 +19,11 @@ namespace Darwin_Version return osver.patchVersion; } } + +namespace Darwin_ProcessInfo +{ + bool getLowPowerModeEnabled() + { + return NSProcessInfo.processInfo.isLowPowerModeEnabled; + } +} diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index dfb6587131..911332482d 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -513,14 +513,18 @@ int main(int argc, char** argv) rlim.rlim_max = 4096; #ifdef RLIMIT_NOFILE if (::setrlimit(RLIMIT_NOFILE, &rlim) != 0) + { std::cerr << "Failed to set max open file limit (4096).\n"; + } #endif rlim.rlim_cur = 0x80000000; rlim.rlim_max = 0x80000000; #ifdef RLIMIT_MEMLOCK if (::setrlimit(RLIMIT_MEMLOCK, &rlim) != 0) + { std::cerr << "Failed to set RLIMIT_MEMLOCK size to 2 GiB. Try to update your system configuration.\n"; + } #endif // Work around crash on startup on KDE: https://bugs.kde.org/show_bug.cgi?id=401637 setenv( "KDE_DEBUG", "1", 0 ); @@ -531,7 +535,9 @@ int main(int argc, char** argv) ::getrlimit(RLIMIT_NOFILE, &rlim); rlim.rlim_cur = OPEN_MAX; if (::setrlimit(RLIMIT_NOFILE, &rlim) != 0) + { std::cerr << "Failed to set max open file limit (" << OPEN_MAX << ").\n"; + } #endif #ifndef _WIN32 @@ -539,6 +545,11 @@ int main(int argc, char** argv) sys_log.notice("Maximum open file descriptors: %i", utils::get_maxfiles()); #endif + if (utils::get_low_power_mode()) + { + sys_log.error("Low Power Mode is enabled, performance may be reduced."); + } + std::lock_guard qt_init(s_qt_init); // The constructor of QApplication eats the --style and --stylesheet arguments. diff --git a/rpcs3/util/sysinfo.cpp b/rpcs3/util/sysinfo.cpp index 8a440962f8..29f62a1525 100755 --- a/rpcs3/util/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -57,6 +57,11 @@ namespace Darwin_Version extern int getNSminorVersion(); extern int getNSpatchVersion(); } + +namespace Darwin_ProcessInfo +{ + extern bool getLowPowerModeEnabled(); +} #endif bool utils::has_ssse3() @@ -474,6 +479,15 @@ int utils::get_maxfiles() #endif } +bool utils::get_low_power_mode() +{ +#ifdef __APPLE__ + return Darwin_ProcessInfo::getLowPowerModeEnabled(); +#else + return false; +#endif +} + static constexpr ullong round_tsc(ullong val) { return utils::rounded_div(val, 1'000'000) * 1'000'000; diff --git a/rpcs3/util/sysinfo.hpp b/rpcs3/util/sysinfo.hpp index 3aabc97311..ef8c09c78c 100755 --- a/rpcs3/util/sysinfo.hpp +++ b/rpcs3/util/sysinfo.hpp @@ -51,6 +51,8 @@ namespace utils int get_maxfiles(); + bool get_low_power_mode(); + ullong get_tsc_freq(); u64 get_total_memory();