mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-28 03:39:55 +00:00
[Qt] fix graphics adapter selection and rebase for less redundancy
This commit is contained in:
parent
cad91e114d
commit
b141b43c1c
@ -19,6 +19,7 @@ struct Render_Creator
|
|||||||
bool supportsVulkan = false;
|
bool supportsVulkan = false;
|
||||||
QStringList D3D12Adapters;
|
QStringList D3D12Adapters;
|
||||||
QStringList vulkanAdapters;
|
QStringList vulkanAdapters;
|
||||||
|
QString render_Null = QObject::tr("Null");
|
||||||
QString render_Vulkan = QObject::tr("Vulkan");
|
QString render_Vulkan = QObject::tr("Vulkan");
|
||||||
QString render_D3D12 = QObject::tr("D3D12[DO NOT USE]");
|
QString render_D3D12 = QObject::tr("D3D12[DO NOT USE]");
|
||||||
QString render_OpenGL = QObject::tr("OpenGL");
|
QString render_OpenGL = QObject::tr("OpenGL");
|
||||||
|
@ -377,26 +377,28 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> xSettings, const
|
|||||||
ui->scrictModeRendering->setToolTip(json_gpu_main["scrictModeRendering"].toString());
|
ui->scrictModeRendering->setToolTip(json_gpu_main["scrictModeRendering"].toString());
|
||||||
|
|
||||||
// Graphics Adapter
|
// Graphics Adapter
|
||||||
QStringList D3D12Adapters = r_Creator.D3D12Adapters;
|
m_D3D12 = Render_Info(r_Creator.render_D3D12, r_Creator.D3D12Adapters, r_Creator.supportsD3D12, emu_settings::D3D12Adapter);
|
||||||
QStringList vulkanAdapters = r_Creator.vulkanAdapters;
|
m_Vulkan = Render_Info(r_Creator.render_Vulkan, r_Creator.vulkanAdapters, r_Creator.supportsVulkan, emu_settings::VulkanAdapter);
|
||||||
bool supportsD3D12 = r_Creator.supportsD3D12;
|
m_OpenGL = Render_Info(r_Creator.render_OpenGL);
|
||||||
bool supportsVulkan = r_Creator.supportsVulkan;
|
m_NullRender = Render_Info(r_Creator.render_Null);
|
||||||
QString r_D3D12 = r_Creator.render_D3D12;
|
|
||||||
QString r_Vulkan = r_Creator.render_Vulkan;
|
|
||||||
QString r_OpenGL = r_Creator.render_OpenGL;
|
|
||||||
QString old_D3D12;
|
|
||||||
QString old_Vulkan;
|
|
||||||
|
|
||||||
if (supportsD3D12)
|
std::vector<Render_Info*> Render_List = { &m_D3D12, &m_Vulkan, &m_OpenGL, &m_NullRender };
|
||||||
|
|
||||||
|
// Remove renderers from the renderer Combobox if not supported
|
||||||
|
for (auto renderer : Render_List)
|
||||||
{
|
{
|
||||||
old_D3D12 = qstr(xemu_settings->GetSetting(emu_settings::D3D12Adapter));
|
if (renderer->supported)
|
||||||
}
|
{
|
||||||
else
|
if (renderer->has_adapters)
|
||||||
{
|
{
|
||||||
// Remove D3D12 option from render combobox
|
renderer->old_adapter = qstr(xemu_settings->GetSetting(renderer->type));
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ui->renderBox->count(); i++)
|
for (int i = 0; i < ui->renderBox->count(); i++)
|
||||||
{
|
{
|
||||||
if (ui->renderBox->itemText(i) == r_D3D12)
|
if (ui->renderBox->itemText(i) == renderer->name)
|
||||||
{
|
{
|
||||||
ui->renderBox->removeItem(i);
|
ui->renderBox->removeItem(i);
|
||||||
break;
|
break;
|
||||||
@ -404,112 +406,60 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> xSettings, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportsVulkan)
|
m_oldRender = ui->renderBox->currentText();
|
||||||
{
|
|
||||||
old_Vulkan = qstr(xemu_settings->GetSetting(emu_settings::VulkanAdapter));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Remove Vulkan option from render combobox
|
|
||||||
for (int i = 0; i < ui->renderBox->count(); i++)
|
|
||||||
{
|
|
||||||
if (ui->renderBox->itemText(i) == r_Vulkan)
|
|
||||||
{
|
|
||||||
ui->renderBox->removeItem(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString oldRender = ui->renderBox->itemText(ui->renderBox->currentIndex());
|
auto setRenderer = [=](QString text)
|
||||||
|
|
||||||
auto switchGraphicsAdapter = [=](int index)
|
|
||||||
{
|
{
|
||||||
QString render = ui->renderBox->itemText(index);
|
if (text.isEmpty()) return;
|
||||||
m_isD3D12 = render == r_D3D12;
|
|
||||||
m_isVulkan = render == r_Vulkan;
|
|
||||||
ui->graphicsAdapterBox->setEnabled(m_isD3D12 || m_isVulkan);
|
|
||||||
|
|
||||||
// D3D Adapter
|
auto switchTo = [=](Render_Info renderer)
|
||||||
if (m_isD3D12)
|
|
||||||
{
|
{
|
||||||
// Reset other adapters to old config
|
// Reset other adapters to old config
|
||||||
if (supportsVulkan)
|
for (const auto& render : Render_List)
|
||||||
{
|
{
|
||||||
xemu_settings->SetSetting(emu_settings::VulkanAdapter, sstr(old_Vulkan));
|
if (renderer.name != render->name && render->has_adapters && render->supported)
|
||||||
|
{
|
||||||
|
xemu_settings->SetSetting(render->type, sstr(render->old_adapter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fill combobox with placeholder if no adapters needed
|
||||||
|
if (!renderer.has_adapters)
|
||||||
|
{
|
||||||
|
ui->graphicsAdapterBox->clear();
|
||||||
|
ui->graphicsAdapterBox->addItem(tr("Not needed for %1 renderer").arg(text));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Fill combobox
|
// Fill combobox
|
||||||
ui->graphicsAdapterBox->clear();
|
ui->graphicsAdapterBox->clear();
|
||||||
for (const auto& adapter : D3D12Adapters)
|
for (const auto& adapter : renderer.adapters)
|
||||||
{
|
{
|
||||||
ui->graphicsAdapterBox->addItem(adapter);
|
ui->graphicsAdapterBox->addItem(adapter);
|
||||||
}
|
}
|
||||||
// Reset Adapter to old config
|
// Reset Adapter to old config
|
||||||
int idx = ui->graphicsAdapterBox->findText(old_D3D12);
|
int idx = ui->graphicsAdapterBox->findText(renderer.old_adapter);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
{
|
{
|
||||||
idx = 0;
|
idx = 0;
|
||||||
if (old_D3D12.isEmpty())
|
if (renderer.old_adapter.isEmpty())
|
||||||
{
|
{
|
||||||
LOG_WARNING(RSX, "%s adapter config empty: setting to default!", sstr(r_D3D12));
|
LOG_WARNING(RSX, "%s adapter config empty: setting to default!", sstr(renderer.name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_WARNING(RSX, "Last used %s adapter not found: setting to default!", sstr(r_D3D12));
|
LOG_WARNING(RSX, "Last used %s adapter not found: setting to default!", sstr(renderer.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->graphicsAdapterBox->setCurrentIndex(idx);
|
ui->graphicsAdapterBox->setCurrentIndex(idx);
|
||||||
xemu_settings->SetSetting(emu_settings::D3D12Adapter, sstr(ui->graphicsAdapterBox->currentText()));
|
xemu_settings->SetSetting(renderer.type, sstr(ui->graphicsAdapterBox->currentText()));
|
||||||
}
|
};
|
||||||
|
|
||||||
// Vulkan Adapter
|
for (auto render : Render_List)
|
||||||
else if (m_isVulkan)
|
|
||||||
{
|
{
|
||||||
// Reset other adapters to old config
|
if (render->name == text)
|
||||||
if (supportsD3D12)
|
|
||||||
{
|
{
|
||||||
xemu_settings->SetSetting(emu_settings::D3D12Adapter, sstr(old_D3D12));
|
switchTo(*render);
|
||||||
|
ui->graphicsAdapterBox->setEnabled(render->has_adapters);
|
||||||
}
|
}
|
||||||
// Fill combobox
|
|
||||||
ui->graphicsAdapterBox->clear();
|
|
||||||
for (const auto& adapter : vulkanAdapters)
|
|
||||||
{
|
|
||||||
ui->graphicsAdapterBox->addItem(adapter);
|
|
||||||
}
|
|
||||||
// Reset Adapter to old config
|
|
||||||
int idx = ui->graphicsAdapterBox->findText(old_Vulkan);
|
|
||||||
if (idx == -1)
|
|
||||||
{
|
|
||||||
idx = 0;
|
|
||||||
if (old_Vulkan.isEmpty())
|
|
||||||
{
|
|
||||||
LOG_WARNING(RSX, "%s adapter config empty: setting to default!", sstr(r_Vulkan));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_WARNING(RSX, "Last used %s adapter not found: setting to default!", sstr(r_Vulkan));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ui->graphicsAdapterBox->setCurrentIndex(idx);
|
|
||||||
xemu_settings->SetSetting(emu_settings::VulkanAdapter, sstr(ui->graphicsAdapterBox->currentText()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Other Adapter
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Reset Adapters to old config
|
|
||||||
if (supportsD3D12)
|
|
||||||
{
|
|
||||||
xemu_settings->SetSetting(emu_settings::D3D12Adapter, sstr(old_D3D12));
|
|
||||||
}
|
|
||||||
if (supportsVulkan)
|
|
||||||
{
|
|
||||||
xemu_settings->SetSetting(emu_settings::VulkanAdapter, sstr(old_Vulkan));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill combobox with placeholder
|
|
||||||
ui->graphicsAdapterBox->clear();
|
|
||||||
ui->graphicsAdapterBox->addItem(tr("Not needed for %1 renderer").arg(render));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -518,35 +468,33 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> xSettings, const
|
|||||||
if (text.isEmpty()) return;
|
if (text.isEmpty()) return;
|
||||||
|
|
||||||
// don't set adapter if signal was created by switching render
|
// don't set adapter if signal was created by switching render
|
||||||
QString newRender = ui->renderBox->itemText(ui->renderBox->currentIndex());
|
QString newRender = ui->renderBox->currentText();
|
||||||
if (m_oldRender == newRender)
|
if (m_oldRender != newRender)
|
||||||
{
|
|
||||||
if (m_isD3D12 && D3D12Adapters.contains(text))
|
|
||||||
{
|
|
||||||
xemu_settings->SetSetting(emu_settings::D3D12Adapter, sstr(text));
|
|
||||||
}
|
|
||||||
else if (m_isVulkan && vulkanAdapters.contains(text))
|
|
||||||
{
|
|
||||||
xemu_settings->SetSetting(emu_settings::VulkanAdapter, sstr(text));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
m_oldRender = newRender;
|
m_oldRender = newRender;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const auto& render : Render_List)
|
||||||
|
{
|
||||||
|
if (render->name == newRender && render->has_adapters && render->adapters.contains(text))
|
||||||
|
{
|
||||||
|
xemu_settings->SetSetting(render->type, sstr(text));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
|
setRenderer(ui->renderBox->currentText());
|
||||||
setAdapter(ui->graphicsAdapterBox->currentText());
|
setAdapter(ui->graphicsAdapterBox->currentText());
|
||||||
switchGraphicsAdapter(ui->renderBox->currentIndex());
|
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
connect(ui->graphicsAdapterBox, &QComboBox::currentTextChanged, setAdapter);
|
connect(ui->graphicsAdapterBox, &QComboBox::currentTextChanged, setAdapter);
|
||||||
connect(ui->renderBox, static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged), switchGraphicsAdapter);
|
connect(ui->renderBox, &QComboBox::currentTextChanged, setRenderer);
|
||||||
|
|
||||||
auto fixGLLegacy = [=](const QString& text)
|
auto fixGLLegacy = [=](const QString& text)
|
||||||
{
|
{
|
||||||
ui->glLegacyBuffers->setEnabled(text == r_OpenGL);
|
ui->glLegacyBuffers->setEnabled(text == m_OpenGL.name);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle connects to disable specific checkboxes that depend on GUI state.
|
// Handle connects to disable specific checkboxes that depend on GUI state.
|
||||||
|
@ -15,6 +15,21 @@ namespace Ui
|
|||||||
class settings_dialog;
|
class settings_dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Render_Info
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
QString old_adapter;
|
||||||
|
QStringList adapters;
|
||||||
|
emu_settings::SettingsType type;
|
||||||
|
bool supported = true;
|
||||||
|
bool has_adapters = true;
|
||||||
|
|
||||||
|
Render_Info(){};
|
||||||
|
Render_Info(const QString& name) : name(name), has_adapters(false){};
|
||||||
|
Render_Info(const QString& name, const QStringList& adapters, bool supported, const emu_settings::SettingsType& type)
|
||||||
|
: name(name), adapters(adapters), supported(supported), type(type) {};
|
||||||
|
};
|
||||||
|
|
||||||
class settings_dialog : public QDialog
|
class settings_dialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -40,8 +55,11 @@ private:
|
|||||||
QString m_currentConfig;
|
QString m_currentConfig;
|
||||||
//gpu tab
|
//gpu tab
|
||||||
QString m_oldRender = "";
|
QString m_oldRender = "";
|
||||||
bool m_isD3D12 = false;
|
|
||||||
bool m_isVulkan = false;
|
Render_Info m_D3D12;
|
||||||
|
Render_Info m_Vulkan;
|
||||||
|
Render_Info m_OpenGL;
|
||||||
|
Render_Info m_NullRender;
|
||||||
|
|
||||||
int m_tab_Index;
|
int m_tab_Index;
|
||||||
Ui::settings_dialog *ui;
|
Ui::settings_dialog *ui;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user