From 7184983ee8f6938be5d5abea1857bc54c832282a Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 6 Jan 2022 01:23:56 +0100 Subject: [PATCH] Config: Port DisableICache setting to new config system. --- Source/Core/Core/BootManager.cpp | 5 ----- .../Core/ConfigLoaders/IsSettingSaveable.cpp | 1 + Source/Core/Core/ConfigManager.cpp | 2 -- Source/Core/Core/ConfigManager.h | 1 - Source/Core/Core/PowerPC/PPCCache.cpp | 21 ++++++++++++++++--- Source/Core/Core/PowerPC/PPCCache.h | 6 ++++++ 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index ce45fa4999..4faf55f87d 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -74,7 +74,6 @@ private: bool bCPUThread = false; bool bSyncGPUOnSkipIdleHack = false; bool bMMU = false; - bool bDisableICache = false; bool bSyncGPU = false; int iSyncGpuMaxDistance = 0; int iSyncGpuMinDistance = 0; @@ -91,7 +90,6 @@ void ConfigCache::SaveConfig(const SConfig& config) bCPUThread = config.bCPUThread; bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack; - bDisableICache = config.bDisableICache; bMMU = config.bMMU; bSyncGPU = config.bSyncGPU; iSyncGpuMaxDistance = config.iSyncGpuMaxDistance; @@ -120,7 +118,6 @@ void ConfigCache::RestoreConfig(SConfig* config) config->bCPUThread = bCPUThread; config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack; - config->bDisableICache = bDisableICache; config->bMMU = bMMU; config->bSyncGPU = bSyncGPU; config->iSyncGpuMaxDistance = iSyncGpuMaxDistance; @@ -179,7 +176,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread); core_section->Get("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack, StartUp.bSyncGPUOnSkipIdleHack); - core_section->Get("DisableICache", &StartUp.bDisableICache, StartUp.bDisableICache); core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU); core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU); core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); @@ -257,7 +253,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) config_cache.bSetEXIDevice[0] = true; config_cache.bSetEXIDevice[1] = true; config_cache.bSetEXIDevice[2] = true; - StartUp.bDisableICache = netplay_settings.m_DisableICache; StartUp.bSyncGPUOnSkipIdleHack = netplay_settings.m_SyncOnSkipIdle; StartUp.bSyncGPU = netplay_settings.m_SyncGPU; StartUp.iSyncGpuMaxDistance = netplay_settings.m_SyncGpuMaxDistance; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 89d1a105da..42bc8d8208 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -100,6 +100,7 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::MAIN_EMULATION_SPEED.GetLocation(), &Config::MAIN_PERF_MAP_DIR.GetLocation(), &Config::MAIN_GPU_DETERMINISM_MODE.GetLocation(), + &Config::MAIN_DISABLE_ICACHE.GetLocation(), // UI.General diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 6c2ff77cc2..b90cf59e59 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -161,7 +161,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("SyncGpuMinDistance", &iSyncGpuMinDistance, -200000); core->Get("SyncGpuOverclock", &fSyncGpuOverclock, 1.0f); core->Get("FastDiscSpeed", &bFastDiscSpeed, false); - core->Get("DisableICache", &bDisableICache, false); } void SConfig::ResetRunningGameMetadata() @@ -281,7 +280,6 @@ void SConfig::LoadDefaults() bCPUThread = false; bSyncGPUOnSkipIdleHack = true; bFastmem = true; - bDisableICache = false; bMMU = false; iBBDumpPort = -1; bSyncGPU = false; diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 6de804185c..f639c33ec4 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -64,7 +64,6 @@ struct SConfig bool bJITNoBlockLinking = false; bool bFastmem; - bool bDisableICache = false; int iTimingVariance = 40; // in milli secounds bool bCPUThread = true; diff --git a/Source/Core/Core/PowerPC/PPCCache.cpp b/Source/Core/Core/PowerPC/PPCCache.cpp index 181764dc3b..9207ea5f72 100644 --- a/Source/Core/Core/PowerPC/PPCCache.cpp +++ b/Source/Core/Core/PowerPC/PPCCache.cpp @@ -7,7 +7,7 @@ #include "Common/ChunkFile.h" #include "Common/Swap.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/DolphinAnalytics.h" #include "Core/HW/Memmap.h" #include "Core/PowerPC/JitInterface.h" @@ -87,6 +87,12 @@ constexpr std::array s_way_from_plru = [] { }(); } // Anonymous namespace +InstructionCache::~InstructionCache() +{ + if (m_config_callback_id) + Config::RemoveConfigChangedCallback(*m_config_callback_id); +} + void InstructionCache::Reset() { valid.fill(0); @@ -99,6 +105,10 @@ void InstructionCache::Reset() void InstructionCache::Init() { + if (!m_config_callback_id) + m_config_callback_id = Config::AddConfigChangedCallback([this] { RefreshConfig(); }); + RefreshConfig(); + data.fill({}); tags.fill({}); Reset(); @@ -106,7 +116,7 @@ void InstructionCache::Init() void InstructionCache::Invalidate(u32 addr) { - if (!HID0.ICE || SConfig::GetInstance().bDisableICache) + if (!HID0.ICE || m_disable_icache) return; // Invalidates the whole set @@ -129,7 +139,7 @@ void InstructionCache::Invalidate(u32 addr) u32 InstructionCache::ReadInstruction(u32 addr) { - if (!HID0.ICE || SConfig::GetInstance().bDisableICache) // instruction cache is disabled + if (!HID0.ICE || m_disable_icache) // instruction cache is disabled return Memory::Read_U32(addr); u32 set = (addr >> 5) & 0x7f; u32 tag = addr >> 12; @@ -202,4 +212,9 @@ void InstructionCache::DoState(PointerWrap& p) p.DoArray(lookup_table_ex); p.DoArray(lookup_table_vmem); } + +void InstructionCache::RefreshConfig() +{ + m_disable_icache = Config::Get(Config::MAIN_DISABLE_ICACHE); +} } // namespace PowerPC diff --git a/Source/Core/Core/PowerPC/PPCCache.h b/Source/Core/Core/PowerPC/PPCCache.h index fdc23ba546..431bc10c41 100644 --- a/Source/Core/Core/PowerPC/PPCCache.h +++ b/Source/Core/Core/PowerPC/PPCCache.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include "Common/CommonTypes.h" @@ -30,11 +31,16 @@ struct InstructionCache std::array lookup_table_ex{}; std::array lookup_table_vmem{}; + bool m_disable_icache = false; + std::optional m_config_callback_id = std::nullopt; + InstructionCache() = default; + ~InstructionCache(); u32 ReadInstruction(u32 addr); void Invalidate(u32 addr); void Init(); void Reset(); void DoState(PointerWrap& p); + void RefreshConfig(); }; } // namespace PowerPC