mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-22 14:28:57 +02:00
[common] merge RenderBackend and ShaderBackend options (#3313)
first of all it makes UI a tad bit more simple and benefits the end user second, it allows to add new backends a bit more easily and also, there was a shader backend option in android... we don't use opengl in android so may as well save ourselves the trouble, aye  Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3313 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: DraVee <dravee@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
ed0276582e
commit
291b5febec
45 changed files with 133 additions and 351 deletions
|
|
@ -91,9 +91,8 @@ ConfigureGraphics::ConfigureGraphics(
|
|||
: ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
|
||||
records{records_}, expose_compute_option{expose_compute_option_},
|
||||
update_aspect_ratio{update_aspect_ratio_}, system{system_},
|
||||
combobox_translations{builder.ComboboxTranslations()},
|
||||
shader_mapping{
|
||||
combobox_translations.at(Settings::EnumMetadata<Settings::ShaderBackend>::Index())} {
|
||||
combobox_translations{builder.ComboboxTranslations()}
|
||||
{
|
||||
vulkan_device = Settings::values.vulkan_device.GetValue();
|
||||
RetrieveVulkanDevices();
|
||||
|
||||
|
|
@ -134,9 +133,6 @@ ConfigureGraphics::ConfigureGraphics(
|
|||
UpdateDeviceSelection(device);
|
||||
PopulateVSyncModeSelection(false);
|
||||
});
|
||||
connect(shader_backend_combobox, qOverload<int>(&QComboBox::activated), this,
|
||||
[this](int backend) { UpdateShaderBackendSelection(backend); });
|
||||
|
||||
connect(ui->bg_button, &QPushButton::clicked, this, [this] {
|
||||
const QColor new_bg_color = QColorDialog::getColor(bg_color);
|
||||
if (!new_bg_color.isValid()) {
|
||||
|
|
@ -219,7 +215,9 @@ void ConfigureGraphics::PopulateVSyncModeSelection(bool use_setting) {
|
|||
|
||||
const Settings::VSyncMode global_vsync_mode = Settings::values.vsync_mode.GetValue(true);
|
||||
vsync_restore_global_button->setEnabled(
|
||||
(backend == Settings::RendererBackend::OpenGL &&
|
||||
((backend == Settings::RendererBackend::OpenGL_GLSL
|
||||
|| backend == Settings::RendererBackend::OpenGL_GLASM
|
||||
|| backend == Settings::RendererBackend::OpenGL_SPIRV) &&
|
||||
(global_vsync_mode == Settings::VSyncMode::Immediate ||
|
||||
global_vsync_mode == Settings::VSyncMode::Fifo)) ||
|
||||
backend == Settings::RendererBackend::Vulkan);
|
||||
|
|
@ -246,15 +244,6 @@ void ConfigureGraphics::UpdateDeviceSelection(int device) {
|
|||
}
|
||||
}
|
||||
|
||||
void ConfigureGraphics::UpdateShaderBackendSelection(int backend) {
|
||||
if (backend == -1) {
|
||||
return;
|
||||
}
|
||||
if (GetCurrentGraphicsBackend() == Settings::RendererBackend::OpenGL) {
|
||||
shader_backend = static_cast<Settings::ShaderBackend>(backend);
|
||||
}
|
||||
}
|
||||
|
||||
ConfigureGraphics::~ConfigureGraphics() = default;
|
||||
|
||||
void ConfigureGraphics::SetConfiguration() {}
|
||||
|
|
@ -296,14 +285,11 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
|
|||
api_grid_layout->addWidget(widget);
|
||||
api_combobox = widget->combobox;
|
||||
api_restore_global_button = widget->restore_button;
|
||||
|
||||
if (!Settings::IsConfiguringGlobal()) {
|
||||
api_restore_global_button->connect(api_restore_global_button, &QAbstractButton::clicked,
|
||||
[this](bool) { UpdateAPILayout(); });
|
||||
|
||||
api_restore_global_button->connect(api_restore_global_button, &QAbstractButton::clicked, [this](bool) { UpdateAPILayout(); });
|
||||
// Detach API's restore button and place it where we want
|
||||
// Lets us put it on the side, and it will automatically scale if there's a
|
||||
// second combobox (shader_backend, vulkan_device)
|
||||
// second combobox (vulkan_device)
|
||||
widget->layout()->removeWidget(api_restore_global_button);
|
||||
api_layout->addWidget(api_restore_global_button);
|
||||
}
|
||||
|
|
@ -312,11 +298,6 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
|
|||
hold_api.push_back(widget);
|
||||
vulkan_device_combobox = widget->combobox;
|
||||
vulkan_device_widget = widget;
|
||||
} else if (setting->Id() == Settings::values.shader_backend.Id()) {
|
||||
// Keep track of shader_backend's combobox so we can populate it
|
||||
hold_api.push_back(widget);
|
||||
shader_backend_combobox = widget->combobox;
|
||||
shader_backend_widget = widget;
|
||||
} else if (setting->Id() == Settings::values.vsync_mode.Id()) {
|
||||
// Keep track of vsync_mode's combobox so we can populate it
|
||||
vsync_mode_combobox = widget->combobox;
|
||||
|
|
@ -416,20 +397,21 @@ const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode,
|
|||
Settings::RendererBackend backend) const {
|
||||
switch (mode) {
|
||||
case VK_PRESENT_MODE_IMMEDIATE_KHR:
|
||||
return backend == Settings::RendererBackend::OpenGL
|
||||
? tr("Off")
|
||||
: QStringLiteral("Immediate (%1)").arg(tr("VSync Off"));
|
||||
return (backend == Settings::RendererBackend::OpenGL_GLSL
|
||||
|| backend == Settings::RendererBackend::OpenGL_GLASM
|
||||
|| backend == Settings::RendererBackend::OpenGL_SPIRV)
|
||||
? tr("Off") : QStringLiteral("Immediate (%1)").arg(tr("VSync Off"));
|
||||
case VK_PRESENT_MODE_MAILBOX_KHR:
|
||||
return QStringLiteral("Mailbox (%1)").arg(tr("Recommended"));
|
||||
case VK_PRESENT_MODE_FIFO_KHR:
|
||||
return backend == Settings::RendererBackend::OpenGL
|
||||
? tr("On")
|
||||
: QStringLiteral("FIFO (%1)").arg(tr("VSync On"));
|
||||
return (backend == Settings::RendererBackend::OpenGL_GLSL
|
||||
|| backend == Settings::RendererBackend::OpenGL_GLASM
|
||||
|| backend == Settings::RendererBackend::OpenGL_SPIRV)
|
||||
? tr("On") : QStringLiteral("FIFO (%1)").arg(tr("VSync On"));
|
||||
case VK_PRESENT_MODE_FIFO_RELAXED_KHR:
|
||||
return QStringLiteral("FIFO Relaxed");
|
||||
default:
|
||||
return {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -451,7 +433,6 @@ void ConfigureGraphics::ApplyConfiguration() {
|
|||
UpdateVsyncSetting();
|
||||
|
||||
Settings::values.vulkan_device.SetGlobal(true);
|
||||
Settings::values.shader_backend.SetGlobal(true);
|
||||
if (Settings::IsConfiguringGlobal() ||
|
||||
(!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) {
|
||||
auto backend = static_cast<Settings::RendererBackend>(
|
||||
|
|
@ -460,15 +441,13 @@ void ConfigureGraphics::ApplyConfiguration() {
|
|||
Settings::RendererBackend>::Index())[api_combobox->currentIndex()]
|
||||
.first);
|
||||
switch (backend) {
|
||||
case Settings::RendererBackend::OpenGL:
|
||||
Settings::values.shader_backend.SetGlobal(Settings::IsConfiguringGlobal());
|
||||
Settings::values.shader_backend.SetValue(static_cast<Settings::ShaderBackend>(
|
||||
shader_mapping[shader_backend_combobox->currentIndex()].first));
|
||||
break;
|
||||
case Settings::RendererBackend::Vulkan:
|
||||
Settings::values.vulkan_device.SetGlobal(Settings::IsConfiguringGlobal());
|
||||
Settings::values.vulkan_device.SetValue(vulkan_device_combobox->currentIndex());
|
||||
break;
|
||||
case Settings::RendererBackend::OpenGL_GLSL:
|
||||
case Settings::RendererBackend::OpenGL_SPIRV:
|
||||
case Settings::RendererBackend::OpenGL_GLASM:
|
||||
case Settings::RendererBackend::Null:
|
||||
break;
|
||||
}
|
||||
|
|
@ -501,22 +480,12 @@ void ConfigureGraphics::UpdateAPILayout() {
|
|||
bool runtime_lock = !system.IsPoweredOn();
|
||||
bool need_global = !(Settings::IsConfiguringGlobal() || api_restore_global_button->isEnabled());
|
||||
vulkan_device = Settings::values.vulkan_device.GetValue(need_global);
|
||||
shader_backend = Settings::values.shader_backend.GetValue(need_global);
|
||||
vulkan_device_widget->setEnabled(!need_global && runtime_lock);
|
||||
shader_backend_widget->setEnabled(!need_global && runtime_lock);
|
||||
|
||||
const auto current_backend = GetCurrentGraphicsBackend();
|
||||
const bool is_opengl = current_backend == Settings::RendererBackend::OpenGL;
|
||||
const bool is_vulkan = current_backend == Settings::RendererBackend::Vulkan;
|
||||
|
||||
vulkan_device_widget->setVisible(is_vulkan);
|
||||
shader_backend_widget->setVisible(is_opengl);
|
||||
|
||||
if (is_opengl) {
|
||||
shader_backend_combobox->setCurrentIndex(
|
||||
FindIndex(Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
|
||||
static_cast<int>(shader_backend)));
|
||||
} else if (is_vulkan && static_cast<int>(vulkan_device) < vulkan_device_combobox->count()) {
|
||||
if (is_vulkan && int(vulkan_device) < vulkan_device_combobox->count()) {
|
||||
vulkan_device_combobox->setCurrentIndex(vulkan_device);
|
||||
}
|
||||
}
|
||||
|
|
@ -541,15 +510,13 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
|||
if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) {
|
||||
return Settings::values.renderer_backend.GetValue(true);
|
||||
}
|
||||
return static_cast<Settings::RendererBackend>(
|
||||
return Settings::RendererBackend(
|
||||
combobox_translations.at(Settings::EnumMetadata<Settings::RendererBackend>::Index())
|
||||
.at(api_combobox->currentIndex())
|
||||
.first);
|
||||
}();
|
||||
|
||||
if (selected_backend == Settings::RendererBackend::Vulkan &&
|
||||
UISettings::values.has_broken_vulkan) {
|
||||
return Settings::RendererBackend::OpenGL;
|
||||
}
|
||||
if (selected_backend == Settings::RendererBackend::Vulkan && UISettings::values.has_broken_vulkan)
|
||||
return Settings::RendererBackend::OpenGL_GLSL;
|
||||
return selected_backend;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue