System: Use recreation logic for toggling GPU threading

This commit is contained in:
Stenzek 2025-01-31 12:56:14 +10:00
parent f7d7eecb6c
commit 96058f5d7e
No known key found for this signature in database
1 changed files with 23 additions and 1 deletions

View File

@ -170,6 +170,7 @@ static void ClearRunningGame();
static void DestroySystem();
static void RecreateGPU(GPURenderer new_renderer);
static void SetGPUThreadEnabled(bool enabled);
static std::string GetScreenshotPath(const char* extension);
static bool StartMediaCapture(std::string path, bool capture_video, bool capture_audio, u32 video_width,
u32 video_height);
@ -1203,6 +1204,27 @@ void System::RecreateGPU(GPURenderer renderer)
GPUThread::PresentCurrentFrame();
}
void System::SetGPUThreadEnabled(bool enabled)
{
// can be called without valid system
if (!IsValid())
{
GPUThread::Internal::SetThreadEnabled(g_settings.gpu_use_thread);
return;
}
FreeMemoryStateStorage(false, true, false);
StopMediaCapture();
GPUThread::Internal::SetThreadEnabled(g_settings.gpu_use_thread);
ClearMemorySaveStates(true, false);
g_gpu.UpdateDisplay(false);
if (IsPaused())
GPUThread::PresentCurrentFrame();
}
void System::LoadSettings(bool display_osd_messages)
{
std::unique_lock<std::mutex> lock = Host::GetSettingsLock();
@ -4676,7 +4698,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
if (g_settings.gpu_use_thread != old_settings.gpu_use_thread) [[unlikely]]
{
GPUThread::Internal::SetThreadEnabled(g_settings.gpu_use_thread);
SetGPUThreadEnabled(g_settings.gpu_use_thread);
}
else if (g_settings.gpu_use_thread && g_settings.gpu_max_queued_frames != old_settings.gpu_max_queued_frames)
[[unlikely]]