diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.kt index 298f2ebe24..5ccc6b4aad 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.kt @@ -902,7 +902,6 @@ enum class BooleanSetting( MAIN_OVERRIDE_REGION_SETTINGS, MAIN_MMU, MAIN_PAUSE_ON_PANIC, - MAIN_ACCURATE_CPU_CACHE, MAIN_RAM_OVERRIDE_ENABLE, MAIN_CUSTOM_RTC_ENABLE, MAIN_DSP_JIT, diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp index d5bd82ecd2..335658f532 100644 --- a/Source/Core/Core/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/PowerPC/PowerPC.cpp @@ -18,6 +18,7 @@ #include "Common/FloatUtils.h" #include "Common/Logging/Log.h" +#include "Core/CPUThreadConfigCallback.h" #include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -262,8 +263,25 @@ CPUCore DefaultCPUCore() #endif } +void PowerPCManager::RefreshConfig() +{ + const bool old_enable_dcache = m_ppc_state.m_enable_dcache; + + m_ppc_state.m_enable_dcache = Config::Get(Config::MAIN_ACCURATE_CPU_CACHE); + + if (old_enable_dcache && !m_ppc_state.m_enable_dcache) + { + INFO_LOG_FMT(POWERPC, "Flushing data cache"); + m_ppc_state.dCache.FlushAll(); + } +} + void PowerPCManager::Init(CPUCore cpu_core) { + m_registered_config_callback_id = + CPUThreadConfigCallback::AddConfigChangedCallback([this] { RefreshConfig(); }); + RefreshConfig(); + m_invalidate_cache_thread_safe = m_system.GetCoreTiming().RegisterEvent("invalidateEmulatedCache", InvalidateCacheThreadSafe); @@ -273,8 +291,6 @@ void PowerPCManager::Init(CPUCore cpu_core) m_ppc_state.iCache.Init(); m_ppc_state.dCache.Init(); - m_ppc_state.m_enable_dcache = Config::Get(Config::MAIN_ACCURATE_CPU_CACHE); - if (Config::Get(Config::MAIN_ENABLE_DEBUGGING)) m_breakpoints.ClearAllTemporary(); } @@ -307,6 +323,7 @@ void PowerPCManager::ScheduleInvalidateCacheThreadSafe(u32 address) void PowerPCManager::Shutdown() { + CPUThreadConfigCallback::RemoveConfigChangedCallback(m_registered_config_callback_id); InjectExternalCPUCore(nullptr); m_system.GetJitInterface().Shutdown(); m_system.GetInterpreter().Shutdown(); diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h index 30cbd47b41..7612018a93 100644 --- a/Source/Core/Core/PowerPC/PowerPC.h +++ b/Source/Core/Core/PowerPC/PowerPC.h @@ -13,6 +13,7 @@ #include "Common/CommonTypes.h" +#include "Core/CPUThreadConfigCallback.h" #include "Core/Debugger/PPCDebugInterface.h" #include "Core/PowerPC/BreakPoints.h" #include "Core/PowerPC/ConditionRegister.h" @@ -297,6 +298,7 @@ private: void InitializeCPUCore(CPUCore cpu_core); void ApplyMode(); void ResetRegisters(); + void RefreshConfig(); PowerPCState m_ppc_state; @@ -308,6 +310,8 @@ private: MemChecks m_memchecks; PPCDebugInterface m_debug_interface; + CPUThreadConfigCallback::ConfigChangedCallbackID m_registered_config_callback_id; + CoreTiming::EventType* m_invalidate_cache_thread_safe = nullptr; Core::System& m_system; diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp index af50a3f7e9..132ac4bf69 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp @@ -255,7 +255,6 @@ void AdvancedPane::Update() m_cpu_emulation_engine_combobox->setEnabled(!running); m_enable_mmu_checkbox->setEnabled(!running); m_pause_on_panic_checkbox->setEnabled(!running); - m_accurate_cpu_cache_checkbox->setEnabled(!running); { QFont bf = font();