Merge pull request #7124 from lioncash/enum-class

PowerPC: Convert CPUCore enum into an enum class
This commit is contained in:
Léo Lam 2018-06-15 19:52:06 +02:00 committed by GitHub
commit 2b6d6c12bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 147 additions and 76 deletions

View File

@ -445,7 +445,7 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDi
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env, JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
jobject obj) jobject obj)
{ {
return PowerPC::DefaultCPUCore(); return static_cast<jint>(PowerPC::DefaultCPUCore());
} }
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env,

View File

@ -55,14 +55,14 @@ static bool TryParse(const std::string& str, N* const output)
// separators // separators
iss.imbue(std::locale("C")); iss.imbue(std::locale("C"));
N tmp = 0; N tmp;
if (iss >> tmp) if (iss >> tmp)
{ {
*output = tmp; *output = tmp;
return true; return true;
} }
else
return false; return false;
} }
template <typename N> template <typename N>

View File

@ -28,16 +28,12 @@
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/IniFile.h" #include "Common/IniFile.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/Config/Config.h"
#include "Core/Boot/Boot.h" #include "Core/Boot/Boot.h"
#include "Core/Config/MainSettings.h" #include "Core/Config/MainSettings.h"
#include "Core/Config/SYSCONFSettings.h" #include "Core/Config/SYSCONFSettings.h"
#include "Core/ConfigLoaders/BaseConfigLoader.h" #include "Core/ConfigLoaders/BaseConfigLoader.h"
#include "Core/ConfigLoaders/GameConfigLoader.h"
#include "Core/ConfigLoaders/MovieConfigLoader.h"
#include "Core/ConfigLoaders/NetPlayConfigLoader.h" #include "Core/ConfigLoaders/NetPlayConfigLoader.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
@ -47,6 +43,7 @@
#include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Core/Movie.h" #include "Core/Movie.h"
#include "Core/NetPlayProto.h" #include "Core/NetPlayProto.h"
#include "Core/PowerPC/PowerPC.h"
#include "DiscIO/Enums.h" #include "DiscIO/Enums.h"
@ -88,7 +85,7 @@ private:
bool bDSPHLE; bool bDSPHLE;
bool bHLE_BS2; bool bHLE_BS2;
int iSelectedLanguage; int iSelectedLanguage;
int iCPUCore; PowerPC::CPUCore cpu_core;
int Volume; int Volume;
float m_EmulationSpeed; float m_EmulationSpeed;
float m_OCFactor; float m_OCFactor;
@ -118,7 +115,7 @@ void ConfigCache::SaveConfig(const SConfig& config)
bDSPHLE = config.bDSPHLE; bDSPHLE = config.bDSPHLE;
bHLE_BS2 = config.bHLE_BS2; bHLE_BS2 = config.bHLE_BS2;
iSelectedLanguage = config.SelectedLanguage; iSelectedLanguage = config.SelectedLanguage;
iCPUCore = config.iCPUCore; cpu_core = config.cpu_core;
Volume = config.m_Volume; Volume = config.m_Volume;
m_EmulationSpeed = config.m_EmulationSpeed; m_EmulationSpeed = config.m_EmulationSpeed;
strBackend = config.m_strVideoBackend; strBackend = config.m_strVideoBackend;
@ -159,7 +156,7 @@ void ConfigCache::RestoreConfig(SConfig* config)
config->bDSPHLE = bDSPHLE; config->bDSPHLE = bDSPHLE;
config->bHLE_BS2 = bHLE_BS2; config->bHLE_BS2 = bHLE_BS2;
config->SelectedLanguage = iSelectedLanguage; config->SelectedLanguage = iSelectedLanguage;
config->iCPUCore = iCPUCore; config->cpu_core = cpu_core;
// Only change these back if they were actually set by game ini, since they can be changed while a // Only change these back if they were actually set by game ini, since they can be changed while a
// game is running. // game is running.
@ -255,7 +252,7 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed);
core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE); core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
core_section->Get("GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend); core_section->Get("GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend);
core_section->Get("CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore); core_section->Get("CPUCore", &StartUp.cpu_core, StartUp.cpu_core);
core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2); core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
core_section->Get("GameCubeLanguage", &StartUp.SelectedLanguage, StartUp.SelectedLanguage); core_section->Get("GameCubeLanguage", &StartUp.SelectedLanguage, StartUp.SelectedLanguage);
if (core_section->Get("EmulationSpeed", &StartUp.m_EmulationSpeed, StartUp.m_EmulationSpeed)) if (core_section->Get("EmulationSpeed", &StartUp.m_EmulationSpeed, StartUp.m_EmulationSpeed))
@ -317,7 +314,7 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD); StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD);
StartUp.bDSPHLE = Config::Get(Config::MAIN_DSP_HLE); StartUp.bDSPHLE = Config::Get(Config::MAIN_DSP_HLE);
StartUp.bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED); StartUp.bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED);
StartUp.iCPUCore = Config::Get(Config::MAIN_CPU_CORE); StartUp.cpu_core = Config::Get(Config::MAIN_CPU_CORE);
StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU); StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU);
if (!StartUp.bWii) if (!StartUp.bWii)
StartUp.SelectedLanguage = Config::Get(Config::MAIN_GC_LANGUAGE); StartUp.SelectedLanguage = Config::Get(Config::MAIN_GC_LANGUAGE);
@ -343,7 +340,7 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE; StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE;
StartUp.bEnableMemcardSdWriting = g_NetPlaySettings.m_WriteToMemcard; StartUp.bEnableMemcardSdWriting = g_NetPlaySettings.m_WriteToMemcard;
StartUp.bCopyWiiSaveNetplay = g_NetPlaySettings.m_CopyWiiSave; StartUp.bCopyWiiSaveNetplay = g_NetPlaySettings.m_CopyWiiSave;
StartUp.iCPUCore = g_NetPlaySettings.m_CPUcore; StartUp.cpu_core = g_NetPlaySettings.m_CPUcore;
StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage; StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage;
StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage; StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage;
StartUp.m_DSPEnableJIT = g_NetPlaySettings.m_DSPEnableJIT; StartUp.m_DSPEnableJIT = g_NetPlaySettings.m_DSPEnableJIT;

