diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 4dbe7a2f9d..23de16583b 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -96,7 +96,6 @@ private: float m_OCFactor; bool m_OCEnable; bool m_bt_passthrough_enabled; - std::string strBackend; std::string sBackend; std::string m_strGPUDeterminismMode; std::array iWiimoteSource; @@ -127,7 +126,6 @@ void ConfigCache::SaveConfig(const SConfig& config) cpu_core = config.cpu_core; Volume = config.m_Volume; m_EmulationSpeed = config.m_EmulationSpeed; - strBackend = config.m_strVideoBackend; sBackend = config.sBackend; m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; m_OCFactor = config.m_OCFactor; @@ -202,13 +200,11 @@ void ConfigCache::RestoreConfig(SConfig* config) config->m_EXIDevice[i] = m_EXIDevice[i]; } - config->m_strVideoBackend = strBackend; config->sBackend = sBackend; config->m_strGPUDeterminismMode = m_strGPUDeterminismMode; config->m_OCFactor = m_OCFactor; config->m_OCEnable = m_OCEnable; config->m_bt_passthrough_enabled = m_bt_passthrough_enabled; - VideoBackendBase::ActivateBackend(config->m_strVideoBackend); } static ConfigCache config_cache; @@ -269,7 +265,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU); core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE); - core_section->Get("GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend); core_section->Get("CPUCore", &StartUp.cpu_core, StartUp.cpu_core); core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2); core_section->Get("GameCubeLanguage", &StartUp.SelectedLanguage, StartUp.SelectedLanguage); @@ -280,7 +275,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) config_cache.bSetVolume = true; dsp_section->Get("EnableJIT", &StartUp.m_DSPEnableJIT, StartUp.m_DSPEnableJIT); dsp_section->Get("Backend", &StartUp.sBackend, StartUp.sBackend); - VideoBackendBase::ActivateBackend(StartUp.m_strVideoBackend); core_section->Get("GPUDeterminismMode", &StartUp.m_strGPUDeterminismMode, StartUp.m_strGPUDeterminismMode); core_section->Get("Overclock", &StartUp.m_OCFactor, StartUp.m_OCFactor); diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 98aca975e1..50532508f9 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -28,7 +28,7 @@ bool IsSettingSaveable(const Config::Location& config_location) return true; } - static constexpr std::array s_setting_saveable = { + static constexpr std::array s_setting_saveable = { // Main.Core &Config::MAIN_DEFAULT_ISO.location, @@ -40,6 +40,7 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::MAIN_RAM_OVERRIDE_ENABLE.location, &Config::MAIN_MEM1_SIZE.location, &Config::MAIN_MEM2_SIZE.location, + &Config::MAIN_GFX_BACKEND.location, // Main.Display diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 3c7d223b52..092d45b1da 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -241,7 +241,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("EmulationSpeed", m_EmulationSpeed); core->Set("Overclock", m_OCFactor); core->Set("OverclockEnable", m_OCEnable); - core->Set("GFXBackend", m_strVideoBackend); core->Set("GPUDeterminismMode", m_strGPUDeterminismMode); core->Set("PerfMapDir", m_perfDir); core->Set("EnableCustomRTC", bEnableCustomRTC); @@ -517,7 +516,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("EmulationSpeed", &m_EmulationSpeed, 1.0f); core->Get("Overclock", &m_OCFactor, 1.0f); core->Get("OverclockEnable", &m_OCEnable, false); - core->Get("GFXBackend", &m_strVideoBackend, ""); core->Get("GPUDeterminismMode", &m_strGPUDeterminismMode, "auto"); core->Get("PerfMapDir", &m_perfDir, ""); core->Get("EnableCustomRTC", &bEnableCustomRTC, false); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 87e0134e96..4341f88196 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -180,7 +180,6 @@ struct SConfig DiscIO::Region m_region; - std::string m_strVideoBackend; std::string m_strGPUDeterminismMode; // set based on the string version diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 72b33dd37b..3e3b15bde6 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -459,11 +459,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi HLE::Clear(); }}; - // Backend info has to be initialized before we can initialize the backend. - // This is because when we load the config, we validate it against the current backend info. - // We also should have the correct adapter selected for creating the device in Initialize(). - g_video_backend->InitBackendInfo(); - g_Config.Refresh(); + VideoBackendBase::PopulateBackendInfo(); if (!g_video_backend->Initialize(wsi)) { diff --git a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp index c616880632..eeefbf7ddb 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp @@ -38,7 +38,7 @@ GeneralWidget::GeneralWidget(X11Utils::XRRConfiguration* xrr_config, GraphicsWin LoadSettings(); ConnectWidgets(); AddDescriptions(); - emit BackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend)); + emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND))); connect(parent, &GraphicsWindow::BackendChanged, this, &GeneralWidget::OnBackendChanged); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, @@ -150,14 +150,14 @@ void GeneralWidget::LoadSettings() { // Video Backend m_backend_combo->setCurrentIndex(m_backend_combo->findData( - QVariant(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend)))); + QVariant(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND))))); } void GeneralWidget::SaveSettings() { // Video Backend const auto current_backend = m_backend_combo->currentData().toString().toStdString(); - if (SConfig::GetInstance().m_strVideoBackend != current_backend) + if (Config::Get(Config::MAIN_GFX_BACKEND) != current_backend) { auto warningMessage = g_available_video_backends[m_backend_combo->currentIndex()]->GetWarningMessage(); @@ -173,7 +173,7 @@ void GeneralWidget::SaveSettings() if (confirm_sw.exec() != QMessageBox::Yes) { m_backend_combo->setCurrentIndex(m_backend_combo->findData( - QVariant(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend)))); + QVariant(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND))))); return; } } diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp b/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp index e66f5a27ff..b9ca205b08 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp @@ -11,6 +11,8 @@ #include #include +#include "Common/Config/Config.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "DolphinQt/Config/Graphics/AdvancedWidget.h" @@ -32,7 +34,7 @@ GraphicsWindow::GraphicsWindow(X11Utils::XRRConfiguration* xrr_config, MainWindo setWindowTitle(tr("Graphics")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - OnBackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend)); + OnBackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND))); } void GraphicsWindow::CreateMainLayout() @@ -77,7 +79,7 @@ void GraphicsWindow::CreateMainLayout() m_wrapped_advanced = GetWrappedWidget(m_advanced_widget, this, 50, 305); m_wrapped_software = GetWrappedWidget(m_software_renderer, this, 50, 305); - if (SConfig::GetInstance().m_strVideoBackend != "Software Renderer") + if (Config::Get(Config::MAIN_GFX_BACKEND) != "Software Renderer") { m_tab_widget->addTab(m_wrapped_general, tr("General")); m_tab_widget->addTab(m_wrapped_enhancements, tr("Enhancements")); @@ -94,8 +96,8 @@ void GraphicsWindow::CreateMainLayout() void GraphicsWindow::OnBackendChanged(const QString& backend_name) { - SConfig::GetInstance().m_strVideoBackend = backend_name.toStdString(); - VideoBackendBase::PopulateBackendInfo(); + Config::SetBase(Config::MAIN_GFX_BACKEND, backend_name.toStdString()); + VideoBackendBase::PopulateBackendInfoFromUI(); setWindowTitle( tr("%1 Graphics Configuration").arg(tr(g_video_backend->GetDisplayName().c_str()))); diff --git a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp index 2229a51ddf..5aaf31480b 100644 --- a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp @@ -11,6 +11,7 @@ #include #include "Core/Config/GraphicsSettings.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "DolphinQt/Config/Graphics/GraphicsBool.h" @@ -28,7 +29,7 @@ HacksWidget::HacksWidget(GraphicsWindow* parent) : GraphicsWidget(parent) AddDescriptions(); connect(parent, &GraphicsWindow::BackendChanged, this, &HacksWidget::OnBackendChanged); - OnBackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend)); + OnBackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND))); connect(&Settings::Instance(), &Settings::ConfigChanged, this, &HacksWidget::LoadSettings); } diff --git a/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp index 5af91d0ff5..c1e7c5f73f 100644 --- a/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp @@ -12,6 +12,7 @@ #include #include "Core/Config/GraphicsSettings.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -30,7 +31,7 @@ SoftwareRendererWidget::SoftwareRendererWidget(GraphicsWindow* parent) : Graphic LoadSettings(); ConnectWidgets(); AddDescriptions(); - emit BackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend)); + emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND))); connect(parent, &GraphicsWindow::BackendChanged, [this] { LoadSettings(); }); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, @@ -123,9 +124,11 @@ void SoftwareRendererWidget::LoadSettings() { for (const auto& backend : g_available_video_backends) { - if (backend->GetName() == SConfig::GetInstance().m_strVideoBackend) + if (backend->GetName() == Config::Get(Config::MAIN_GFX_BACKEND)) + { m_backend_combo->setCurrentIndex( m_backend_combo->findText(tr(backend->GetDisplayName().c_str()))); + } } m_object_range_min->setValue(Config::Get(Config::GFX_SW_DRAW_START)); @@ -139,7 +142,7 @@ void SoftwareRendererWidget::SaveSettings() if (tr(backend->GetDisplayName().c_str()) == m_backend_combo->currentText()) { const auto backend_name = backend->GetName(); - if (backend_name != SConfig::GetInstance().m_strVideoBackend) + if (backend_name != Config::Get(Config::MAIN_GFX_BACKEND)) emit BackendChanged(QString::fromStdString(backend_name)); break; } diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index 86de40a8ca..c7bbf98e22 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -100,7 +100,7 @@ void Init() VideoBackendBase::PopulateList(); WiimoteReal::LoadSettings(); GCAdapter::Init(); - VideoBackendBase::ActivateBackend(SConfig::GetInstance().m_strVideoBackend); + VideoBackendBase::ActivateBackend(Config::Get(Config::MAIN_GFX_BACKEND)); Common::SetEnableAlert(SConfig::GetInstance().bUsePanicHandlers); } diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 2c58449e1d..5e7337c767 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -14,9 +14,11 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #include "Common/Event.h" #include "Common/Logging/Log.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -245,18 +247,21 @@ void VideoBackendBase::ActivateBackend(const std::string& name) 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); + ActivateBackend(Config::Get(Config::MAIN_GFX_BACKEND)); g_video_backend->InitBackendInfo(); g_Config.Refresh(); } +void VideoBackendBase::PopulateBackendInfoFromUI() +{ + // 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()) + PopulateBackendInfo(); +} + void VideoBackendBase::DoState(PointerWrap& p) { if (!SConfig::GetInstance().bCPUThread) diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h index 7eeffaaf95..0370ef2a44 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.h +++ b/Source/Core/VideoCommon/VideoBackendBase.h @@ -64,8 +64,9 @@ public: 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(); + // Called by the UI thread when the graphics config is opened. + static void PopulateBackendInfoFromUI(); // Wrapper function which pushes the event to the GPU thread. void DoState(PointerWrap& p);