Config: Port DisableICache setting to new config system.

This commit is contained in:
Admiral H. Curtiss 2022-01-06 01:23:56 +01:00
parent d98c6b0b1d
commit 7184983ee8
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
6 changed files with 25 additions and 11 deletions

View File

@ -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<BootParameters> 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<BootParameters> 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;

View File

@ -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

View File

@ -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;

View File

@ -64,7 +64,6 @@ struct SConfig
bool bJITNoBlockLinking = false;
bool bFastmem;
bool bDisableICache = false;
int iTimingVariance = 40; // in milli secounds
bool bCPUThread = true;

View File

@ -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<u32, 128> 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

View File

@ -4,6 +4,7 @@
#pragma once
#include <array>
#include <optional>
#include "Common/CommonTypes.h"
@ -30,11 +31,16 @@ struct InstructionCache
std::array<u8, 1 << 21> lookup_table_ex{};
std::array<u8, 1 << 20> lookup_table_vmem{};
bool m_disable_icache = false;
std::optional<size_t> 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