diff options
author | Lioncash <mathew1800@gmail.com> | 2019-10-17 22:10:24 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-10-17 22:13:14 +0200 |
commit | b77430df7035ed2baba4705ff53861df8a5b3e21 (patch) | |
tree | 28812c67beed8fc5f6a2e555f50818827bd6b6a7 /src/core | |
parent | apm/controller: Make GetCurrentPerformanceMode() a const member function (diff) | |
download | yuzu-b77430df7035ed2baba4705ff53861df8a5b3e21.tar yuzu-b77430df7035ed2baba4705ff53861df8a5b3e21.tar.gz yuzu-b77430df7035ed2baba4705ff53861df8a5b3e21.tar.bz2 yuzu-b77430df7035ed2baba4705ff53861df8a5b3e21.tar.lz yuzu-b77430df7035ed2baba4705ff53861df8a5b3e21.tar.xz yuzu-b77430df7035ed2baba4705ff53861df8a5b3e21.tar.zst yuzu-b77430df7035ed2baba4705ff53861df8a5b3e21.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/service/apm/controller.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/core/hle/service/apm/controller.cpp b/src/core/hle/service/apm/controller.cpp index d9e8d247d..25a886238 100644 --- a/src/core/hle/service/apm/controller.cpp +++ b/src/core/hle/service/apm/controller.cpp @@ -2,6 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <array> +#include <utility> + #include "common/logging/log.h" #include "core/core_timing.h" #include "core/hle/service/apm/controller.h" @@ -9,8 +13,7 @@ namespace Service::APM { -constexpr PerformanceConfiguration DEFAULT_PERFORMANCE_CONFIGURATION = - PerformanceConfiguration::Config7; +constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7; Controller::Controller(Core::Timing::CoreTiming& core_timing) : core_timing{core_timing}, configs{ @@ -22,18 +25,35 @@ Controller::~Controller() = default; void Controller::SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config) { - static const std::map<PerformanceConfiguration, u32> PCONFIG_TO_SPEED_MAP{ - {PerformanceConfiguration::Config1, 1020}, {PerformanceConfiguration::Config2, 1020}, - {PerformanceConfiguration::Config3, 1224}, {PerformanceConfiguration::Config4, 1020}, - {PerformanceConfiguration::Config5, 1020}, {PerformanceConfiguration::Config6, 1224}, - {PerformanceConfiguration::Config7, 1020}, {PerformanceConfiguration::Config8, 1020}, - {PerformanceConfiguration::Config9, 1020}, {PerformanceConfiguration::Config10, 1020}, - {PerformanceConfiguration::Config11, 1020}, {PerformanceConfiguration::Config12, 1020}, - {PerformanceConfiguration::Config13, 1785}, {PerformanceConfiguration::Config14, 1785}, - {PerformanceConfiguration::Config15, 1020}, {PerformanceConfiguration::Config16, 1020}, - }; - - SetClockSpeed(PCONFIG_TO_SPEED_MAP.find(config)->second); + static constexpr std::array<std::pair<PerformanceConfiguration, u32>, 16> config_to_speed{{ + {PerformanceConfiguration::Config1, 1020}, + {PerformanceConfiguration::Config2, 1020}, + {PerformanceConfiguration::Config3, 1224}, + {PerformanceConfiguration::Config4, 1020}, + {PerformanceConfiguration::Config5, 1020}, + {PerformanceConfiguration::Config6, 1224}, + {PerformanceConfiguration::Config7, 1020}, + {PerformanceConfiguration::Config8, 1020}, + {PerformanceConfiguration::Config9, 1020}, + {PerformanceConfiguration::Config10, 1020}, + {PerformanceConfiguration::Config11, 1020}, + {PerformanceConfiguration::Config12, 1020}, + {PerformanceConfiguration::Config13, 1785}, + {PerformanceConfiguration::Config14, 1785}, + {PerformanceConfiguration::Config15, 1020}, + {PerformanceConfiguration::Config16, 1020}, + }}; + + const auto iter = std::find_if(config_to_speed.cbegin(), config_to_speed.cend(), + [config](const auto& entry) { return entry.first == config; }); + + if (iter == config_to_speed.cend()) { + LOG_ERROR(Service_APM, "Invalid performance configuration value provided: {}", + static_cast<u32>(config)); + return; + } + + SetClockSpeed(iter->second); configs.insert_or_assign(mode, config); } |