From 6811cd617b24bbece61fa44df33b327eb9056857 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Mon, 29 Nov 2021 22:30:54 -0600 Subject: [PATCH] GS: Add system default adapter config option --- pcsx2/GS/GSUtil.cpp | 3 +-- pcsx2/GS/GSUtil.h | 2 +- pcsx2/GS/Window/GSwxDialog.cpp | 38 ++++++++++++++-------------------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/pcsx2/GS/GSUtil.cpp b/pcsx2/GS/GSUtil.cpp index 9aff3850d7..f7f64368ae 100644 --- a/pcsx2/GS/GSUtil.cpp +++ b/pcsx2/GS/GSUtil.cpp @@ -197,12 +197,11 @@ GSRendererType GSUtil::GetPreferredRenderer() return GSRendererType::OGL_HW; } -std::vector GSUtil::GetAdapterList(GSRendererType renderer, size_t& default_adapter) +std::vector GSUtil::GetAdapterList(GSRendererType renderer) { #ifdef _WIN32 if (renderer == GSRendererType::DX1011_HW) { - default_adapter = 0; auto factory = D3D::CreateFactory(false); return D3D::GetAdapterList(factory.get()); } diff --git a/pcsx2/GS/GSUtil.h b/pcsx2/GS/GSUtil.h index 2e554c0c2c..d284f7afb6 100644 --- a/pcsx2/GS/GSUtil.h +++ b/pcsx2/GS/GSUtil.h @@ -42,7 +42,7 @@ public: static bool CheckSSE(); static CRCHackLevel GetRecommendedCRCHackLevel(GSRendererType type); static GSRendererType GetPreferredRenderer(); - static std::vector GetAdapterList(GSRendererType renderer, size_t& default_adapter); + static std::vector GetAdapterList(GSRendererType renderer); }; #ifdef _WIN32 diff --git a/pcsx2/GS/Window/GSwxDialog.cpp b/pcsx2/GS/Window/GSwxDialog.cpp index c0d2925820..1369e23961 100644 --- a/pcsx2/GS/Window/GSwxDialog.cpp +++ b/pcsx2/GS/Window/GSwxDialog.cpp @@ -686,31 +686,23 @@ void Dialog::RendererChange() int current_sel = m_adapter_select->GetSelection(); if (current_sel >= 0 && current_sel < static_cast(m_adapter_arr_string.Count())) current = m_adapter_arr_string[current_sel].ToUTF8(); + bool explicitly_selected_default = m_adapter_arr_string.Count() > 1 && current_sel == 0; - size_t default_adapter = 0; - std::vector adapters = GSUtil::GetAdapterList(renderer, default_adapter); + std::vector adapters = GSUtil::GetAdapterList(renderer); - m_adapter_select->Clear(); - if (adapters.empty()) + m_adapter_arr_string.Clear(); + m_adapter_arr_string.Add(_("Default Adapter")); + int new_sel = theApp.GetConfigI("adapter_index") + 1; + if (new_sel < 0 || new_sel >= static_cast(adapters.size() + 1) || explicitly_selected_default) + new_sel = 0; + for (std::string& adapter : adapters) { - m_adapter_select->Disable(); - } - else - { - m_adapter_arr_string.Clear(); - int new_sel = theApp.GetConfigI("adapter_index"); - if (new_sel < 0 || new_sel >= static_cast(adapters.size())) - new_sel = default_adapter; - for (std::string& adapter : adapters) - { - if (adapter == current) - new_sel = m_adapter_arr_string.Count(); - m_adapter_arr_string.Add(fromUTF8(adapter)); - } - m_adapter_select->Set(m_adapter_arr_string); - m_adapter_select->SetSelection(new_sel); - m_adapter_select->Enable(); + if (adapter == current) + new_sel = m_adapter_arr_string.Count(); + m_adapter_arr_string.Add(fromUTF8(adapter)); } + m_adapter_select->Set(m_adapter_arr_string); + m_adapter_select->SetSelection(new_sel); #ifdef _WIN32 m_renderer_panel->UpdateBlendMode(renderer); @@ -741,8 +733,8 @@ void Dialog::Save() m_ui.Save(); // only save the adapter when it makes sense to // prevents changing the adapter, switching to another renderer and saving - if (m_adapter_select->GetCount()) - theApp.SetConfig("adapter_index", m_adapter_select->GetSelection()); + if (m_adapter_select->GetCount() > 1) // First option is system default + theApp.SetConfig("adapter_index", m_adapter_select->GetSelection() - 1); m_hacks_panel->Save(); m_renderer_panel->Save();