Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10356 from AdmiralCurtiss/config-port-core-4
Config: Port remaining Core settings to new config system (the rest).
  • Loading branch information
JMC47 committed Jan 11, 2022
2 parents d32b13f + c82b2dc commit c18abfa
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 157 deletions.
37 changes: 3 additions & 34 deletions Source/Core/Core/BootManager.cpp
Expand Up @@ -44,6 +44,7 @@
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "Core/WiiRoot.h"

#include "DiscIO/Enums.h"
Expand All @@ -69,26 +70,13 @@ struct ConfigCache

private:
bool valid = false;
bool bCPUThread = false;
bool bMMU = false;
bool bSyncGPU = false;
int iSyncGpuMaxDistance = 0;
int iSyncGpuMinDistance = 0;
float fSyncGpuOverclock = 0;
std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource{};
};

void ConfigCache::SaveConfig(const SConfig& config)
{
valid = true;

bCPUThread = config.bCPUThread;
bMMU = config.bMMU;
bSyncGPU = config.bSyncGPU;
iSyncGpuMaxDistance = config.iSyncGpuMaxDistance;
iSyncGpuMinDistance = config.iSyncGpuMinDistance;
fSyncGpuOverclock = config.fSyncGpuOverclock;

for (int i = 0; i != MAX_BBMOTES; ++i)
iWiimoteSource[i] = WiimoteCommon::GetSource(i);

Expand All @@ -103,13 +91,6 @@ void ConfigCache::RestoreConfig(SConfig* config)

valid = false;

config->bCPUThread = bCPUThread;
config->bMMU = bMMU;
config->bSyncGPU = bSyncGPU;
config->iSyncGpuMaxDistance = iSyncGpuMaxDistance;
config->iSyncGpuMinDistance = iSyncGpuMinDistance;
config->fSyncGpuOverclock = fSyncGpuOverclock;

// Only change these back if they were actually set by game ini, since they can be changed while a
// game is running.
if (config->bWii)
Expand Down Expand Up @@ -143,13 +124,8 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
IniFile game_ini = StartUp.LoadGameIni();

// General settings
IniFile::Section* core_section = game_ini.GetOrCreateSection("Core");
IniFile::Section* controls_section = game_ini.GetOrCreateSection("Controls");

core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread);
core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU);
core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU);

// Wii settings
if (StartUp.bWii)
{
Expand Down Expand Up @@ -180,9 +156,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
// Movie settings
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
{
// TODO: remove this once ConfigManager starts using OnionConfig.
StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD);
StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU);
for (int i = 0; i < 2; ++i)
{
if (Movie::IsUsingMemcard(i) && Movie::IsStartingFromClearSave() && !StartUp.bWii)
Expand All @@ -203,13 +176,7 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
{
const NetPlay::NetSettings& netplay_settings = NetPlay::GetNetSettings();
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings));
StartUp.bCPUThread = netplay_settings.m_CPUthread;
StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave;
StartUp.bSyncGPU = netplay_settings.m_SyncGPU;
StartUp.iSyncGpuMaxDistance = netplay_settings.m_SyncGpuMaxDistance;
StartUp.iSyncGpuMinDistance = netplay_settings.m_SyncGpuMinDistance;
StartUp.fSyncGpuOverclock = netplay_settings.m_SyncGpuOverclock;
StartUp.bMMU = netplay_settings.m_MMU;
}
else
{
Expand Down Expand Up @@ -263,6 +230,8 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
if (!boot->riivolution_patches.empty())
Config::SetCurrent(Config::MAIN_FAST_DISC_SPEED, true);

Core::System::GetInstance().Initialize();

Core::UpdateWantDeterminism(/*initial*/ true);

if (StartUp.bWii)
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
Expand Up @@ -117,6 +117,13 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::GetInfoForSIDevice(1).GetLocation(),
&Config::GetInfoForSIDevice(2).GetLocation(),
&Config::GetInfoForSIDevice(3).GetLocation(),
&Config::MAIN_CPU_THREAD.GetLocation(),
&Config::MAIN_MMU.GetLocation(),
&Config::MAIN_BB_DUMP_PORT.GetLocation(),
&Config::MAIN_SYNC_GPU.GetLocation(),
&Config::MAIN_SYNC_GPU_MAX_DISTANCE.GetLocation(),
&Config::MAIN_SYNC_GPU_MIN_DISTANCE.GetLocation(),
&Config::MAIN_SYNC_GPU_OVERCLOCK.GetLocation(),

// UI.General

Expand Down
43 changes: 1 addition & 42 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -84,50 +84,13 @@ SConfig::~SConfig()
void SConfig::SaveSettings()
{
NOTICE_LOG_FMT(BOOT, "Saving settings to {}", File::GetUserPath(F_DOLPHINCONFIG_IDX));
IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); // load first to not kill unknown stuff

SaveCoreSettings(ini);

ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));

