From b3b564dbb797891b0cc980d96a4ae4b78f3fa1d0 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 f01b2d685e55d4..6307c6beb80d50 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 37b441cc854c0e..84956d86a35c41 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 0ab827f0afb6a8..f2882c3a7f1057 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 7b9f52101eaac3..d1fbec14cf8d9a 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 f068304da72dd4..55d917368cbe94 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -851,7 +851,9 @@ static void OnMainThread(Fn&& fn) } 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 b84cd355643673..c16af54cde6ad9 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; }