Merge pull request #7437 from stenzek/graphics-options-race

Fix race condition caused by opening graphics options while running
This commit is contained in:
Mat M
2018-10-12 10:29:28 -04:00
committed by GitHub
15 changed files with 29 additions and 48 deletions

View File

@ -14,6 +14,8 @@
#include "Common/CommonTypes.h"
#include "Common/Event.h"
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/Host.h"
// TODO: ugly
@ -60,14 +62,6 @@ __declspec(dllexport) DWORD NvOptimusEnablement = 1;
}
#endif
void VideoBackendBase::ShowConfig(void* parent_handle)
{
if (!m_initialized)
InitBackendInfo();
Host_ShowVideoConfig(parent_handle, GetDisplayName());
}
void VideoBackendBase::Video_ExitLoop()
{
Fifo::ExitGpuLoop();
@ -231,6 +225,20 @@ void VideoBackendBase::ActivateBackend(const std::string& name)
g_video_backend = iter->get();
}
void VideoBackendBase::PopulateBackendInfo()
{
// If the core is running, the backend info will have been populated already.
// If we did it here, the UI thread can race with the with the GPU thread.
if (Core::IsRunning())
return;
// We refresh the config after initializing the backend info, as system-specific settings
// such as anti-aliasing, or the selected adapter may be invalid, and should be checked.
ActivateBackend(SConfig::GetInstance().m_strVideoBackend);
g_video_backend->InitBackendInfo();
g_Config.Refresh();
}
// Run from the CPU thread
void VideoBackendBase::DoState(PointerWrap& p)
{
@ -294,7 +302,6 @@ void VideoBackendBase::InitializeShared()
GeometryShaderManager::Init();
PixelShaderManager::Init();
g_Config.Refresh();
UpdateActiveConfig();
}

View File

@ -40,7 +40,6 @@ public:
virtual std::string GetName() const = 0;
virtual std::string GetDisplayName() const { return GetName(); }
void ShowConfig(void* parent_handle);
virtual void InitBackendInfo() = 0;
void Video_ExitLoop();
@ -55,6 +54,10 @@ public:
static void ClearList();
static void ActivateBackend(const std::string& name);
// Fills the backend_info fields with the capabilities of the selected backend/device.
// Called by the UI thread when the graphics config is opened.
static void PopulateBackendInfo();
// the implementation needs not do synchronization logic, because calls to it are surrounded by
// PauseAndLock now
void DoState(PointerWrap& p);