2016-08-25 04:15:38 +02:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-08-02 05:36:47 +02:00
|
|
|
#include <QColorDialog>
|
2018-07-17 04:03:32 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <QMessageBox>
|
|
|
|
#endif
|
2022-12-08 12:27:25 +01:00
|
|
|
#include "citra_qt/configuration/configuration_shared.h"
|
2016-12-22 05:49:36 +01:00
|
|
|
#include "citra_qt/configuration/configure_graphics.h"
|
2022-12-08 12:27:25 +01:00
|
|
|
#include "common/settings.h"
|
2016-12-16 01:01:48 +01:00
|
|
|
#include "core/core.h"
|
2016-09-20 17:21:23 +02:00
|
|
|
#include "ui_configure_graphics.h"
|
2016-08-25 04:15:38 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
ConfigureGraphics::ConfigureGraphics(QWidget* parent)
|
2020-10-01 03:23:01 +02:00
|
|
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureGraphics>()) {
|
2016-08-25 04:15:38 +02:00
|
|
|
ui->setupUi(this);
|
2022-12-08 12:27:25 +01:00
|
|
|
|
2019-12-15 23:42:05 +01:00
|
|
|
ui->toggle_vsync_new->setEnabled(!Core::System::GetInstance().IsPoweredOn());
|
2023-03-27 13:29:17 +02:00
|
|
|
// Set the index to -1 to ensure the below lambda is called with setCurrentIndex
|
|
|
|
ui->graphics_api_combo->setCurrentIndex(-1);
|
2019-12-15 23:42:05 +01:00
|
|
|
|
2023-03-27 13:29:17 +02:00
|
|
|
connect(ui->graphics_api_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
|
|
|
[this](int index) {
|
|
|
|
const auto graphics_api =
|
|
|
|
ConfigurationShared::GetComboboxSetting(index, &Settings::values.graphics_api);
|
|
|
|
const bool is_software = graphics_api == Settings::GraphicsAPI::Software;
|
2019-08-07 20:21:47 +02:00
|
|
|
|
2023-03-27 13:29:17 +02:00
|
|
|
ui->hw_renderer_group->setEnabled(!is_software);
|
|
|
|
ui->toggle_disk_shader_cache->setEnabled(!is_software &&
|
|
|
|
ui->toggle_hw_shader->isChecked());
|
|
|
|
});
|
2020-11-06 19:07:59 +01:00
|
|
|
|
|
|
|
connect(ui->toggle_hw_shader, &QCheckBox::toggled, this, [this] {
|
2022-12-08 12:27:25 +01:00
|
|
|
const bool checked = ui->toggle_hw_shader->isChecked();
|
2021-05-16 10:45:02 +02:00
|
|
|
ui->hw_shader_group->setEnabled(checked);
|
|
|
|
ui->toggle_disk_shader_cache->setEnabled(checked);
|
2020-11-06 19:07:59 +01:00
|
|
|
});
|
|
|
|
|
2018-07-17 04:03:32 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
connect(ui->toggle_hw_shader, &QCheckBox::stateChanged, this, [this](int state) {
|
2020-04-18 13:37:58 +02:00
|
|
|
if (state == Qt::Checked) {
|
2020-04-18 15:55:19 +02:00
|
|
|
ui->toggle_separable_shader->setEnabled(true);
|
2020-04-18 13:37:58 +02:00
|
|
|
}
|
|
|
|
});
|
2020-04-18 15:55:19 +02:00
|
|
|
connect(ui->toggle_separable_shader, &QCheckBox::stateChanged, this, [this](int state) {
|
2018-07-17 04:03:32 +02:00
|
|
|
if (state == Qt::Checked) {
|
|
|
|
QMessageBox::warning(
|
|
|
|
this, tr("Hardware Shader Warning"),
|
2020-05-04 12:14:40 +02:00
|
|
|
tr("Separable Shader support is broken on macOS with Intel GPUs, and will cause "
|
|
|
|
"graphical issues "
|
2018-07-17 04:03:32 +02:00
|
|
|
"like showing a black screen.<br><br>The option is only there for "
|
|
|
|
"test/development purposes. If you experience graphical issues with Hardware "
|
|
|
|
"Shader, please turn it off."));
|
|
|
|
}
|
|
|
|
});
|
2020-04-18 13:37:58 +02:00
|
|
|
#else
|
|
|
|
// TODO(B3N30): Hide this for macs with none Intel GPUs, too.
|
2020-04-18 15:55:19 +02:00
|
|
|
ui->toggle_separable_shader->setVisible(false);
|
2018-07-17 04:03:32 +02:00
|
|
|
#endif
|
2023-03-27 13:29:17 +02:00
|
|
|
|
|
|
|
SetupPerGameUI();
|
|
|
|
SetConfiguration();
|
2016-08-25 04:15:38 +02:00
|
|
|
}
|
|
|
|
|
2018-08-24 17:14:09 +02:00
|
|
|
ConfigureGraphics::~ConfigureGraphics() = default;
|
2016-08-25 04:15:38 +02:00
|
|
|
|
2019-05-26 06:39:23 +02:00
|
|
|
void ConfigureGraphics::SetConfiguration() {
|
2023-03-27 13:29:17 +02:00
|
|
|
if (!Settings::IsConfiguringGlobal()) {
|
|
|
|
ConfigurationShared::SetHighlight(ui->graphics_api_group,
|
|
|
|
!Settings::values.graphics_api.UsingGlobal());
|
|
|
|
ConfigurationShared::SetPerGameSetting(ui->graphics_api_combo,
|
|
|
|
&Settings::values.graphics_api);
|
|
|
|
} else {
|
|
|
|
ui->graphics_api_combo->setCurrentIndex(
|
|
|
|
static_cast<int>(Settings::values.graphics_api.GetValue()));
|
|
|
|
}
|
|
|
|
|
2022-12-08 12:27:25 +01:00
|
|
|
ui->toggle_hw_shader->setChecked(Settings::values.use_hw_shader.GetValue());
|
|
|
|
ui->toggle_separable_shader->setChecked(Settings::values.separable_shader.GetValue());
|
|
|
|
ui->toggle_accurate_mul->setChecked(Settings::values.shaders_accurate_mul.GetValue());
|
|
|
|
ui->toggle_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue());
|
|
|
|
ui->toggle_vsync_new->setChecked(Settings::values.use_vsync_new.GetValue());
|
|
|
|
|
|
|
|
if (Settings::IsConfiguringGlobal()) {
|
|
|
|
ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit.GetValue());
|
|
|
|
}
|
2016-08-25 04:15:38 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 06:39:23 +02:00
|
|
|
void ConfigureGraphics::ApplyConfiguration() {
|
2023-03-27 13:29:17 +02:00
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.graphics_api,
|
|
|
|
ui->graphics_api_combo);
|
2022-12-08 12:27:25 +01:00
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_hw_shader, ui->toggle_hw_shader,
|
|
|
|
use_hw_shader);
|
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.separable_shader,
|
|
|
|
ui->toggle_separable_shader, separable_shader);
|
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.shaders_accurate_mul,
|
|
|
|
ui->toggle_accurate_mul, shaders_accurate_mul);
|
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_disk_shader_cache,
|
|
|
|
ui->toggle_disk_shader_cache, use_disk_shader_cache);
|
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync_new, ui->toggle_vsync_new,
|
|
|
|
use_vsync_new);
|
|
|
|
|
|
|
|
if (Settings::IsConfiguringGlobal()) {
|
|
|
|
Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked();
|
|
|
|
}
|
2019-09-22 17:47:18 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 06:39:23 +02:00
|
|
|
void ConfigureGraphics::RetranslateUI() {
|
2017-09-23 15:13:59 +02:00
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
2022-12-08 12:27:25 +01:00
|
|
|
|
|
|
|
void ConfigureGraphics::SetupPerGameUI() {
|
|
|
|
// Block the global settings if a game is currently running that overrides them
|
|
|
|
if (Settings::IsConfiguringGlobal()) {
|
2023-03-27 13:29:17 +02:00
|
|
|
ui->graphics_api_group->setEnabled(Settings::values.graphics_api.UsingGlobal());
|
2022-12-08 12:27:25 +01:00
|
|
|
ui->toggle_hw_shader->setEnabled(Settings::values.use_hw_shader.UsingGlobal());
|
|
|
|
ui->toggle_separable_shader->setEnabled(Settings::values.separable_shader.UsingGlobal());
|
|
|
|
ui->toggle_accurate_mul->setEnabled(Settings::values.shaders_accurate_mul.UsingGlobal());
|
|
|
|
ui->toggle_disk_shader_cache->setEnabled(
|
|
|
|
Settings::values.use_disk_shader_cache.UsingGlobal());
|
|
|
|
ui->toggle_vsync_new->setEnabled(Settings::values.use_vsync_new.UsingGlobal());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->toggle_shader_jit->setVisible(false);
|
|
|
|
|
2023-03-27 13:29:17 +02:00
|
|
|
ConfigurationShared::SetColoredComboBox(
|
|
|
|
ui->graphics_api_combo, ui->graphics_api_group,
|
|
|
|
static_cast<u32>(Settings::values.graphics_api.GetValue(true)));
|
|
|
|
|
2022-12-08 12:27:25 +01:00
|
|
|
ConfigurationShared::SetColoredTristate(ui->toggle_hw_shader, Settings::values.use_hw_shader,
|
|
|
|
use_hw_shader);
|
|
|
|
ConfigurationShared::SetColoredTristate(ui->toggle_separable_shader,
|
|
|
|
Settings::values.separable_shader, separable_shader);
|
|
|
|
ConfigurationShared::SetColoredTristate(
|
|
|
|
ui->toggle_accurate_mul, Settings::values.shaders_accurate_mul, shaders_accurate_mul);
|
|
|
|
ConfigurationShared::SetColoredTristate(ui->toggle_disk_shader_cache,
|
|
|
|
Settings::values.use_disk_shader_cache,
|
|
|
|
use_disk_shader_cache);
|
|
|
|
ConfigurationShared::SetColoredTristate(ui->toggle_vsync_new, Settings::values.use_vsync_new,
|
|
|
|
use_vsync_new);
|
|
|
|
}
|