mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 05:40:06 +00:00
dynarmic: Add unsafe optimizations
This commit is contained in:
parent
db96034ea4
commit
836ec9176a
2
externals/dynarmic
vendored
2
externals/dynarmic
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 82417da7803e2cf18efc28a1cd3f3d0a4b6045ae
|
Subproject commit 0e1112b7df77ae55a62a51622940d5c8f9e8c84c
|
@ -143,7 +143,7 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable&
|
|||||||
config.wall_clock_cntpct = uses_wall_clock;
|
config.wall_clock_cntpct = uses_wall_clock;
|
||||||
|
|
||||||
// Safe optimizations
|
// Safe optimizations
|
||||||
if (Settings::values.cpu_accuracy != Settings::CPUAccuracy::Accurate) {
|
if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::DebugMode) {
|
||||||
if (!Settings::values.cpuopt_page_tables) {
|
if (!Settings::values.cpuopt_page_tables) {
|
||||||
config.page_table = nullptr;
|
config.page_table = nullptr;
|
||||||
}
|
}
|
||||||
@ -170,6 +170,17 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unsafe optimizations
|
||||||
|
if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::Unsafe) {
|
||||||
|
config.unsafe_optimizations = true;
|
||||||
|
if (Settings::values.cpuopt_unsafe_unfuse_fma) {
|
||||||
|
config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_UnfuseFMA;
|
||||||
|
}
|
||||||
|
if (Settings::values.cpuopt_unsafe_reduce_fp_error) {
|
||||||
|
config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_ReducedErrorFP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_unique<Dynarmic::A32::Jit>(config);
|
return std::make_unique<Dynarmic::A32::Jit>(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable&
|
|||||||
config.wall_clock_cntpct = uses_wall_clock;
|
config.wall_clock_cntpct = uses_wall_clock;
|
||||||
|
|
||||||
// Safe optimizations
|
// Safe optimizations
|
||||||
if (Settings::values.cpu_accuracy != Settings::CPUAccuracy::Accurate) {
|
if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::DebugMode) {
|
||||||
if (!Settings::values.cpuopt_page_tables) {
|
if (!Settings::values.cpuopt_page_tables) {
|
||||||
config.page_table = nullptr;
|
config.page_table = nullptr;
|
||||||
}
|
}
|
||||||
@ -222,6 +222,17 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unsafe optimizations
|
||||||
|
if (Settings::values.cpu_accuracy == Settings::CPUAccuracy::Unsafe) {
|
||||||
|
config.unsafe_optimizations = true;
|
||||||
|
if (Settings::values.cpuopt_unsafe_unfuse_fma) {
|
||||||
|
config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_UnfuseFMA;
|
||||||
|
}
|
||||||
|
if (Settings::values.cpuopt_unsafe_reduce_fp_error) {
|
||||||
|
config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_ReducedErrorFP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_shared<Dynarmic::A64::Jit>(config);
|
return std::make_shared<Dynarmic::A64::Jit>(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,8 @@ enum class GPUAccuracy : u32 {
|
|||||||
|
|
||||||
enum class CPUAccuracy {
|
enum class CPUAccuracy {
|
||||||
Accurate = 0,
|
Accurate = 0,
|
||||||
DebugMode = 1,
|
Unsafe = 1,
|
||||||
|
DebugMode = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool configuring_global;
|
extern bool configuring_global;
|
||||||
@ -419,6 +420,9 @@ struct Values {
|
|||||||
bool cpuopt_misc_ir;
|
bool cpuopt_misc_ir;
|
||||||
bool cpuopt_reduce_misalign_checks;
|
bool cpuopt_reduce_misalign_checks;
|
||||||
|
|
||||||
|
bool cpuopt_unsafe_unfuse_fma;
|
||||||
|
bool cpuopt_unsafe_reduce_fp_error;
|
||||||
|
|
||||||
// Renderer
|
// Renderer
|
||||||
Setting<RendererBackend> renderer_backend;
|
Setting<RendererBackend> renderer_backend;
|
||||||
bool renderer_debug;
|
bool renderer_debug;
|
||||||
|
@ -638,6 +638,11 @@ void Config::ReadCpuValues() {
|
|||||||
ReadSetting(QStringLiteral("cpuopt_misc_ir"), true).toBool();
|
ReadSetting(QStringLiteral("cpuopt_misc_ir"), true).toBool();
|
||||||
Settings::values.cpuopt_reduce_misalign_checks =
|
Settings::values.cpuopt_reduce_misalign_checks =
|
||||||
ReadSetting(QStringLiteral("cpuopt_reduce_misalign_checks"), true).toBool();
|
ReadSetting(QStringLiteral("cpuopt_reduce_misalign_checks"), true).toBool();
|
||||||
|
|
||||||
|
Settings::values.cpuopt_unsafe_unfuse_fma =
|
||||||
|
ReadSetting(QStringLiteral("cpuopt_unsafe_unfuse_fma"), true).toBool();
|
||||||
|
Settings::values.cpuopt_unsafe_reduce_fp_error =
|
||||||
|
ReadSetting(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
@ -1135,6 +1140,11 @@ void Config::SaveCpuValues() {
|
|||||||
WriteSetting(QStringLiteral("cpuopt_misc_ir"), Settings::values.cpuopt_misc_ir, true);
|
WriteSetting(QStringLiteral("cpuopt_misc_ir"), Settings::values.cpuopt_misc_ir, true);
|
||||||
WriteSetting(QStringLiteral("cpuopt_reduce_misalign_checks"),
|
WriteSetting(QStringLiteral("cpuopt_reduce_misalign_checks"),
|
||||||
Settings::values.cpuopt_reduce_misalign_checks, true);
|
Settings::values.cpuopt_reduce_misalign_checks, true);
|
||||||
|
|
||||||
|
WriteSetting(QStringLiteral("cpuopt_unsafe_unfuse_fma"),
|
||||||
|
Settings::values.cpuopt_unsafe_unfuse_fma, true);
|
||||||
|
WriteSetting(QStringLiteral("cpuopt_unsafe_reduce_fp_error"),
|
||||||
|
Settings::values.cpuopt_unsafe_reduce_fp_error, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
|
@ -19,6 +19,8 @@ ConfigureCpu::ConfigureCpu(QWidget* parent) : QWidget(parent), ui(new Ui::Config
|
|||||||
|
|
||||||
connect(ui->accuracy, qOverload<int>(&QComboBox::activated), this,
|
connect(ui->accuracy, qOverload<int>(&QComboBox::activated), this,
|
||||||
&ConfigureCpu::AccuracyUpdated);
|
&ConfigureCpu::AccuracyUpdated);
|
||||||
|
connect(ui->accuracy, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||||
|
&ConfigureCpu::UpdateGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureCpu::~ConfigureCpu() = default;
|
ConfigureCpu::~ConfigureCpu() = default;
|
||||||
@ -28,6 +30,12 @@ void ConfigureCpu::SetConfiguration() {
|
|||||||
|
|
||||||
ui->accuracy->setEnabled(runtime_lock);
|
ui->accuracy->setEnabled(runtime_lock);
|
||||||
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy));
|
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy));
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureCpu::AccuracyUpdated(int index) {
|
void ConfigureCpu::AccuracyUpdated(int index) {
|
||||||
@ -38,14 +46,21 @@ void ConfigureCpu::AccuracyUpdated(int index) {
|
|||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
if (result == QMessageBox::No) {
|
if (result == QMessageBox::No) {
|
||||||
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::CPUAccuracy::Accurate));
|
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::CPUAccuracy::Accurate));
|
||||||
return;
|
UpdateGroup(static_cast<int>(Settings::CPUAccuracy::Accurate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigureCpu::UpdateGroup(int index) {
|
||||||
|
ui->unsafe_group->setVisible(static_cast<Settings::CPUAccuracy>(index) ==
|
||||||
|
Settings::CPUAccuracy::Unsafe);
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigureCpu::ApplyConfiguration() {
|
void ConfigureCpu::ApplyConfiguration() {
|
||||||
Settings::values.cpu_accuracy =
|
Settings::values.cpu_accuracy =
|
||||||
static_cast<Settings::CPUAccuracy>(ui->accuracy->currentIndex());
|
static_cast<Settings::CPUAccuracy>(ui->accuracy->currentIndex());
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureCpu::changeEvent(QEvent* event) {
|
void ConfigureCpu::changeEvent(QEvent* event) {
|
||||||
|
@ -26,6 +26,7 @@ private:
|
|||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
|
|
||||||
void AccuracyUpdated(int index);
|
void AccuracyUpdated(int index);
|
||||||
|
void UpdateGroup(int index);
|
||||||
|
|
||||||
void SetConfiguration();
|
void SetConfiguration();
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@
|
|||||||
<string>Accurate</string>
|
<string>Accurate</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Unsafe</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable Debug Mode</string>
|
<string>Enable Debug Mode</string>
|
||||||
@ -62,6 +67,53 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="unsafe_group">
|
||||||
|
<property name="title">
|
||||||
|
<string>Unsafe CPU Optimization Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>1</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>These settings reduce accuracy for speed.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cpuopt_unsafe_unfuse_fma">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unfuse FMA (improve performance on CPUs without FMA)</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>
|
||||||
|
<div>This option improves speed by reducing accuracy of fused-multiply-add instructions on CPUs without native FMA support.</div>
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cpuopt_unsafe_reduce_fp_error">
|
||||||
|
<property name="text">
|
||||||
|
<string>Faster FRSQRTE and FRECPE</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>
|
||||||
|
<div>This option improves the speed of some approximate floating-point functions by using less accurate native approximations.</div>
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
Reference in New Issue
Block a user