From 1b50057764a351e942c8087dc46cc81e73907889 Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Tue, 22 Oct 2024 02:24:31 +0200 Subject: [PATCH] GS/Qt: Adjust how we handle Default adapter. Try to resolve it again since it annoys me. Treat is as empty. Also do NOT translate Default adapter, it messes with the ini config. --- pcsx2-qt/Settings/GraphicsSettingsWidget.cpp | 4 ++-- pcsx2/GS/GS.cpp | 6 ++++++ pcsx2/GS/GS.h | 1 + pcsx2/GS/Renderers/DX11/D3D.cpp | 2 +- pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm | 4 +++- pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp | 5 +++-- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp index f01b2d685e..6307c6beb8 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp @@ -1137,13 +1137,13 @@ void GraphicsSettingsWidget::updateRendererDependentOptions() std::string current_adapter = Host::GetBaseStringSettingValue("EmuCore/GS", "Adapter", ""); m_ui.adapterDropdown->clear(); m_ui.adapterDropdown->setEnabled(!adapters.empty()); - m_ui.adapterDropdown->addItem(tr("(Default)")); + m_ui.adapterDropdown->addItem(GetDefaultAdapter().c_str()); m_ui.adapterDropdown->setCurrentIndex(0); if (m_dialog->isPerGameSettings()) { m_ui.adapterDropdown->insertItem( - 0, tr("Use Global Setting [%1]").arg(current_adapter.empty() ? tr("(Default)") : QString::fromStdString(current_adapter))); + 0, tr("Use Global Setting [%1]").arg(current_adapter.empty() ? GetDefaultAdapter().c_str() : QString::fromStdString(current_adapter))); if (!m_dialog->getSettingsInterface()->GetStringValue("EmuCore/GS", "Adapter", ¤t_adapter)) { // clear the adapter so we don't set it to the global value diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 37b441cc85..84956d86a3 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -69,6 +69,12 @@ bool GSIsHardwareRenderer() return (GSCurrentRenderer != GSRendererType::SW); } +std::string GetDefaultAdapter() +{ + // Will be treated as empty. + return "(Default)"; +} + static RenderAPI GetAPIForRenderer(GSRendererType renderer) { switch (renderer) diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index 0ab827f0af..f2882c3a7f 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -89,6 +89,7 @@ void GSSetVSyncMode(GSVSyncMode mode, bool allow_present_throttle); GSRendererType GSGetCurrentRenderer(); bool GSIsHardwareRenderer(); +std::string GetDefaultAdapter(); bool GSWantsExclusiveFullscreen(); std::optional GSGetHostRefreshRate(); std::vector GSGetAdapterInfo(GSRendererType renderer); diff --git a/pcsx2/GS/Renderers/DX11/D3D.cpp b/pcsx2/GS/Renderers/DX11/D3D.cpp index 7b9f52101e..d1fbec14cf 100644 --- a/pcsx2/GS/Renderers/DX11/D3D.cpp +++ b/pcsx2/GS/Renderers/DX11/D3D.cpp @@ -197,7 +197,7 @@ bool D3D::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const wil::com_ptr_nothrow D3D::GetAdapterByName(IDXGIFactory5* factory, const std::string_view name) { - if (name.empty()) + if (name.empty() || name == GetDefaultAdapter()) return {}; // This might seem a bit odd to cache the names.. but there's a method to the madness. diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm index f068304da7..55d917368c 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -851,7 +851,9 @@ bool GSDeviceMTL::Create(GSVSyncMode vsync_mode, bool allow_present_throttle) } if (!m_dev.dev) { - if (!GSConfig.Adapter.empty()) + if (GSConfig.Adapter == GetDefaultAdapter()) + Console.WriteLn("Metal: Using default adapter"); + else if (!GSConfig.Adapter.empty()) Console.Warning("Metal: Couldn't find adapter %s, using default", GSConfig.Adapter.c_str()); m_dev = GSMTLDevice(MRCTransfer(MTLCreateSystemDefaultDevice())); if (!m_dev.dev) diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index b84cd35564..c16af54cde 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -2511,7 +2511,8 @@ bool GSDeviceVK::CreateDeviceAndSwapChain() return false; } - if (!GSConfig.Adapter.empty()) + const bool is_default_gpu = GSConfig.Adapter == GetDefaultAdapter(); + if (!(GSConfig.Adapter.empty() || is_default_gpu)) { u32 gpu_index = 0; for (; gpu_index < static_cast(gpus.size()); gpu_index++) @@ -2532,7 +2533,7 @@ bool GSDeviceVK::CreateDeviceAndSwapChain() } else { - INFO_LOG("No GPU requested, using first ({})", gpus[0].second.name); + INFO_LOG("{} GPU requested, using first ({})", is_default_gpu ? "Default" : "No", gpus[0].second.name); m_physical_device = gpus[0].first; }