View File

@ -16,7 +16,8 @@ namespace Config
// Main.Core // Main.Core
const ConfigInfo<bool> MAIN_SKIP_IPL{{System::Main, "Core", "SkipIPL"}, true}; const ConfigInfo<bool> MAIN_SKIP_IPL{{System::Main, "Core", "SkipIPL"}, true};
const ConfigInfo<int> MAIN_CPU_CORE{{System::Main, "Core", "CPUCore"}, PowerPC::DefaultCPUCore()}; const ConfigInfo<PowerPC::CPUCore> MAIN_CPU_CORE{{System::Main, "Core", "CPUCore"},
PowerPC::DefaultCPUCore()};
const ConfigInfo<bool> MAIN_FASTMEM{{System::Main, "Core", "Fastmem"}, true}; const ConfigInfo<bool> MAIN_FASTMEM{{System::Main, "Core", "Fastmem"}, true};
const ConfigInfo<bool> MAIN_DSP_HLE{{System::Main, "Core", "DSPHLE"}, true}; const ConfigInfo<bool> MAIN_DSP_HLE{{System::Main, "Core", "DSPHLE"}, true};
const ConfigInfo<int> MAIN_TIMING_VARIANCE{{System::Main, "Core", "TimingVariance"}, 40}; const ConfigInfo<int> MAIN_TIMING_VARIANCE{{System::Main, "Core", "TimingVariance"}, 40};

View File

