2020-07-11 14:26:36 +01:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QComboBox>
|
2020-07-12 12:06:04 +01:00
|
|
|
#include <QMessageBox>
|
2020-07-11 14:26:36 +01:00
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/logging/log.h"
|
2021-04-15 00:07:40 +01:00
|
|
|
#include "common/settings.h"
|
2020-07-11 14:26:36 +01:00
|
|
|
#include "core/core.h"
|
|
|
|
#include "ui_configure_cpu.h"
|
2021-05-16 04:53:36 +01:00
|
|
|
#include "yuzu/configuration/configuration_shared.h"
|
2020-07-11 14:26:36 +01:00
|
|
|
#include "yuzu/configuration/configure_cpu.h"
|
|
|
|
|
2021-07-30 15:07:32 +01:00
|
|
|
ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent)
|
2021-10-15 20:26:20 +01:00
|
|
|
: QWidget(parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_} {
|
2020-07-11 14:26:36 +01:00
|
|
|
ui->setupUi(this);
|
|
|
|
|
2021-05-16 04:53:36 +01:00
|
|
|
SetupPerGameUI();
|
|
|
|
|
2020-07-11 14:26:36 +01:00
|
|
|
SetConfiguration();
|
2020-07-11 16:25:49 +01:00
|
|
|
|
2020-08-16 13:19:55 +01:00
|
|
|
connect(ui->accuracy, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
|
|
|
&ConfigureCpu::UpdateGroup);
|
2020-07-11 14:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigureCpu::~ConfigureCpu() = default;
|
|
|
|
|
|
|
|
void ConfigureCpu::SetConfiguration() {
|
2021-09-03 02:40:55 +01:00
|
|
|
const bool runtime_lock = !system.IsPoweredOn();
|
2020-07-11 14:26:36 +01:00
|
|
|
|
2020-07-11 16:25:49 +01:00
|
|
|
ui->accuracy->setEnabled(runtime_lock);
|
2020-08-16 13:19:55 +01:00
|
|
|
ui->cpuopt_unsafe_unfuse_fma->setEnabled(runtime_lock);
|
|
|
|
ui->cpuopt_unsafe_reduce_fp_error->setEnabled(runtime_lock);
|
2021-06-20 19:40:02 +01:00
|
|
|
ui->cpuopt_unsafe_ignore_standard_fpcr->setEnabled(runtime_lock);
|
2021-05-16 04:53:36 +01:00
|
|
|
ui->cpuopt_unsafe_inaccurate_nan->setEnabled(runtime_lock);
|
2021-06-06 08:57:24 +01:00
|
|
|
ui->cpuopt_unsafe_fastmem_check->setEnabled(runtime_lock);
|
2021-05-16 04:53:36 +01:00
|
|
|
|
|
|
|
ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma.GetValue());
|
2021-05-16 01:46:48 +01:00
|
|
|
ui->cpuopt_unsafe_reduce_fp_error->setChecked(
|
|
|
|
Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue());
|
2021-06-20 19:40:02 +01:00
|
|
|
ui->cpuopt_unsafe_ignore_standard_fpcr->setChecked(
|
|
|
|
Settings::values.cpuopt_unsafe_ignore_standard_fpcr.GetValue());
|
2021-05-16 01:46:48 +01:00
|
|
|
ui->cpuopt_unsafe_inaccurate_nan->setChecked(
|
|
|
|
Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue());
|
2021-06-06 08:57:24 +01:00
|
|
|
ui->cpuopt_unsafe_fastmem_check->setChecked(
|
|
|
|
Settings::values.cpuopt_unsafe_fastmem_check.GetValue());
|
2021-05-16 04:53:36 +01:00
|
|
|
|
|
|
|
if (Settings::IsConfiguringGlobal()) {
|
|
|
|
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy.GetValue()));
|
|
|
|
} else {
|
|
|
|
ConfigurationShared::SetPerGameSetting(ui->accuracy, &Settings::values.cpu_accuracy);
|
|
|
|
ConfigurationShared::SetHighlight(ui->widget_accuracy,
|
|
|
|
!Settings::values.cpu_accuracy.UsingGlobal());
|
|
|
|
}
|
|
|
|
UpdateGroup(ui->accuracy->currentIndex());
|
2020-07-11 14:26:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 13:19:55 +01:00
|
|
|
void ConfigureCpu::UpdateGroup(int index) {
|
2021-05-20 06:11:56 +01:00
|
|
|
if (!Settings::IsConfiguringGlobal()) {
|
|
|
|
index -= ConfigurationShared::USE_GLOBAL_OFFSET;
|
2021-05-16 04:53:36 +01:00
|
|
|
}
|
2021-05-20 06:11:56 +01:00
|
|
|
const auto accuracy = static_cast<Settings::CPUAccuracy>(index);
|
|
|
|
ui->unsafe_group->setVisible(accuracy == Settings::CPUAccuracy::Unsafe);
|
2020-08-16 13:19:55 +01:00
|
|
|
}
|
|
|
|
|
2020-07-11 14:26:36 +01:00
|
|
|
void ConfigureCpu::ApplyConfiguration() {
|
2021-07-23 15:18:07 +01:00
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpu_accuracy, ui->accuracy);
|
2021-05-16 04:53:36 +01:00
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_unfuse_fma,
|
|
|
|
ui->cpuopt_unsafe_unfuse_fma,
|
|
|
|
cpuopt_unsafe_unfuse_fma);
|
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_reduce_fp_error,
|
|
|
|
ui->cpuopt_unsafe_reduce_fp_error,
|
|
|
|
cpuopt_unsafe_reduce_fp_error);
|
2021-06-20 19:40:02 +01:00
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_ignore_standard_fpcr,
|
|
|
|
ui->cpuopt_unsafe_ignore_standard_fpcr,
|
|
|
|
cpuopt_unsafe_ignore_standard_fpcr);
|
2021-05-16 04:53:36 +01:00
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_inaccurate_nan,
|
|
|
|
ui->cpuopt_unsafe_inaccurate_nan,
|
|
|
|
cpuopt_unsafe_inaccurate_nan);
|
2021-06-06 08:57:24 +01:00
|
|
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_fastmem_check,
|
|
|
|
ui->cpuopt_unsafe_fastmem_check,
|
|
|
|
cpuopt_unsafe_fastmem_check);
|
2020-07-11 14:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureCpu::changeEvent(QEvent* event) {
|
|
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
|
|
RetranslateUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureCpu::RetranslateUI() {
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
2021-05-16 04:53:36 +01:00
|
|
|
|
|
|
|
void ConfigureCpu::SetupPerGameUI() {
|
|
|
|
if (Settings::IsConfiguringGlobal()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigurationShared::SetColoredComboBox(
|
|
|
|
ui->accuracy, ui->widget_accuracy,
|
|
|
|
static_cast<u32>(Settings::values.cpu_accuracy.GetValue(true)));
|
|
|
|
|
|
|
|
ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_unfuse_fma,
|
|
|
|
Settings::values.cpuopt_unsafe_unfuse_fma,
|
|
|
|
cpuopt_unsafe_unfuse_fma);
|
|
|
|
ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_reduce_fp_error,
|
|
|
|
Settings::values.cpuopt_unsafe_reduce_fp_error,
|
|
|
|
cpuopt_unsafe_reduce_fp_error);
|
2021-06-20 19:40:02 +01:00
|
|
|
ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_ignore_standard_fpcr,
|
|
|
|
Settings::values.cpuopt_unsafe_ignore_standard_fpcr,
|
|
|
|
cpuopt_unsafe_ignore_standard_fpcr);
|
2021-05-16 04:53:36 +01:00
|
|
|
ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_inaccurate_nan,
|
|
|
|
Settings::values.cpuopt_unsafe_inaccurate_nan,
|
|
|
|
cpuopt_unsafe_inaccurate_nan);
|
2021-06-06 08:57:24 +01:00
|
|
|
ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_fastmem_check,
|
|
|
|
Settings::values.cpuopt_unsafe_fastmem_check,
|
|
|
|
cpuopt_unsafe_fastmem_check);
|
2021-05-16 04:53:36 +01:00
|
|
|
}
|