Skip to content

Commit

Permalink
GS/Qt: Adjust how we handle Default adapter.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lightningterror authored and F0bes committed Oct 23, 2024
1 parent 9e15058 commit 1b50057
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pcsx2-qt/Settings/GraphicsSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", &current_adapter))
{
// clear the adapter so we don't set it to the global value
Expand Down
6 changes: 6 additions & 0 deletions pcsx2/GS/GS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GS/GS.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void GSSetVSyncMode(GSVSyncMode mode, bool allow_present_throttle);

GSRendererType GSGetCurrentRenderer();
bool GSIsHardwareRenderer();
std::string GetDefaultAdapter();
bool GSWantsExclusiveFullscreen();
std::optional<float> GSGetHostRefreshRate();
std::vector<GSAdapterInfo> GSGetAdapterInfo(GSRendererType renderer);
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/GS/Renderers/DX11/D3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ bool D3D::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const

wil::com_ptr_nothrow<IDXGIAdapter1> 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.
Expand Down
4 changes: 3 additions & 1 deletion pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>(gpus.size()); gpu_index++)
Expand All @@ -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;
}

Expand Down

0 comments on commit 1b50057

Please sign in to comment.