@ -8,12 +8,17 @@
#include "Common/Config/Config.h" #include "Common/Config/Config.h"
namespace PowerPC
{
enum class CPUCore;
}
namespace Config namespace Config
{ {
// Main.Core // Main.Core
extern const ConfigInfo<bool> MAIN_SKIP_IPL; extern const ConfigInfo<bool> MAIN_SKIP_IPL;
extern const ConfigInfo<int> MAIN_CPU_CORE; extern const ConfigInfo<PowerPC::CPUCore> MAIN_CPU_CORE;
extern const ConfigInfo<bool> MAIN_FASTMEM; extern const ConfigInfo<bool> MAIN_FASTMEM;
// Should really be in the DSP section, but we're kind of stuck with bad decisions made in the past. // Should really be in the DSP section, but we're kind of stuck with bad decisions made in the past.
extern const ConfigInfo<bool> MAIN_DSP_HLE; extern const ConfigInfo<bool> MAIN_DSP_HLE;

View File

@ -8,10 +8,8 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Config/Config.h" #include "Common/Config/Config.h"
#include "Common/FileUtil.h"
#include "Core/Config/GraphicsSettings.h" #include "Core/Config/GraphicsSettings.h"
#include "Core/Config/MainSettings.h" #include "Core/Config/MainSettings.h"
@ -20,6 +18,11 @@
#include "Core/Movie.h" #include "Core/Movie.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
namespace PowerPC
{
enum class CPUCore;
}
namespace ConfigLoaders namespace ConfigLoaders
{ {
static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm) static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm)
@ -27,7 +30,7 @@ static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm)
config_layer->Set(Config::MAIN_CPU_THREAD, dtm->bDualCore); config_layer->Set(Config::MAIN_CPU_THREAD, dtm->bDualCore);
config_layer->Set(Config::MAIN_DSP_HLE, dtm->bDSPHLE); config_layer->Set(Config::MAIN_DSP_HLE, dtm->bDSPHLE);
config_layer->Set(Config::MAIN_FAST_DISC_SPEED, dtm->bFastDiscSpeed); config_layer->Set(Config::MAIN_FAST_DISC_SPEED, dtm->bFastDiscSpeed);
config_layer->Set(Config::MAIN_CPU_CORE, static_cast<int>(dtm->CPUCore)); config_layer->Set(Config::MAIN_CPU_CORE, static_cast<PowerPC::CPUCore>(dtm->CPUCore));
config_layer->Set(Config::MAIN_SYNC_GPU, dtm->bSyncGPU); config_layer->Set(Config::MAIN_SYNC_GPU, dtm->bSyncGPU);
config_layer->Set(Config::MAIN_GFX_BACKEND, dtm->videoBackend.data()); config_layer->Set(Config::MAIN_GFX_BACKEND, dtm->videoBackend.data());
@ -50,7 +53,7 @@ void SaveToDTM(Movie::DTMHeader* dtm)
dtm->bDualCore = Config::Get(Config::MAIN_CPU_THREAD); dtm->bDualCore = Config::Get(Config::MAIN_CPU_THREAD);
dtm->bDSPHLE = Config::Get(Config::MAIN_DSP_HLE); dtm->bDSPHLE = Config::Get(Config::MAIN_DSP_HLE);
dtm->bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED); dtm->bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED);
dtm->CPUCore = Config::Get(Config::MAIN_CPU_CORE); dtm->CPUCore = static_cast<u8>(Config::Get(Config::MAIN_CPU_CORE));
dtm->bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU); dtm->bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU);
const std::string video_backend = Config::Get(Config::MAIN_GFX_BACKEND); const std::string video_backend = Config::Get(Config::MAIN_GFX_BACKEND);

View File

@ -218,7 +218,7 @@ void SConfig::SaveCoreSettings(IniFile& ini)
core->Set("SkipIPL", bHLE_BS2); core->Set("SkipIPL", bHLE_BS2);
core->Set("TimingVariance", iTimingVariance); core->Set("TimingVariance", iTimingVariance);
core->Set("CPUCore", iCPUCore); core->Set("CPUCore", cpu_core);
core->Set("Fastmem", bFastmem); core->Set("Fastmem", bFastmem);
core->Set("CPUThread", bCPUThread); core->Set("CPUThread", bCPUThread);
core->Set("DSPHLE", bDSPHLE); core->Set("DSPHLE", bDSPHLE);
@ -505,11 +505,11 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("SkipIPL", &bHLE_BS2, true); core->Get("SkipIPL", &bHLE_BS2, true);
#ifdef _M_X86 #ifdef _M_X86
core->Get("CPUCore", &iCPUCore, PowerPC::CORE_JIT64); core->Get("CPUCore", &cpu_core, PowerPC::CPUCore::JIT64);
#elif _M_ARM_64 #elif _M_ARM_64
core->Get("CPUCore", &iCPUCore, PowerPC::CORE_JITARM64); core->Get("CPUCore", &cpu_core, PowerPC::CPUCore::JITARM64);
#else #else
core->Get("CPUCore", &iCPUCore, PowerPC::CORE_INTERPRETER); core->Get("CPUCore", &cpu_core, PowerPC::CPUCore::Interpreter);
#endif #endif
core->Get("Fastmem", &bFastmem, true); core->Get("Fastmem", &bFastmem, true);
core->Get("DSPHLE", &bDSPHLE, true); core->Get("DSPHLE", &bDSPHLE, true);
@ -763,7 +763,7 @@ void SConfig::LoadDefaults()
#endif #endif
#endif #endif
iCPUCore = PowerPC::DefaultCPUCore(); cpu_core = PowerPC::DefaultCPUCore();
iTimingVariance = 40; iTimingVariance = 40;
bCPUThread = false; bCPUThread = false;
bSyncGPUOnSkipIdleHack = true; bSyncGPUOnSkipIdleHack = true;

View File

@ -23,6 +23,7 @@ enum class Region;
struct Partition; struct Partition;
class Volume; class Volume;
} // namespace DiscIO } // namespace DiscIO
namespace IOS namespace IOS
{ {
namespace ES namespace ES
@ -31,6 +32,11 @@ class TMDReader;
} }
} // namespace IOS } // namespace IOS
namespace PowerPC
{
enum class CPUCore;
} // namespace PowerPC
// DSP Backend Types // DSP Backend Types
#define BACKEND_NULLSOUND _trans("No Audio Output") #define BACKEND_NULLSOUND _trans("No Audio Output")
#define BACKEND_ALSA "ALSA" #define BACKEND_ALSA "ALSA"
@ -75,7 +81,7 @@ struct SConfig
bool bAutomaticStart = false; bool bAutomaticStart = false;
bool bBootToPause = false; bool bBootToPause = false;
int iCPUCore; // Uses the values of PowerPC::CPUCore PowerPC::CPUCore cpu_core;
bool bJITNoBlockCache = false; bool bJITNoBlockCache = false;
bool bJITNoBlockLinking = false; bool bJITNoBlockLinking = false;