Config::Save();
}

void SConfig::SaveCoreSettings(IniFile& ini)
{
IniFile::Section* core = ini.GetOrCreateSection("Core");

core->Set("CPUThread", bCPUThread);
core->Set("SyncGPU", bSyncGPU);
core->Set("SyncGpuMaxDistance", iSyncGpuMaxDistance);
core->Set("SyncGpuMinDistance", iSyncGpuMinDistance);
core->Set("SyncGpuOverclock", fSyncGpuOverclock);
core->Set("MMU", bMMU);
}

void SConfig::LoadSettings()
{
Config::Load();

INFO_LOG_FMT(BOOT, "Loading Settings from {}", File::GetUserPath(F_DOLPHINCONFIG_IDX));
IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));

LoadCoreSettings(ini);
}

void SConfig::LoadCoreSettings(IniFile& ini)
{
IniFile::Section* core = ini.GetOrCreateSection("Core");

core->Get("CPUThread", &bCPUThread, true);
core->Get("MMU", &bMMU, bMMU);
core->Get("BBDumpPort", &iBBDumpPort, -1);
core->Get("SyncGPU", &bSyncGPU, false);
core->Get("SyncGpuMaxDistance", &iSyncGpuMaxDistance, 200000);
core->Get("SyncGpuMinDistance", &iSyncGpuMinDistance, -200000);
core->Get("SyncGpuOverclock", &fSyncGpuOverclock, 1.0f);
Config::Load();
}

void SConfig::ResetRunningGameMetadata()
Expand Down Expand Up @@ -243,10 +206,6 @@ void SConfig::LoadDefaults()
bAutomaticStart = false;
bBootToPause = false;

bCPUThread = false;
bMMU = false;
iBBDumpPort = -1;
bSyncGPU = false;
bWii = false;

ResetRunningGameMetadata();
Expand Down
13 changes: 0 additions & 13 deletions Source/Core/Core/ConfigManager.h
Expand Up @@ -56,17 +56,8 @@ struct SConfig
bool bJITNoBlockCache = false;
bool bJITNoBlockLinking = false;

bool bCPUThread = true;
bool bCopyWiiSaveNetplay = true;

bool bMMU = false;
int iBBDumpPort = 0;

bool bSyncGPU = false;
int iSyncGpuMaxDistance;
int iSyncGpuMinDistance;
float fSyncGpuOverclock;

bool bWii = false;
bool m_is_mios = false;

Expand Down Expand Up @@ -134,10 +125,6 @@ struct SConfig
SConfig();
~SConfig();

void SaveCoreSettings(IniFile& ini);

void LoadCoreSettings(IniFile& ini);

void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id,
u64 title_id, u16 revision, DiscIO::Region region);

Expand Down
27 changes: 12 additions & 15 deletions Source/Core/Core/Core.cpp
Expand Up @@ -67,6 +67,7 @@
#include "Core/PowerPC/JitInterface.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/State.h"
#include "Core/System.h"
#include "Core/WiiRoot.h"

#ifdef USE_MEMORYWATCHER
Expand Down Expand Up @@ -202,8 +203,7 @@ bool IsCPUThread()

