Config: Port SyncGPU settings to new config system.
This commit is contained in:
parent
d8b67bc15f
commit
c82b2dccb5
|
@ -70,10 +70,6 @@ public:
|
|||
|
||||
private:
|
||||
bool valid = false;
|
||||
bool bSyncGPU = false;
|
||||
int iSyncGpuMaxDistance = 0;
|
||||
int iSyncGpuMinDistance = 0;
|
||||
float fSyncGpuOverclock = 0;
|
||||
std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource{};
|
||||
};
|
||||
|
||||
|
@ -81,11 +77,6 @@ void ConfigCache::SaveConfig(const SConfig& config)
|
|||
{
|
||||
valid = true;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -100,11 +91,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
|
|||
|
||||
valid = false;
|
||||
|
||||
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)
|
||||
|
@ -138,11 +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("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU);
|
||||
|
||||
// Wii settings
|
||||
if (StartUp.bWii)
|
||||
{
|
||||
|
@ -173,8 +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.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
if (Movie::IsUsingMemcard(i) && Movie::IsStartingFromClearSave() && !StartUp.bWii)
|
||||
|
@ -196,10 +177,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
|
|||
const NetPlay::NetSettings& netplay_settings = NetPlay::GetNetSettings();
|
||||
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings));
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -120,6 +120,10 @@ bool IsSettingSaveable(const Config::Location& config_location)
|
|||
&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
|
||||
|
||||
|
|
|
@ -85,45 +85,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("SyncGPU", bSyncGPU);
|
||||
core->Set("SyncGpuMaxDistance", iSyncGpuMaxDistance);
|
||||
core->Set("SyncGpuMinDistance", iSyncGpuMinDistance);
|
||||
core->Set("SyncGpuOverclock", fSyncGpuOverclock);
|
||||
}
|
||||
|
||||
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("SyncGPU", &bSyncGPU, false);
|
||||
core->Get("SyncGpuMaxDistance", &iSyncGpuMaxDistance, 200000);
|
||||
core->Get("SyncGpuMinDistance", &iSyncGpuMinDistance, -200000);
|
||||
core->Get("SyncGpuOverclock", &fSyncGpuOverclock, 1.0f);
|
||||
Config::Load();
|
||||
}
|
||||
|
||||
void SConfig::ResetRunningGameMetadata()
|
||||
|
@ -239,7 +207,6 @@ void SConfig::LoadDefaults()
|
|||
bAutomaticStart = false;
|
||||
bBootToPause = false;
|
||||
|
||||
bSyncGPU = false;
|
||||
bWii = false;
|
||||
|
||||
ResetRunningGameMetadata();
|
||||
|
|
|
@ -58,11 +58,6 @@ struct SConfig
|
|||
|
||||
bool bCopyWiiSaveNetplay = true;
|
||||
|
||||
bool bSyncGPU = false;
|
||||
int iSyncGpuMaxDistance;
|
||||
int iSyncGpuMinDistance;
|
||||
float fSyncGpuOverclock;
|
||||
|
||||
bool bWii = false;
|
||||
bool m_is_mios = false;
|
||||
|
||||
|
@ -130,10 +125,6 @@ private:
|
|||
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);
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ void DolphinAnalytics::MakePerGameBuilder()
|
|||
builder.AddData("cfg-dsp-thread", Config::Get(Config::MAIN_DSP_THREAD));
|
||||
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));
|
||||
|
|
|
@ -72,6 +72,20 @@ static std::atomic<int> s_sync_ticks;
|
|||
static bool s_syncing_suspended;
|
||||
static Common::Event s_sync_wakeup_event;
|
||||
|
||||
static std::optional<size_t> s_config_callback_id = std::nullopt;
|
||||
static bool s_config_sync_gpu = false;
|
||||
static int s_config_sync_gpu_max_distance = 0;
|
||||
static int s_config_sync_gpu_min_distance = 0;
|
||||
static float s_config_sync_gpu_overclock = 0.0f;
|
||||
|
||||
static void RefreshConfig()
|
||||
{
|
||||
s_config_sync_gpu = Config::Get(Config::MAIN_SYNC_GPU);
|
||||
s_config_sync_gpu_max_distance = Config::Get(Config::MAIN_SYNC_GPU_MAX_DISTANCE);
|
||||
s_config_sync_gpu_min_distance = Config::Get(Config::MAIN_SYNC_GPU_MIN_DISTANCE);
|
||||
s_config_sync_gpu_overclock = Config::Get(Config::MAIN_SYNC_GPU_OVERCLOCK);
|
||||
}
|
||||
|
||||
void DoState(PointerWrap& p)
|
||||
{
|
||||
p.DoArray(s_video_buffer, FIFO_SIZE);
|
||||
|
@ -110,6 +124,10 @@ void PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
|||
|
||||
void Init()
|
||||
{
|
||||
if (!s_config_callback_id)
|
||||
s_config_callback_id = Config::AddConfigChangedCallback(RefreshConfig);
|
||||
RefreshConfig();
|
||||
|
||||
// Padded so that SIMD overreads in the vertex loader are safe
|
||||
s_video_buffer = static_cast<u8*>(Common::AllocateMemoryPages(FIFO_SIZE + 4));
|
||||
ResetVideoBuffer();
|
||||
|
@ -131,6 +149,12 @@ void Shutdown()
|
|||
s_video_buffer_seen_ptr = nullptr;
|
||||
s_fifo_aux_write_ptr = nullptr;
|
||||
s_fifo_aux_read_ptr = nullptr;
|
||||
|
||||
if (s_config_callback_id)
|
||||
{
|
||||
Config::RemoveConfigChangedCallback(*s_config_callback_id);
|
||||
s_config_callback_id = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
// May be executed from any thread, even the graphics thread.
|
||||
|
@ -296,10 +320,8 @@ void RunGpuLoop()
|
|||
AsyncRequests::GetInstance()->SetEnable(true);
|
||||
AsyncRequests::GetInstance()->SetPassthrough(false);
|
||||
|
||||
const SConfig& param = SConfig::GetInstance();
|
||||
|
||||
s_gpu_mainloop.Run(
|
||||
[¶m] {
|
||||
[] {
|
||||
// Run events from the CPU thread.
|
||||
AsyncRequests::GetInstance()->PullEvents();
|
||||
|
||||
|
@ -330,7 +352,7 @@ void RunGpuLoop()
|
|||
fifo.bFF_GPReadEnable.load(std::memory_order_relaxed) &&
|
||||
fifo.CPReadWriteDistance.load(std::memory_order_relaxed) && !AtBreakpoint())
|
||||
{
|
||||
if (param.bSyncGPU && s_sync_ticks.load() < param.iSyncGpuMinDistance)
|
||||
if (s_config_sync_gpu && s_sync_ticks.load() < s_config_sync_gpu_min_distance)
|
||||
break;
|
||||
|
||||
u32 cyclesExecuted = 0;
|
||||
|
@ -362,12 +384,12 @@ void RunGpuLoop()
|
|||
|
||||
CommandProcessor::SetCPStatusFromGPU();
|
||||
|
||||
if (param.bSyncGPU)
|
||||
if (s_config_sync_gpu)
|
||||
{
|
||||
cyclesExecuted = (int)(cyclesExecuted / param.fSyncGpuOverclock);
|
||||
cyclesExecuted = (int)(cyclesExecuted / s_config_sync_gpu_overclock);
|
||||
int old = s_sync_ticks.fetch_sub(cyclesExecuted);
|
||||
if (old >= param.iSyncGpuMaxDistance &&
|
||||
old - (int)cyclesExecuted < param.iSyncGpuMaxDistance)
|
||||
if (old >= s_config_sync_gpu_max_distance &&
|
||||
old - (int)cyclesExecuted < s_config_sync_gpu_max_distance)
|
||||
s_sync_wakeup_event.Set();
|
||||
}
|
||||
|
||||
|
@ -382,7 +404,7 @@ void RunGpuLoop()
|
|||
if (s_sync_ticks.load() > 0)
|
||||
{
|
||||
int old = s_sync_ticks.exchange(0);
|
||||
if (old >= param.iSyncGpuMaxDistance)
|
||||
if (old >= s_config_sync_gpu_max_distance)
|
||||
s_sync_wakeup_event.Set();
|
||||
}
|
||||
|
||||
|
@ -429,7 +451,7 @@ void RunGpu()
|
|||
}
|
||||
|
||||
// if the sync GPU callback is suspended, wake it up.
|
||||
if (!is_dual_core || s_use_deterministic_gpu_thread || SConfig::GetInstance().bSyncGPU)
|
||||
if (!is_dual_core || s_use_deterministic_gpu_thread || s_config_sync_gpu)
|
||||
{
|
||||
if (s_syncing_suspended)
|
||||
{
|
||||
|
@ -443,7 +465,7 @@ static int RunGpuOnCpu(int ticks)
|
|||
{
|
||||
CommandProcessor::SCPFifoStruct& fifo = CommandProcessor::fifo;
|
||||
bool reset_simd_state = false;
|
||||
int available_ticks = int(ticks * SConfig::GetInstance().fSyncGpuOverclock) + s_sync_ticks.load();
|
||||
int available_ticks = int(ticks * s_config_sync_gpu_overclock) + s_sync_ticks.load();
|
||||
while (fifo.bFF_GPReadEnable.load(std::memory_order_relaxed) &&
|
||||
fifo.CPReadWriteDistance.load(std::memory_order_relaxed) && !AtBreakpoint() &&
|
||||
available_ticks >= 0)
|
||||
|
@ -545,8 +567,6 @@ bool UseDeterministicGPUThread()
|
|||
*/
|
||||
static int WaitForGpuThread(int ticks)
|
||||
{
|
||||
const SConfig& param = SConfig::GetInstance();
|
||||
|
||||
int old = s_sync_ticks.fetch_add(ticks);
|
||||
int now = old + ticks;
|
||||
|
||||
|
@ -555,15 +575,15 @@ static int WaitForGpuThread(int ticks)
|
|||
return -1;
|
||||
|
||||
// Wakeup GPU
|
||||
if (old < param.iSyncGpuMinDistance && now >= param.iSyncGpuMinDistance)
|
||||
if (old < s_config_sync_gpu_min_distance && now >= s_config_sync_gpu_min_distance)
|
||||
RunGpu();
|
||||
|
||||
// If the GPU is still sleeping, wait for a longer time
|
||||
if (now < param.iSyncGpuMinDistance)
|
||||
return GPU_TIME_SLOT_SIZE + param.iSyncGpuMinDistance - now;
|
||||
if (now < s_config_sync_gpu_min_distance)
|
||||
return GPU_TIME_SLOT_SIZE + s_config_sync_gpu_min_distance - now;
|
||||
|
||||
// Wait for GPU
|
||||
if (now >= param.iSyncGpuMaxDistance)
|
||||
if (now >= s_config_sync_gpu_max_distance)
|
||||
s_sync_wakeup_event.Wait();
|
||||
|
||||
return GPU_TIME_SLOT_SIZE;
|
||||
|
@ -578,7 +598,7 @@ static void SyncGPUCallback(u64 ticks, s64 cyclesLate)
|
|||
{
|
||||
next = RunGpuOnCpu((int)ticks);
|
||||
}
|
||||
else if (SConfig::GetInstance().bSyncGPU)
|
||||
else if (s_config_sync_gpu)
|
||||
{
|
||||
next = WaitForGpuThread((int)ticks);
|
||||
}
|
||||
|
@ -594,7 +614,7 @@ void SyncGPUForRegisterAccess()
|
|||
|
||||
if (!Core::System::GetInstance().IsDualCoreMode() || s_use_deterministic_gpu_thread)
|
||||
RunGpuOnCpu(GPU_TIME_SLOT_SIZE);
|
||||
else if (SConfig::GetInstance().bSyncGPU)
|
||||
else if (s_config_sync_gpu)
|
||||
WaitForGpuThread(GPU_TIME_SLOT_SIZE);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue