From dc7e7d08ad012668fc9d4776fefa16eebfebef4e Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 6 Jan 2022 01:51:29 +0100 Subject: [PATCH] Config: Port Fastmem setting to new config system. --- Source/Core/Core/BootManager.cpp | 1 - Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp | 1 + Source/Core/Core/ConfigManager.cpp | 3 --- Source/Core/Core/ConfigManager.h | 2 -- Source/Core/Core/Core.cpp | 5 +++-- Source/Core/Core/DolphinAnalytics.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 5 ++--- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 5 ++--- Source/Core/Core/PowerPC/JitCommon/JitBase.cpp | 3 ++- Source/Core/Core/PowerPC/JitCommon/JitBase.h | 1 + Source/Core/DolphinQt/MenuBar.cpp | 4 ++-- 11 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index c7d9983efd..5f72002545 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -248,7 +248,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) StartUp.iSyncGpuMinDistance = netplay_settings.m_SyncGpuMinDistance; StartUp.fSyncGpuOverclock = netplay_settings.m_SyncGpuOverclock; StartUp.bMMU = netplay_settings.m_MMU; - StartUp.bFastmem = netplay_settings.m_Fastmem; } else { diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 591df9aefe..59bff15aa0 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -103,6 +103,7 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::MAIN_DISABLE_ICACHE.GetLocation(), &Config::MAIN_FAST_DISC_SPEED.GetLocation(), &Config::MAIN_SYNC_ON_SKIP_IDLE.GetLocation(), + &Config::MAIN_FASTMEM.GetLocation(), // UI.General diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 41d1c5df67..1ad3213651 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -100,7 +100,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) IniFile::Section* core = ini.GetOrCreateSection("Core"); core->Set("TimingVariance", iTimingVariance); - core->Set("Fastmem", bFastmem); core->Set("CPUThread", bCPUThread); core->Set("SyncGPU", bSyncGPU); core->Set("SyncGpuMaxDistance", iSyncGpuMaxDistance); @@ -136,7 +135,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) { IniFile::Section* core = ini.GetOrCreateSection("Core"); - core->Get("Fastmem", &bFastmem, true); core->Get("TimingVariance", &iTimingVariance, 40); core->Get("CPUThread", &bCPUThread, true); core->Get("SlotA", (int*)&m_EXIDevice[0], ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER); @@ -275,7 +273,6 @@ void SConfig::LoadDefaults() iTimingVariance = 40; bCPUThread = false; - bFastmem = true; bMMU = false; iBBDumpPort = -1; bSyncGPU = false; diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 7cec9e4de2..0bef47a7e0 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -63,8 +63,6 @@ struct SConfig bool bJITNoBlockCache = false; bool bJITNoBlockLinking = false; - bool bFastmem; - int iTimingVariance = 40; // in milli secounds bool bCPUThread = true; bool bCopyWiiSaveNetplay = true; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index a5ae7784b6..df575b431f 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -348,7 +348,8 @@ static void CpuThread(const std::optional& savestate_path, bool del static_cast(IDCache::GetEnvForThread()); #endif - if (_CoreParameter.bFastmem) + const bool fastmem_enabled = Config::Get(Config::MAIN_FASTMEM); + if (fastmem_enabled) EMM::InstallExceptionHandler(); // Let's run under memory watch #ifdef USE_MEMORYWATCHER @@ -396,7 +397,7 @@ static void CpuThread(const std::optional& savestate_path, bool del s_is_started = false; - if (_CoreParameter.bFastmem) + if (fastmem_enabled) EMM::UninstallExceptionHandler(); if (GDBStub::IsActive()) diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp index 6ef1109cb4..93ed3888dd 100644 --- a/Source/Core/Core/DolphinAnalytics.cpp +++ b/Source/Core/Core/DolphinAnalytics.cpp @@ -360,7 +360,7 @@ void DolphinAnalytics::MakePerGameBuilder() builder.AddData("cfg-dsp-jit", Config::Get(Config::MAIN_DSP_JIT)); builder.AddData("cfg-dsp-thread", Config::Get(Config::MAIN_DSP_THREAD)); builder.AddData("cfg-cpu-thread", SConfig::GetInstance().bCPUThread); - builder.AddData("cfg-fastmem", SConfig::GetInstance().bFastmem); + builder.AddData("cfg-fastmem", Config::Get(Config::MAIN_FASTMEM)); builder.AddData("cfg-syncgpu", SConfig::GetInstance().bSyncGPU); builder.AddData("cfg-audio-backend", Config::Get(Config::MAIN_AUDIO_BACKEND)); builder.AddData("cfg-oc-enable", Config::Get(Config::MAIN_OVERCLOCK_ENABLE)); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 84e2970d27..fc77921ece 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -332,7 +332,7 @@ void Jit64::Init() { EnableBlockLink(); - jo.fastmem_arena = SConfig::GetInstance().bFastmem && Memory::InitFastmemArena(); + jo.fastmem_arena = m_fastmem_enabled && Memory::InitFastmemArena(); jo.optimizeGatherPipe = true; jo.accurateSinglePrecision = true; UpdateMemoryAndExceptionOptions(); @@ -355,8 +355,7 @@ void Jit64::Init() // BLR optimization has the same consequences as block linking, as well as // depending on the fault handler to be safe in the event of excessive BL. - m_enable_blr_optimization = - jo.enableBlocklink && SConfig::GetInstance().bFastmem && !m_enable_debugging; + m_enable_blr_optimization = jo.enableBlocklink && m_fastmem_enabled && !m_enable_debugging; m_cleanup_after_stackfault = false; m_stack = nullptr; diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index da44109464..c701f160c6 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -52,7 +52,7 @@ void JitArm64::Init() AllocCodeSpace(CODE_SIZE + child_code_size); AddChildCodeSpace(&m_far_code, child_code_size); - jo.fastmem_arena = SConfig::GetInstance().bFastmem && Memory::InitFastmemArena(); + jo.fastmem_arena = m_fastmem_enabled && Memory::InitFastmemArena(); jo.enableBlocklink = true; jo.optimizeGatherPipe = true; UpdateMemoryAndExceptionOptions(); @@ -67,8 +67,7 @@ void JitArm64::Init() analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE); analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_FOLLOW); - m_enable_blr_optimization = - jo.enableBlocklink && SConfig::GetInstance().bFastmem && !m_enable_debugging; + m_enable_blr_optimization = jo.enableBlocklink && m_fastmem_enabled && !m_enable_debugging; m_cleanup_after_stackfault = false; AllocStack(); diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp index 53d41868a5..5dfe40cfd4 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp @@ -54,6 +54,7 @@ void JitBase::RefreshConfig() m_low_dcbz_hack = Config::Get(Config::MAIN_LOW_DCBZ_HACK); m_fprf = Config::Get(Config::MAIN_FPRF); m_accurate_nans = Config::Get(Config::MAIN_ACCURATE_NANS); + m_fastmem_enabled = Config::Get(Config::MAIN_FASTMEM); analyzer.SetDebuggingEnabled(m_enable_debugging); analyzer.SetBranchFollowingEnabled(Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH)); analyzer.SetFloatExceptionsEnabled(m_enable_float_exceptions); @@ -78,7 +79,7 @@ bool JitBase::CanMergeNextInstructions(int count) const void JitBase::UpdateMemoryAndExceptionOptions() { bool any_watchpoints = PowerPC::memchecks.HasAny(); - jo.fastmem = SConfig::GetInstance().bFastmem && jo.fastmem_arena && (MSR.DR || !any_watchpoints); + jo.fastmem = m_fastmem_enabled && jo.fastmem_arena && (MSR.DR || !any_watchpoints); jo.memcheck = SConfig::GetInstance().bMMU || any_watchpoints; jo.fp_exceptions = m_enable_float_exceptions; jo.div_by_zero_exceptions = m_enable_div_by_zero_exceptions; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.h b/Source/Core/Core/PowerPC/JitCommon/JitBase.h index ccda3fc12d..d9e7ae8e94 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.h @@ -132,6 +132,7 @@ protected: bool m_low_dcbz_hack = false; bool m_fprf = false; bool m_accurate_nans = false; + bool m_fastmem_enabled = false; void RefreshConfig(); diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index c2d64f52f0..0c08dd3390 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -829,9 +829,9 @@ void MenuBar::AddJITMenu() m_jit_disable_fastmem = m_jit->addAction(tr("Disable Fastmem")); m_jit_disable_fastmem->setCheckable(true); - m_jit_disable_fastmem->setChecked(!SConfig::GetInstance().bFastmem); + m_jit_disable_fastmem->setChecked(!Config::Get(Config::MAIN_FASTMEM)); connect(m_jit_disable_fastmem, &QAction::toggled, [this](bool enabled) { - SConfig::GetInstance().bFastmem = !enabled; + Config::SetBaseOrCurrent(Config::MAIN_FASTMEM, !enabled); ClearCache(); });