diff options
| author | Mat M <mathew1800@gmail.com> | 2018-10-12 10:29:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-12 10:29:28 -0400 |
| commit | ecd4897d43e115dbc00534fe74a5cc9d2c3a0fed (patch) | |
| tree | a2a879c0df72ce242ec69b51405426d2b52f3bc5 /Source/Core/VideoCommon | |
| parent | 7ac90b55d6263b1369defcdcc85af290add87d9a (diff) | |
| parent | 349765ba77df11a9d5eeac424ac87e0047c7f0b3 (diff) | |
Merge pull request #7437 from stenzek/graphics-options-race
Fix race condition caused by opening graphics options while running
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/VideoBackendBase.cpp | 25 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoBackendBase.h | 5 |
2 files changed, 20 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 77ffb294ff..725857a85d 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -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(); } diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h index 576cd1f3e6..5f43b904d4 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.h +++ b/Source/Core/VideoCommon/VideoBackendBase.h @@ -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); |