bool IsGPUThread()
{
const SConfig& _CoreParameter = SConfig::GetInstance();
if (_CoreParameter.bCPUThread)
if (Core::System::GetInstance().IsDualCoreMode())
{
return (s_emu_thread.joinable() && (s_emu_thread.get_id() == std::this_thread::get_id()));
}
Expand Down Expand Up @@ -238,7 +238,8 @@ bool Init(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
HostDispatchJobs();

INFO_LOG_FMT(BOOT, "Starting core = {} mode", SConfig::GetInstance().bWii ? "Wii" : "GameCube");
INFO_LOG_FMT(BOOT, "CPU Thread separate = {}", SConfig::GetInstance().bCPUThread ? "Yes" : "No");
INFO_LOG_FMT(BOOT, "CPU Thread separate = {}",
Core::System::GetInstance().IsDualCoreMode() ? "Yes" : "No");

Host_UpdateMainFrame(); // Disable any menus or buttons at boot

Expand Down Expand Up @@ -272,8 +273,6 @@ void Stop() // - Hammertime!
if (GetState() == State::Stopping || GetState() == State::Uninitialized)
return;

const SConfig& _CoreParameter = SConfig::GetInstance();

s_is_stopping = true;

s_timer.Stop();
Expand All @@ -291,7 +290,7 @@ void Stop() // - Hammertime!
INFO_LOG_FMT(CONSOLE, "{}", StopMessage(true, "Stop CPU"));
CPU::Stop();

if (_CoreParameter.bCPUThread)
if (Core::System::GetInstance().IsDualCoreMode())
{
// Video_EnterLoop() should now exit so that EmuThread()
// will continue concurrently with the rest of the commands
Expand Down Expand Up @@ -333,8 +332,7 @@ static void CpuThread(const std::optional<std::string>& savestate_path, bool del
{
DeclareAsCPUThread();

const SConfig& _CoreParameter = SConfig::GetInstance();
if (_CoreParameter.bCPUThread)
if (Core::System::GetInstance().IsDualCoreMode())
Common::SetCurrentThreadName("CPU thread");
else
Common::SetCurrentThreadName("CPU-GPU thread");
Expand Down Expand Up @@ -413,8 +411,7 @@ static void FifoPlayerThread(const std::optional<std::string>& savestate_path,
{
DeclareAsCPUThread();

const SConfig& _CoreParameter = SConfig::GetInstance();
if (_CoreParameter.bCPUThread)
if (Core::System::GetInstance().IsDualCoreMode())
Common::SetCurrentThreadName("FIFO player thread");
else
Common::SetCurrentThreadName("FIFO-GPU thread");
Expand Down Expand Up @@ -446,6 +443,7 @@ static void FifoPlayerThread(const std::optional<std::string>& savestate_path,
// See the BootManager.cpp file description for a complete call schedule.
static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi)
{
const Core::System& system = Core::System::GetInstance();
const SConfig& core_parameter = SConfig::GetInstance();
CallOnStateChangedCallbacks(State::Starting);
Common::ScopeGuard flag_guard{[] {
Expand Down Expand Up @@ -647,7 +645,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
}

// ENTER THE VIDEO THREAD LOOP
if (core_parameter.bCPUThread)
if (system.IsDualCoreMode())
{
// This thread, after creating the EmuWindow, spawns a CPU
// thread, and then takes over and becomes the video thread
Expand Down Expand Up @@ -930,8 +928,6 @@ void Callback_NewField()

void UpdateTitle(u32 ElapseTime)
{
SConfig& _CoreParameter = SConfig::GetInstance();

if (ElapseTime == 0)
ElapseTime = 1;

Expand All @@ -942,8 +938,9 @@ void UpdateTitle(u32 ElapseTime)

// Settings are shown the same for both extended and summary info
const std::string SSettings = fmt::format(
"{} {} | {} | {}", PowerPC::GetCPUName(), _CoreParameter.bCPUThread ? "DC" : "SC",
g_video_backend->GetDisplayName(), Config::Get(Config::MAIN_DSP_HLE) ? "HLE" : "LLE");
"{} {} | {} | {}", PowerPC::GetCPUName(),
Core::System::GetInstance().IsDualCoreMode() ? "DC" : "SC", g_video_backend->GetDisplayName(),
Config::Get(Config::MAIN_DSP_HLE) ? "HLE" : "LLE");

std::string SFPS;
if (Movie::IsPlayingInput())
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/DolphinAnalytics.cpp
Expand Up @@ -359,9 +359,9 @@ void DolphinAnalytics::MakePerGameBuilder()
builder.AddData("cfg-dsp-hle", Config::Get(Config::MAIN_DSP_HLE));
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-cpu-thread", Config::Get(Config::MAIN_CPU_THREAD));
builder.AddData("cfg-fastmem", Config::Get(Config::MAIN_FASTMEM));
builder.AddData("cfg-syncgpu", SConfig::GetInstance().bSyncGPU);
builder.AddData("cfg-syncgpu", Config::Get(Config::MAIN_SYNC_GPU));
builder.AddData("cfg-audio-backend", Config::Get(Config::MAIN_AUDIO_BACKEND));
builder.AddData("cfg-oc-enable", Config::Get(Config::MAIN_OVERCLOCK_ENABLE));
builder.AddData("cfg-oc-factor", Config::Get(Config::MAIN_OVERCLOCK));
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/Memmap.cpp
Expand Up @@ -33,6 +33,7 @@
#include "Core/HW/WII_IPC.h"
#include "Core/PowerPC/JitCommon/JitBase.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/PixelEngine.h"

Expand Down Expand Up @@ -260,7 +261,7 @@ void Init()
false};

const bool wii = SConfig::GetInstance().bWii;
const bool mmu = SConfig::GetInstance().bMMU;
const bool mmu = Core::System::GetInstance().IsMMUMode();

bool fake_vmem = false;
#ifndef _ARCH_32
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
Expand Up @@ -303,11 +303,11 @@ void Wiimote::Read()

if (result > 0)
{
if (SConfig::GetInstance().iBBDumpPort > 0 && m_index == WIIMOTE_BALANCE_BOARD)
if (m_balance_board_dump_port > 0 && m_index == WIIMOTE_BALANCE_BOARD)
{
static sf::UdpSocket Socket;
Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost,
SConfig::GetInstance().iBBDumpPort);
m_balance_board_dump_port);
}

// Add it to queue
Expand All @@ -324,11 +324,10 @@ bool Wiimote::Write()

Report const& rpt = m_write_reports.Front();

if (SConfig::GetInstance().iBBDumpPort > 0 && m_index == WIIMOTE_BALANCE_BOARD)
if (m_balance_board_dump_port > 0 && m_index == WIIMOTE_BALANCE_BOARD)
{
static sf::UdpSocket Socket;
Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost,
SConfig::GetInstance().iBBDumpPort);
Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost, m_balance_board_dump_port);
}
int ret = IOWrite(rpt.data(), rpt.size());

Expand Down Expand Up @@ -816,6 +815,7 @@ void Wiimote::ThreadFunc()
void Wiimote::RefreshConfig()
{
m_speaker_enabled_in_dolphin_config = Config::Get(Config::MAIN_WIIMOTE_ENABLE_SPEAKER);
m_balance_board_dump_port = Config::Get(Config::MAIN_BB_DUMP_PORT);
}

int Wiimote::GetIndex() const
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
Expand Up @@ -148,6 +148,7 @@ class Wiimote : public WiimoteCommon::HIDWiimote
Common::SPSCQueue<Report> m_write_reports;

bool m_speaker_enabled_in_dolphin_config = false;
int m_balance_board_dump_port = 0;

size_t m_config_changed_callback_id;
};
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/JitArm64/Jit.cpp
Expand Up @@ -48,7 +48,7 @@ JitArm64::~JitArm64() = default;

void JitArm64::Init()
{
const size_t child_code_size = SConfig::GetInstance().bMMU ? FARCODE_SIZE_MMU : FARCODE_SIZE;
const size_t child_code_size = m_mmu_enabled ? FARCODE_SIZE_MMU : FARCODE_SIZE;
AllocCodeSpace(CODE_SIZE + child_code_size);
AddChildCodeSpace(&m_far_code, child_code_size);

Expand Down

0 comments on commit c18abfa

Please sign in to comment.