From d98c6b0b1d6203397b81fd0d74db1dfc49ea49f6 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 6 Jan 2022 01:08:56 +0100 Subject: [PATCH] Config: Port GPUDeterminismMode setting to new config system. --- Source/Core/Core/BootManager.cpp | 21 ------------------- Source/Core/Core/Config/MainSettings.cpp | 17 +++++++++++++++ Source/Core/Core/Config/MainSettings.h | 11 ++++++++++ .../Core/ConfigLoaders/IsSettingSaveable.cpp | 1 + Source/Core/Core/ConfigManager.cpp | 2 -- Source/Core/Core/ConfigManager.h | 14 ------------- Source/Core/VideoCommon/Fifo.cpp | 9 ++++---- 7 files changed, 34 insertions(+), 41 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 29cb4bfec9..ce45fa4999 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -80,7 +80,6 @@ private: int iSyncGpuMinDistance = 0; float fSyncGpuOverclock = 0; bool bFastDiscSpeed = false; - std::string m_strGPUDeterminismMode; std::array iWiimoteSource{}; std::array Pads{}; std::array m_EXIDevice{}; @@ -99,7 +98,6 @@ void ConfigCache::SaveConfig(const SConfig& config) iSyncGpuMinDistance = config.iSyncGpuMinDistance; fSyncGpuOverclock = config.fSyncGpuOverclock; bFastDiscSpeed = config.bFastDiscSpeed; - m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; for (int i = 0; i != MAX_BBMOTES; ++i) iWiimoteSource[i] = WiimoteCommon::GetSource(i); @@ -152,25 +150,10 @@ void ConfigCache::RestoreConfig(SConfig* config) if (bSetEXIDevice[i]) config->m_EXIDevice[i] = m_EXIDevice[i]; } - - config->m_strGPUDeterminismMode = m_strGPUDeterminismMode; } static ConfigCache config_cache; -static GPUDeterminismMode ParseGPUDeterminismMode(const std::string& mode) -{ - if (mode == "auto") - return GPUDeterminismMode::Auto; - if (mode == "none") - return GPUDeterminismMode::Disabled; - if (mode == "fake-completion") - return GPUDeterminismMode::FakeCompletion; - - NOTICE_LOG_FMT(BOOT, "Unknown GPU determinism mode {}", mode); - return GPUDeterminismMode::Auto; -} - // Boot the ISO or file bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) { @@ -200,8 +183,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU); core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU); core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); - core_section->Get("GPUDeterminismMode", &StartUp.m_strGPUDeterminismMode, - StartUp.m_strGPUDeterminismMode); for (unsigned int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i) { @@ -241,8 +222,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) } } - StartUp.m_GPUDeterminismMode = ParseGPUDeterminismMode(StartUp.m_strGPUDeterminismMode); - // Movie settings if (Movie::IsPlayingInput() && Movie::IsConfigSaved()) { diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 4e17de9868..f0c687f94e 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -10,6 +10,7 @@ #include "AudioCommon/AudioCommon.h" #include "Common/CommonPaths.h" #include "Common/Config/Config.h" +#include "Common/Logging/Log.h" #include "Common/MathUtil.h" #include "Common/StringUtil.h" #include "Common/Version.h" @@ -118,8 +119,24 @@ const Info MAIN_MEM1_SIZE{{System::Main, "Core", "MEM1Size"}, Memory::MEM1_ const Info MAIN_MEM2_SIZE{{System::Main, "Core", "MEM2Size"}, Memory::MEM2_SIZE_RETAIL}; const Info MAIN_GFX_BACKEND{{System::Main, "Core", "GFXBackend"}, VideoBackendBase::GetDefaultBackendName()}; + const Info MAIN_GPU_DETERMINISM_MODE{{System::Main, "Core", "GPUDeterminismMode"}, "auto"}; + +GPUDeterminismMode GetGPUDeterminismMode() +{ + auto mode = Config::Get(Config::MAIN_GPU_DETERMINISM_MODE); + if (mode == "auto") + return GPUDeterminismMode::Auto; + if (mode == "none") + return GPUDeterminismMode::Disabled; + if (mode == "fake-completion") + return GPUDeterminismMode::FakeCompletion; + + NOTICE_LOG_FMT(CORE, "Unknown GPU determinism mode {}", mode); + return GPUDeterminismMode::Auto; +} + const Info MAIN_PERF_MAP_DIR{{System::Main, "Core", "PerfMapDir"}, ""}; const Info MAIN_CUSTOM_RTC_ENABLE{{System::Main, "Core", "EnableCustomRTC"}, false}; // Default to seconds between 1.1.1970 and 1.1.2000 diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 910b7e8ee0..81daa03a56 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -93,7 +93,18 @@ extern const Info MAIN_MEM1_SIZE; extern const Info MAIN_MEM2_SIZE; // Should really be part of System::GFX, but again, we're stuck with past mistakes. extern const Info MAIN_GFX_BACKEND; + +enum class GPUDeterminismMode +{ + Auto, + Disabled, + // This is currently the only mode. There will probably be at least + // one more at some point. + FakeCompletion, +}; extern const Info MAIN_GPU_DETERMINISM_MODE; +GPUDeterminismMode GetGPUDeterminismMode(); + extern const Info MAIN_PERF_MAP_DIR; extern const Info MAIN_CUSTOM_RTC_ENABLE; extern const Info MAIN_CUSTOM_RTC_VALUE; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 358b0367cf..89d1a105da 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -99,6 +99,7 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::GetInfoForSimulateKonga(3).GetLocation(), &Config::MAIN_EMULATION_SPEED.GetLocation(), &Config::MAIN_PERF_MAP_DIR.GetLocation(), + &Config::MAIN_GPU_DETERMINISM_MODE.GetLocation(), // UI.General diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 9e47845899..6c2ff77cc2 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -120,7 +120,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("WiimoteEnableSpeaker", m_WiimoteEnableSpeaker); core->Set("WiimoteControllerInterface", connect_wiimotes_for_ciface); core->Set("MMU", bMMU); - core->Set("GPUDeterminismMode", m_strGPUDeterminismMode); } void SConfig::LoadSettings() @@ -163,7 +162,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("SyncGpuOverclock", &fSyncGpuOverclock, 1.0f); core->Get("FastDiscSpeed", &bFastDiscSpeed, false); core->Get("DisableICache", &bDisableICache, false); - core->Get("GPUDeterminismMode", &m_strGPUDeterminismMode, "auto"); } void SConfig::ResetRunningGameMetadata() diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 685a69fe05..6de804185c 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -47,15 +47,6 @@ enum SIDevices : int; struct BootParameters; -enum class GPUDeterminismMode -{ - Auto, - Disabled, - // This is currently the only mode. There will probably be at least - // one more at some point. - FakeCompletion, -}; - struct SConfig { // Wii Devices @@ -94,11 +85,6 @@ struct SConfig DiscIO::Region m_region; - std::string m_strGPUDeterminismMode; - - // set based on the string version - GPUDeterminismMode m_GPUDeterminismMode; - // files std::string m_strBootROM; std::string m_strSRAM; diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index f96c71b550..33dd94817d 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -14,6 +14,7 @@ #include "Common/MemoryUtil.h" #include "Common/MsgHandler.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" #include "Core/HW/Memmap.h" @@ -509,15 +510,15 @@ void UpdateWantDeterminism(bool want) // it should be safe to change this. const SConfig& param = SConfig::GetInstance(); bool gpu_thread = false; - switch (param.m_GPUDeterminismMode) + switch (Config::GetGPUDeterminismMode()) { - case GPUDeterminismMode::Auto: + case Config::GPUDeterminismMode::Auto: gpu_thread = want; break; - case GPUDeterminismMode::Disabled: + case Config::GPUDeterminismMode::Disabled: gpu_thread = false; break; - case GPUDeterminismMode::FakeCompletion: + case Config::GPUDeterminismMode::FakeCompletion: gpu_thread = true; break; }