View File

@ -530,7 +530,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot)
Fifo::Prepare(); Fifo::Prepare();
// Setup our core, but can't use dynarec if we are compare server // Setup our core, but can't use dynarec if we are compare server
if (core_parameter.iCPUCore != PowerPC::CORE_INTERPRETER && if (core_parameter.cpu_core != PowerPC::CPUCore::Interpreter &&
(!core_parameter.bRunCompareServer || core_parameter.bRunCompareClient)) (!core_parameter.bRunCompareServer || core_parameter.bRunCompareClient))
{ {
PowerPC::SetMode(PowerPC::CoreMode::JIT); PowerPC::SetMode(PowerPC::CoreMode::JIT);

View File

@ -45,7 +45,7 @@ static bool s_state_system_request_stepping = false;
static bool s_state_cpu_step_instruction = false; static bool s_state_cpu_step_instruction = false;
static Common::Event* s_state_cpu_step_instruction_sync = nullptr; static Common::Event* s_state_cpu_step_instruction_sync = nullptr;
void Init(int cpu_core) void Init(PowerPC::CPUCore cpu_core)
{ {
PowerPC::Init(cpu_core); PowerPC::Init(cpu_core);
s_state = State::Stepping; s_state = State::Stepping;

View File

@ -9,6 +9,11 @@ namespace Common
class Event; class Event;
} }
namespace PowerPC
{
enum class CPUCore;
}
namespace CPU namespace CPU
{ {
enum class State enum class State
@ -19,7 +24,7 @@ enum class State
}; };
// Init // Init
void Init(int cpu_core); void Init(PowerPC::CPUCore cpu_core);
// Shutdown // Shutdown
void Shutdown(); void Shutdown();

View File

@ -45,7 +45,7 @@ void Init()
DSP::Init(SConfig::GetInstance().bDSPHLE); DSP::Init(SConfig::GetInstance().bDSPHLE);
DVDInterface::Init(); DVDInterface::Init();
GPFifo::Init(); GPFifo::Init();
CPU::Init(SConfig::GetInstance().iCPUCore); CPU::Init(SConfig::GetInstance().cpu_core);
SystemTimers::Init(); SystemTimers::Init();
if (SConfig::GetInstance().bWii) if (SConfig::GetInstance().bWii)

View File

@ -12,6 +12,7 @@
#include <mutex> #include <mutex>
#include <sstream> #include <sstream>
#include <thread> #include <thread>
#include <type_traits>
#include <mbedtls/md5.h> #include <mbedtls/md5.h>
@ -35,6 +36,7 @@
#include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Core/IOS/USB/Bluetooth/BTEmu.h" #include "Core/IOS/USB/Bluetooth/BTEmu.h"
#include "Core/Movie.h" #include "Core/Movie.h"
#include "Core/PowerPC/PowerPC.h"
#include "InputCommon/GCAdapter.h" #include "InputCommon/GCAdapter.h"
#include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
@ -412,7 +414,15 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
std::lock_guard<std::recursive_mutex> lkg(m_crit.game); std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
packet >> m_current_game; packet >> m_current_game;
packet >> g_NetPlaySettings.m_CPUthread; packet >> g_NetPlaySettings.m_CPUthread;
packet >> g_NetPlaySettings.m_CPUcore;
{
std::underlying_type_t<PowerPC::CPUCore> core;
if (packet >> core)
g_NetPlaySettings.m_CPUcore = static_cast<PowerPC::CPUCore>(core);
else
g_NetPlaySettings.m_CPUcore = PowerPC::CPUCore::CachedInterpreter;
}
packet >> g_NetPlaySettings.m_EnableCheats; packet >> g_NetPlaySettings.m_EnableCheats;
packet >> g_NetPlaySettings.m_SelectedLanguage; packet >> g_NetPlaySettings.m_SelectedLanguage;
packet >> g_NetPlaySettings.m_OverrideGCLanguage; packet >> g_NetPlaySettings.m_OverrideGCLanguage;

View File

@ -9,10 +9,15 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Core/HW/EXI/EXI_Device.h" #include "Core/HW/EXI/EXI_Device.h"
namespace PowerPC
{
enum class CPUCore;
}
struct NetSettings struct NetSettings
{ {
bool m_CPUthread; bool m_CPUthread;
int m_CPUcore; PowerPC::CPUCore m_CPUcore;
bool m_EnableCheats; bool m_EnableCheats;
int m_SelectedLanguage; int m_SelectedLanguage;
bool m_OverrideGCLanguage; bool m_OverrideGCLanguage;

View File

@ -11,6 +11,7 @@
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <thread> #include <thread>
#include <type_traits>
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
@ -815,10 +816,10 @@ bool NetPlayServer::StartGame()
// tell clients to start game // tell clients to start game
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_START_GAME; spac << static_cast<MessageId>(NP_MSG_START_GAME);
spac << m_current_game; spac << m_current_game;
spac << m_settings.m_CPUthread; spac << m_settings.m_CPUthread;
spac << m_settings.m_CPUcore; spac << static_cast<std::underlying_type_t<PowerPC::CPUCore>>(m_settings.m_CPUcore);
spac << m_settings.m_EnableCheats; spac << m_settings.m_EnableCheats;
spac << m_settings.m_SelectedLanguage; spac << m_settings.m_SelectedLanguage;
spac << m_settings.m_OverrideGCLanguage; spac << m_settings.m_OverrideGCLanguage;
@ -832,8 +833,8 @@ bool NetPlayServer::StartGame()
spac << m_settings.m_OCFactor; spac << m_settings.m_OCFactor;
spac << m_settings.m_EXIDevice[0]; spac << m_settings.m_EXIDevice[0];
spac << m_settings.m_EXIDevice[1]; spac << m_settings.m_EXIDevice[1];
spac << (u32)g_netplay_initial_rtc; spac << static_cast<u32>(g_netplay_initial_rtc);
spac << (u32)(g_netplay_initial_rtc >> 32); spac << static_cast<u32>(g_netplay_initial_rtc >> 32);
SendAsyncToClients(std::move(spac)); SendAsyncToClients(std::move(spac));

View File

@ -45,28 +45,28 @@ void DoState(PointerWrap& p)
if (g_jit && p.GetMode() == PointerWrap::MODE_READ) if (g_jit && p.GetMode() == PointerWrap::MODE_READ)
g_jit->ClearCache(); g_jit->ClearCache();
} }
CPUCoreBase* InitJitCore(int core) CPUCoreBase* InitJitCore(PowerPC::CPUCore core)
{ {
switch (core) switch (core)
{ {
#if _M_X86 #if _M_X86
case PowerPC::CORE_JIT64: case PowerPC::CPUCore::JIT64:
g_jit = new Jit64(); g_jit = new Jit64();
break; break;
#endif #endif
#if _M_ARM_64 #if _M_ARM_64
case PowerPC::CORE_JITARM64: case PowerPC::CPUCore::JITARM64:
g_jit = new JitArm64(); g_jit = new JitArm64();
break; break;
#endif #endif
case PowerPC::CORE_CACHEDINTERPRETER: case PowerPC::CPUCore::CachedInterpreter:
g_jit = new CachedInterpreter(); g_jit = new CachedInterpreter();
break; break;
default: default:
PanicAlertT("The selected CPU emulation core (%d) is not available. " PanicAlertT("The selected CPU emulation core (%d) is not available. "
"Please select a different CPU emulation core in the settings.", "Please select a different CPU emulation core in the settings.",
core); static_cast<int>(core));
g_jit = nullptr; g_jit = nullptr;
return nullptr; return nullptr;
} }

View File

@ -12,6 +12,11 @@
class CPUCoreBase; class CPUCoreBase;
class PointerWrap; class PointerWrap;
namespace PowerPC
{
enum class CPUCore;
}
namespace Profiler namespace Profiler
{ {
struct ProfileStats; struct ProfileStats;
@ -28,7 +33,7 @@ enum class ExceptionType
void DoState(PointerWrap& p); void DoState(PointerWrap& p);
CPUCoreBase* InitJitCore(int core); CPUCoreBase* InitJitCore(PowerPC::CPUCore core);
CPUCoreBase* GetCore(); CPUCoreBase* GetCore();
// Debugging // Debugging

View File

@ -5,6 +5,9 @@
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
#include <cstring> #include <cstring>
#include <istream>
#include <ostream>
#include <type_traits>
#include <vector> #include <vector>
#include "Common/Assert.h" #include "Common/Assert.h"
@ -44,6 +47,30 @@ static void InvalidateCacheThreadSafe(u64 userdata, s64 cyclesLate)
ppcState.iCache.Invalidate(static_cast<u32>(userdata)); ppcState.iCache.Invalidate(static_cast<u32>(userdata));
} }
std::istream& operator>>(std::istream& is, CPUCore& core)
{
std::underlying_type_t<CPUCore> val{};
if (is >> val)
{
core = static_cast<CPUCore>(val);
}
else
{
// Upon failure, fall back to the cached interpreter
// to ensure we always initialize our core reference.
core = CPUCore::CachedInterpreter;
}
return is;
}
std::ostream& operator<<(std::ostream& os, CPUCore core)
{
os << static_cast<std::underlying_type_t<CPUCore>>(core);
return os;
}
u32 CompactCR() u32 CompactCR()
{ {
u32 new_cr = 0; u32 new_cr = 0;
@ -148,7 +175,7 @@ static void ResetRegisters()
SystemTimers::DecrementerSet(); SystemTimers::DecrementerSet();
} }
static void InitializeCPUCore(int cpu_core) static void InitializeCPUCore(CPUCore cpu_core)
{ {
// We initialize the interpreter because // We initialize the interpreter because
// it is used on boot and code window independently. // it is used on boot and code window independently.
@ -156,7 +183,7 @@ static void InitializeCPUCore(int cpu_core)
switch (cpu_core) switch (cpu_core)
{ {
case PowerPC::CORE_INTERPRETER: case CPUCore::Interpreter:
s_cpu_core_base = s_interpreter; s_cpu_core_base = s_interpreter;
break; break;
@ -176,12 +203,12 @@ static void InitializeCPUCore(int cpu_core)
const std::vector<CPUCore>& AvailableCPUCores() const std::vector<CPUCore>& AvailableCPUCores()
{ {
static const std::vector<CPUCore> cpu_cores = { static const std::vector<CPUCore> cpu_cores = {
CORE_INTERPRETER, CPUCore::Interpreter,
CORE_CACHEDINTERPRETER, CPUCore::CachedInterpreter,
#ifdef _M_X86_64 #ifdef _M_X86_64
CORE_JIT64, CPUCore::JIT64,
#elif defined(_M_ARM_64) #elif defined(_M_ARM_64)
CORE_JITARM64, CPUCore::JITARM64,
#endif #endif
}; };
@ -191,15 +218,15 @@ const std::vector<CPUCore>& AvailableCPUCores()
CPUCore DefaultCPUCore() CPUCore DefaultCPUCore()
{ {
#ifdef _M_X86_64 #ifdef _M_X86_64
return CORE_JIT64; return CPUCore::JIT64;
#elif defined(_M_ARM_64) #elif defined(_M_ARM_64)
return CORE_JITARM64; return CPUCore::JITARM64;
#else #else
return CORE_CACHEDINTERPRETER; return CPUCore::CachedInterpreter;
#endif #endif
} }
void Init(int cpu_core) void Init(CPUCore cpu_core)
{ {
// NOTE: This function runs on EmuThread, not the CPU Thread. // NOTE: This function runs on EmuThread, not the CPU Thread.
// Changing the rounding mode has a limited effect. // Changing the rounding mode has a limited effect.

View File

@ -6,6 +6,7 @@
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <iosfwd>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
@ -23,14 +24,18 @@ namespace PowerPC
{ {
// The gaps in the CPUCore numbering are from cores that only existed in the past. // The gaps in the CPUCore numbering are from cores that only existed in the past.
// We avoid re-numbering cores so that settings will be compatible across versions. // We avoid re-numbering cores so that settings will be compatible across versions.
enum CPUCore enum class CPUCore
{ {
CORE_INTERPRETER = 0, Interpreter = 0,
CORE_JIT64 = 1, JIT64 = 1,
CORE_JITARM64 = 4, JITARM64 = 4,
CORE_CACHEDINTERPRETER = 5, CachedInterpreter = 5,
}; };
// For reading from and writing to our config.
std::istream& operator>>(std::istream& is, CPUCore& core);
std::ostream& operator<<(std::ostream& os, CPUCore core);
enum class CoreMode enum class CoreMode
{ {
Interpreter, Interpreter,
@ -142,7 +147,7 @@ extern PPCDebugInterface debug_interface;
const std::vector<CPUCore>& AvailableCPUCores(); const std::vector<CPUCore>& AvailableCPUCores();
CPUCore DefaultCPUCore(); CPUCore DefaultCPUCore();
void Init(int cpu_core); void Init(CPUCore cpu_core);
void Reset(); void Reset();
void Shutdown(); void Shutdown();
void DoState(PointerWrap& p); void DoState(PointerWrap& p);

View File

@ -725,7 +725,8 @@ void MenuBar::AddJITMenu()
m_jit_interpreter_core = m_jit->addAction(tr("Interpreter Core")); m_jit_interpreter_core = m_jit->addAction(tr("Interpreter Core"));
m_jit_interpreter_core->setCheckable(true); m_jit_interpreter_core->setCheckable(true);
m_jit_interpreter_core->setChecked(SConfig::GetInstance().iCPUCore == PowerPC::CORE_INTERPRETER); m_jit_interpreter_core->setChecked(SConfig::GetInstance().cpu_core ==
PowerPC::CPUCore::Interpreter);
connect(m_jit_interpreter_core, &QAction::toggled, [](bool enabled) { connect(m_jit_interpreter_core, &QAction::toggled, [](bool enabled) {
PowerPC::SetMode(enabled ? PowerPC::CoreMode::Interpreter : PowerPC::CoreMode::JIT); PowerPC::SetMode(enabled ? PowerPC::CoreMode::Interpreter : PowerPC::CoreMode::JIT);

View File

@ -278,7 +278,7 @@ void NetPlayDialog::OnStart()
// Copy all relevant settings // Copy all relevant settings
SConfig& instance = SConfig::GetInstance(); SConfig& instance = SConfig::GetInstance();
settings.m_CPUthread = instance.bCPUThread; settings.m_CPUthread = instance.bCPUThread;
settings.m_CPUcore = instance.iCPUCore; settings.m_CPUcore = instance.cpu_core;
settings.m_EnableCheats = instance.bEnableCheats; settings.m_EnableCheats = instance.bEnableCheats;
settings.m_SelectedLanguage = instance.SelectedLanguage; settings.m_SelectedLanguage = instance.SelectedLanguage;
settings.m_OverrideGCLanguage = instance.bOverrideGCLanguage; settings.m_OverrideGCLanguage = instance.bOverrideGCLanguage;

View File

@ -38,10 +38,10 @@ constexpr const char* AUTO_UPDATE_BETA_STRING = "beta";
constexpr const char* AUTO_UPDATE_DEV_STRING = "dev"; constexpr const char* AUTO_UPDATE_DEV_STRING = "dev";
static const std::map<PowerPC::CPUCore, const char*> CPU_CORE_NAMES = { static const std::map<PowerPC::CPUCore, const char*> CPU_CORE_NAMES = {
{PowerPC::CORE_INTERPRETER, QT_TR_NOOP("Interpreter (slowest)")}, {PowerPC::CPUCore::Interpreter, QT_TR_NOOP("Interpreter (slowest)")},
{PowerPC::CORE_CACHEDINTERPRETER, QT_TR_NOOP("Cached Interpreter (slower)")}, {PowerPC::CPUCore::CachedInterpreter, QT_TR_NOOP("Cached Interpreter (slower)")},
{PowerPC::CORE_JIT64, QT_TR_NOOP("JIT Recompiler (recommended)")}, {PowerPC::CPUCore::JIT64, QT_TR_NOOP("JIT Recompiler (recommended)")},
{PowerPC::CORE_JITARM64, QT_TR_NOOP("JIT Arm64 (experimental)")}, {PowerPC::CPUCore::JITARM64, QT_TR_NOOP("JIT Arm64 (experimental)")},
}; };
GeneralPane::GeneralPane(QWidget* parent) : QWidget(parent) GeneralPane::GeneralPane(QWidget* parent) : QWidget(parent)
@ -227,7 +227,7 @@ void GeneralPane::LoadConfig()
const std::vector<PowerPC::CPUCore>& available_cpu_cores = PowerPC::AvailableCPUCores(); const std::vector<PowerPC::CPUCore>& available_cpu_cores = PowerPC::AvailableCPUCores();
for (size_t i = 0; i < available_cpu_cores.size(); ++i) for (size_t i = 0; i < available_cpu_cores.size(); ++i)
{ {
if (available_cpu_cores[i] == SConfig::GetInstance().iCPUCore) if (available_cpu_cores[i] == SConfig::GetInstance().cpu_core)
m_cpu_cores[i]->setChecked(true); m_cpu_cores[i]->setChecked(true);
} }
} }
@ -275,7 +275,7 @@ void GeneralPane::OnSaveConfig()
{ {
if (m_cpu_cores[i]->isChecked()) if (m_cpu_cores[i]->isChecked())
{ {
settings.iCPUCore = PowerPC::AvailableCPUCores()[i]; settings.cpu_core = PowerPC::AvailableCPUCores()[i];
break; break;
} }
} }

View File

@ -26,10 +26,10 @@
#include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxEventUtils.h"
static const std::map<PowerPC::CPUCore, std::string> CPU_CORE_NAMES = { static const std::map<PowerPC::CPUCore, std::string> CPU_CORE_NAMES = {
{PowerPC::CORE_INTERPRETER, _trans("Interpreter (slowest)")}, {PowerPC::CPUCore::Interpreter, _trans("Interpreter (slowest)")},
{PowerPC::CORE_CACHEDINTERPRETER, _trans("Cached Interpreter (slower)")}, {PowerPC::CPUCore::CachedInterpreter, _trans("Cached Interpreter (slower)")},
{PowerPC::CORE_JIT64, _trans("JIT Recompiler (recommended)")}, {PowerPC::CPUCore::JIT64, _trans("JIT Recompiler (recommended)")},
{PowerPC::CORE_JITARM64, _trans("JIT Arm64 (experimental)")}, {PowerPC::CPUCore::JITARM64, _trans("JIT Arm64 (experimental)")},
}; };
GeneralConfigPane::GeneralConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id) GeneralConfigPane::GeneralConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id)
@ -156,7 +156,7 @@ void GeneralConfigPane::LoadGUIValues()
const std::vector<PowerPC::CPUCore>& cpu_cores = PowerPC::AvailableCPUCores(); const std::vector<PowerPC::CPUCore>& cpu_cores = PowerPC::AvailableCPUCores();
for (size_t i = 0; i < cpu_cores.size(); ++i) for (size_t i = 0; i < cpu_cores.size(); ++i)
{ {
if (cpu_cores[i] == startup_params.iCPUCore) if (cpu_cores[i] == startup_params.cpu_core)
m_cpu_engine_radiobox->SetSelection(i); m_cpu_engine_radiobox->SetSelection(i);
} }
} }
@ -202,7 +202,7 @@ void GeneralConfigPane::OnThrottlerChoiceChanged(wxCommandEvent& event)
void GeneralConfigPane::OnCPUEngineRadioBoxChanged(wxCommandEvent& event) void GeneralConfigPane::OnCPUEngineRadioBoxChanged(wxCommandEvent& event)
{ {
SConfig::GetInstance().iCPUCore = PowerPC::AvailableCPUCores()[event.GetSelection()]; SConfig::GetInstance().cpu_core = PowerPC::AvailableCPUCores()[event.GetSelection()];
} }
void GeneralConfigPane::OnAnalyticsCheckBoxChanged(wxCommandEvent& event) void GeneralConfigPane::OnAnalyticsCheckBoxChanged(wxCommandEvent& event)

View File

@ -1137,7 +1137,7 @@ void CFrame::OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event)
if (GetMenuBar()->FindItem(IDM_INTERPRETER)->IsChecked()) if (GetMenuBar()->FindItem(IDM_INTERPRETER)->IsChecked())
return; return;
event.Check(SConfig::GetInstance().iCPUCore == PowerPC::CORE_INTERPRETER); event.Check(SConfig::GetInstance().cpu_core == PowerPC::CPUCore::Interpreter);
} }
void CFrame::ClearStatusBar() void CFrame::ClearStatusBar()

View File

@ -371,7 +371,7 @@ wxMenu* MainMenuBar::CreateJITMenu() const
_("This is necessary to get break points" _("This is necessary to get break points"
" and stepping to work as explained in the Developer Documentation. But it can be very" " and stepping to work as explained in the Developer Documentation. But it can be very"
" slow, perhaps slower than 1 fps.")); " slow, perhaps slower than 1 fps."));
interpreter->Check(config_instance.iCPUCore == PowerPC::CORE_INTERPRETER); interpreter->Check(config_instance.cpu_core == PowerPC::CPUCore::Interpreter);
jit_menu->AppendSeparator(); jit_menu->AppendSeparator();
jit_menu->AppendCheckItem(IDM_JIT_NO_BLOCK_LINKING, _("&JIT Block Linking Off"), jit_menu->AppendCheckItem(IDM_JIT_NO_BLOCK_LINKING, _("&JIT Block Linking Off"),

View File

@ -315,7 +315,7 @@ void NetPlayDialog::GetNetSettings(NetSettings& settings)
{ {
SConfig& instance = SConfig::GetInstance(); SConfig& instance = SConfig::GetInstance();
settings.m_CPUthread = instance.bCPUThread; settings.m_CPUthread = instance.bCPUThread;
settings.m_CPUcore = instance.iCPUCore; settings.m_CPUcore = instance.cpu_core;
settings.m_EnableCheats = instance.bEnableCheats; settings.m_EnableCheats = instance.bEnableCheats;
settings.m_SelectedLanguage = instance.SelectedLanguage; settings.m_SelectedLanguage = instance.SelectedLanguage;
settings.m_OverrideGCLanguage = instance.bOverrideGCLanguage; settings.m_OverrideGCLanguage = instance.bOverrideGCLanguage;

View File

@ -43,7 +43,7 @@ public:
UICommon::SetUserDirectory(m_profile_path); UICommon::SetUserDirectory(m_profile_path);
Config::Init(); Config::Init();
SConfig::Init(); SConfig::Init();
PowerPC::Init(PowerPC::CORE_INTERPRETER); PowerPC::Init(PowerPC::CPUCore::Interpreter);
CoreTiming::Init(); CoreTiming::Init();
} }
~ScopeInit() ~ScopeInit()