2020-07-11 15:26:36 +02: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 13:06:04 +02:00
|
|
|
#include <QMessageBox>
|
2020-07-11 15:26:36 +02:00
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/core.h"
|
|
|
|
#include "core/settings.h"
|
|
|
|
#include "ui_configure_cpu.h"
|
|
|
|
#include "yuzu/configuration/configure_cpu.h"
|
|
|
|
|
|
|
|
ConfigureCpu::ConfigureCpu(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureCpu) {
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
SetConfiguration();
|
2020-07-11 17:25:49 +02:00
|
|
|
|
2020-07-12 13:06:04 +02:00
|
|
|
connect(ui->accuracy, qOverload<int>(&QComboBox::activated), this,
|
|
|
|
&ConfigureCpu::AccuracyUpdated);
|
2020-08-16 14:19:55 +02:00
|
|
|
connect(ui->accuracy, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
|
|
|
&ConfigureCpu::UpdateGroup);
|
2020-07-11 15:26:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigureCpu::~ConfigureCpu() = default;
|
|
|
|
|
|
|
|
void ConfigureCpu::SetConfiguration() {
|
|
|
|
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn();
|
|
|
|
|
2020-07-11 17:25:49 +02:00
|
|
|
ui->accuracy->setEnabled(runtime_lock);
|
|
|
|
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy));
|
2020-08-16 14:19:55 +02:00
|
|
|
UpdateGroup(static_cast<int>(Settings::values.cpu_accuracy));
|
|
|
|
|
|
|
|
ui->cpuopt_unsafe_unfuse_fma->setEnabled(runtime_lock);
|
|
|
|
ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma);
|
|
|
|
ui->cpuopt_unsafe_reduce_fp_error->setEnabled(runtime_lock);
|
|
|
|
ui->cpuopt_unsafe_reduce_fp_error->setChecked(Settings::values.cpuopt_unsafe_reduce_fp_error);
|
2020-07-11 15:26:36 +02:00
|
|
|
}
|
|
|
|
|
2020-07-12 13:06:04 +02:00
|
|
|
void ConfigureCpu::AccuracyUpdated(int index) {
|
|
|
|
if (static_cast<Settings::CPUAccuracy>(index) == Settings::CPUAccuracy::DebugMode) {
|
|
|
|
const auto result = QMessageBox::warning(this, tr("Setting CPU to Debug Mode"),
|
|
|
|
tr("CPU Debug Mode is only intended for developer "
|
|
|
|
"use. Are you sure you want to enable this?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (result == QMessageBox::No) {
|
|
|
|
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::CPUAccuracy::Accurate));
|
2020-08-16 14:19:55 +02:00
|
|
|
UpdateGroup(static_cast<int>(Settings::CPUAccuracy::Accurate));
|
2020-07-12 13:06:04 +02:00
|
|
|
}
|
2020-07-11 17:25:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 14:19:55 +02:00
|
|
|
void ConfigureCpu::UpdateGroup(int index) {
|
|
|
|
ui->unsafe_group->setVisible(static_cast<Settings::CPUAccuracy>(index) ==
|
|
|
|
Settings::CPUAccuracy::Unsafe);
|
|
|
|
}
|
|
|
|
|
2020-07-11 15:26:36 +02:00
|
|
|
void ConfigureCpu::ApplyConfiguration() {
|
2020-07-11 17:25:49 +02:00
|
|
|
Settings::values.cpu_accuracy =
|
|
|
|
static_cast<Settings::CPUAccuracy>(ui->accuracy->currentIndex());
|
2020-08-16 14:19:55 +02:00
|
|
|
Settings::values.cpuopt_unsafe_unfuse_fma = ui->cpuopt_unsafe_unfuse_fma->isChecked();
|
|
|
|
Settings::values.cpuopt_unsafe_reduce_fp_error = ui->cpuopt_unsafe_reduce_fp_error->isChecked();
|
2020-07-11 15:26:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureCpu::changeEvent(QEvent* event) {
|
|
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
|
|
RetranslateUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureCpu::RetranslateUI() {
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|