Browse Source
Merge pull request #4294 from MerryMage/cpu-opt-settings
Merge pull request #4294 from MerryMage/cpu-opt-settings
configuration: Add settings to enable/disable specific CPU optimizationspull/15/merge
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 686 additions and 30 deletions
-
2externals/dynarmic
-
30src/core/arm/dynarmic/arm_dynarmic_32.cpp
-
34src/core/arm/dynarmic/arm_dynarmic_64.cpp
-
18src/core/settings.h
-
6src/yuzu/CMakeLists.txt
-
59src/yuzu/configuration/config.cpp
-
2src/yuzu/configuration/config.h
-
22src/yuzu/configuration/configure.ui
-
61src/yuzu/configuration/configure_cpu.cpp
-
33src/yuzu/configuration/configure_cpu.h
-
92src/yuzu/configuration/configure_cpu.ui
-
65src/yuzu/configuration/configure_cpu_debug.cpp
-
31src/yuzu/configuration/configure_cpu_debug.h
-
174src/yuzu/configuration/configure_cpu_debug.ui
-
2src/yuzu/configuration/configure_debug.cpp
-
7src/yuzu/configuration/configure_debug.ui
-
7src/yuzu/configuration/configure_dialog.cpp
-
2src/yuzu_cmd/config.cpp
-
36src/yuzu_cmd/default_ini.h
-
33src/yuzu_tester/default_ini.h
@ -1 +1 @@ |
|||||
Subproject commit 4f967387c07365b7ea35d2fa3e19b7df8872a09b |
|
||||
|
Subproject commit 82417da7803e2cf18efc28a1cd3f3d0a4b6045ae |
||||
@ -0,0 +1,61 @@ |
|||||
|
// Copyright 2020 yuzu Emulator Project
|
||||
|
// Licensed under GPLv2 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include <QComboBox>
|
||||
|
#include <QMessageBox>
|
||||
|
|
||||
|
#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(); |
||||
|
|
||||
|
connect(ui->accuracy, qOverload<int>(&QComboBox::activated), this, |
||||
|
&ConfigureCpu::AccuracyUpdated); |
||||
|
} |
||||
|
|
||||
|
ConfigureCpu::~ConfigureCpu() = default; |
||||
|
|
||||
|
void ConfigureCpu::SetConfiguration() { |
||||
|
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); |
||||
|
|
||||
|
ui->accuracy->setEnabled(runtime_lock); |
||||
|
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy)); |
||||
|
} |
||||
|
|
||||
|
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)); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void ConfigureCpu::ApplyConfiguration() { |
||||
|
Settings::values.cpu_accuracy = |
||||
|
static_cast<Settings::CPUAccuracy>(ui->accuracy->currentIndex()); |
||||
|
} |
||||
|
|
||||
|
void ConfigureCpu::changeEvent(QEvent* event) { |
||||
|
if (event->type() == QEvent::LanguageChange) { |
||||
|
RetranslateUI(); |
||||
|
} |
||||
|
|
||||
|
QWidget::changeEvent(event); |
||||
|
} |
||||
|
|
||||
|
void ConfigureCpu::RetranslateUI() { |
||||
|
ui->retranslateUi(this); |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright 2020 yuzu Emulator Project |
||||
|
// Licensed under GPLv2 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <memory> |
||||
|
#include <QWidget> |
||||
|
#include "core/settings.h" |
||||
|
|
||||
|
namespace Ui { |
||||
|
class ConfigureCpu; |
||||
|
} |
||||
|
|
||||
|
class ConfigureCpu : public QWidget { |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
explicit ConfigureCpu(QWidget* parent = nullptr); |
||||
|
~ConfigureCpu() override; |
||||
|
|
||||
|
void ApplyConfiguration(); |
||||
|
|
||||
|
private: |
||||
|
void changeEvent(QEvent* event) override; |
||||
|
void RetranslateUI(); |
||||
|
|
||||
|
void AccuracyUpdated(int index); |
||||
|
|
||||
|
void SetConfiguration(); |
||||
|
|
||||
|
std::unique_ptr<Ui::ConfigureCpu> ui; |
||||
|
}; |
||||
@ -0,0 +1,92 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>ConfigureCpu</class> |
||||
|
<widget class="QWidget" name="ConfigureCpu"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>400</width> |
||||
|
<height>321</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Form</string> |
||||
|
</property> |
||||
|
<layout class="QVBoxLayout"> |
||||
|
<item> |
||||
|
<layout class="QVBoxLayout"> |
||||
|
<item> |
||||
|
<widget class="QGroupBox"> |
||||
|
<property name="title"> |
||||
|
<string>General</string> |
||||
|
</property> |
||||
|
<layout class="QVBoxLayout"> |
||||
|
<item> |
||||
|
<layout class="QHBoxLayout"> |
||||
|
<item> |
||||
|
<widget class="QLabel"> |
||||
|
<property name="text"> |
||||
|
<string>Accuracy:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QComboBox" name="accuracy"> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Accurate</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Enable Debug Mode</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel"> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>1</bool> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>We recommend setting accuracy to "Accurate".</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
<item> |
||||
|
<spacer name="verticalSpacer"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Vertical</enum> |
||||
|
</property> |
||||
|
<property name="sizeHint" stdset="0"> |
||||
|
<size> |
||||
|
<width>20</width> |
||||
|
<height>40</height> |
||||
|
</size> |
||||
|
</property> |
||||
|
</spacer> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="label_disable_info"> |
||||
|
<property name="text"> |
||||
|
<string>CPU settings are available only when game is not running.</string> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections/> |
||||
|
</ui> |
||||
@ -0,0 +1,65 @@ |
|||||
|
// Copyright 2020 yuzu Emulator Project
|
||||
|
// Licensed under GPLv2 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include <QComboBox>
|
||||
|
|
||||
|
#include "common/common_types.h"
|
||||
|
#include "common/logging/log.h"
|
||||
|
#include "core/core.h"
|
||||
|
#include "core/settings.h"
|
||||
|
#include "ui_configure_cpu_debug.h"
|
||||
|
#include "yuzu/configuration/configure_cpu_debug.h"
|
||||
|
|
||||
|
ConfigureCpuDebug::ConfigureCpuDebug(QWidget* parent) |
||||
|
: QWidget(parent), ui(new Ui::ConfigureCpuDebug) { |
||||
|
ui->setupUi(this); |
||||
|
|
||||
|
SetConfiguration(); |
||||
|
} |
||||
|
|
||||
|
ConfigureCpuDebug::~ConfigureCpuDebug() = default; |
||||
|
|
||||
|
void ConfigureCpuDebug::SetConfiguration() { |
||||
|
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); |
||||
|
|
||||
|
ui->cpuopt_page_tables->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_page_tables->setChecked(Settings::values.cpuopt_page_tables); |
||||
|
ui->cpuopt_block_linking->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_block_linking->setChecked(Settings::values.cpuopt_block_linking); |
||||
|
ui->cpuopt_return_stack_buffer->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_return_stack_buffer->setChecked(Settings::values.cpuopt_return_stack_buffer); |
||||
|
ui->cpuopt_fast_dispatcher->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_fast_dispatcher->setChecked(Settings::values.cpuopt_fast_dispatcher); |
||||
|
ui->cpuopt_context_elimination->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_context_elimination->setChecked(Settings::values.cpuopt_context_elimination); |
||||
|
ui->cpuopt_const_prop->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_const_prop->setChecked(Settings::values.cpuopt_const_prop); |
||||
|
ui->cpuopt_misc_ir->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_misc_ir->setChecked(Settings::values.cpuopt_misc_ir); |
||||
|
ui->cpuopt_reduce_misalign_checks->setEnabled(runtime_lock); |
||||
|
ui->cpuopt_reduce_misalign_checks->setChecked(Settings::values.cpuopt_reduce_misalign_checks); |
||||
|
} |
||||
|
|
||||
|
void ConfigureCpuDebug::ApplyConfiguration() { |
||||
|
Settings::values.cpuopt_page_tables = ui->cpuopt_page_tables->isChecked(); |
||||
|
Settings::values.cpuopt_block_linking = ui->cpuopt_block_linking->isChecked(); |
||||
|
Settings::values.cpuopt_return_stack_buffer = ui->cpuopt_return_stack_buffer->isChecked(); |
||||
|
Settings::values.cpuopt_fast_dispatcher = ui->cpuopt_fast_dispatcher->isChecked(); |
||||
|
Settings::values.cpuopt_context_elimination = ui->cpuopt_context_elimination->isChecked(); |
||||
|
Settings::values.cpuopt_const_prop = ui->cpuopt_const_prop->isChecked(); |
||||
|
Settings::values.cpuopt_misc_ir = ui->cpuopt_misc_ir->isChecked(); |
||||
|
Settings::values.cpuopt_reduce_misalign_checks = ui->cpuopt_reduce_misalign_checks->isChecked(); |
||||
|
} |
||||
|
|
||||
|
void ConfigureCpuDebug::changeEvent(QEvent* event) { |
||||
|
if (event->type() == QEvent::LanguageChange) { |
||||
|
RetranslateUI(); |
||||
|
} |
||||
|
|
||||
|
QWidget::changeEvent(event); |
||||
|
} |
||||
|
|
||||
|
void ConfigureCpuDebug::RetranslateUI() { |
||||
|
ui->retranslateUi(this); |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
// Copyright 2020 yuzu Emulator Project |
||||
|
// Licensed under GPLv2 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <memory> |
||||
|
#include <QWidget> |
||||
|
#include "core/settings.h" |
||||
|
|
||||
|
namespace Ui { |
||||
|
class ConfigureCpuDebug; |
||||
|
} |
||||
|
|
||||
|
class ConfigureCpuDebug : public QWidget { |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
explicit ConfigureCpuDebug(QWidget* parent = nullptr); |
||||
|
~ConfigureCpuDebug() override; |
||||
|
|
||||
|
void ApplyConfiguration(); |
||||
|
|
||||
|
private: |
||||
|
void changeEvent(QEvent* event) override; |
||||
|
void RetranslateUI(); |
||||
|
|
||||
|
void SetConfiguration(); |
||||
|
|
||||
|
std::unique_ptr<Ui::ConfigureCpuDebug> ui; |
||||
|
}; |
||||
@ -0,0 +1,174 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>ConfigureCpuDebug</class> |
||||
|
<widget class="QWidget" name="ConfigureCpuDebug"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>400</width> |
||||
|
<height>321</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Form</string> |
||||
|
</property> |
||||
|
<layout class="QVBoxLayout"> |
||||
|
<item> |
||||
|
<layout class="QVBoxLayout"> |
||||
|
<item> |
||||
|
<widget class="QGroupBox"> |
||||
|
<property name="title"> |
||||
|
<string>Toggle CPU Optimizations</string> |
||||
|
</property> |
||||
|
<layout class="QVBoxLayout"> |
||||
|
<item> |
||||
|
<widget class="QLabel"> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>1</bool> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string> |
||||
|
<div> |
||||
|
<b>For debugging only.</b> |
||||
|
<br> |
||||
|
If you're not sure what these do, keep all of these enabled. |
||||
|
<br> |
||||
|
These settings only take effect when CPU Accuracy is "Debug Mode". |
||||
|
</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_page_tables"> |
||||
|
<property name="text"> |
||||
|
<string>Enable inline page tables</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div style="white-space: nowrap">This optimization speeds up memory accesses by the guest program.</div> |
||||
|
<div style="white-space: nowrap">Enabling it inlines accesses to PageTable::pointers into emitted code.</div> |
||||
|
<div style="white-space: nowrap">Disabling this forces all memory accesses to go through the Memory::Read/Memory::Write functions.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_block_linking"> |
||||
|
<property name="text"> |
||||
|
<string>Enable block linking</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div>This optimization avoids dispatcher lookups by allowing emitted basic blocks to jump directly to other basic blocks if the destination PC is static.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_return_stack_buffer"> |
||||
|
<property name="text"> |
||||
|
<string>Enable return stack buffer</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div>This optimization avoids dispatcher lookups by keeping track potential return addresses of BL instructions. This approximates what happens with a return stack buffer on a real CPU.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_fast_dispatcher"> |
||||
|
<property name="text"> |
||||
|
<string>Enable fast dispatcher</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div>Enable a two-tiered dispatch system. A faster dispatcher written in assembly has a small MRU cache of jump destinations is used first. If that fails, dispatch falls back to the slower C++ dispatcher.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_context_elimination"> |
||||
|
<property name="text"> |
||||
|
<string>Enable context elimination</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div>Enables an IR optimization that reduces unnecessary accesses to the CPU context structure.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_const_prop"> |
||||
|
<property name="text"> |
||||
|
<string>Enable constant propagation</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div>Enables IR optimizations that involve constant propagation.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_misc_ir"> |
||||
|
<property name="text"> |
||||
|
<string>Enable miscellaneous optimizations</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div>Enables miscellaneous IR optimizations.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QCheckBox" name="cpuopt_reduce_misalign_checks"> |
||||
|
<property name="text"> |
||||
|
<string>Enable misalignment check reduction</string> |
||||
|
</property> |
||||
|
<property name="toolTip"> |
||||
|
<string> |
||||
|
<div style="white-space: nowrap">When enabled, a misalignment is only triggered when an access crosses a page boundary.</div> |
||||
|
<div style="white-space: nowrap">When disabled, a misalignment is triggered on all misaligned accesses.</div> |
||||
|
</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
<item> |
||||
|
<spacer name="verticalSpacer"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Vertical</enum> |
||||
|
</property> |
||||
|
<property name="sizeHint" stdset="0"> |
||||
|
<size> |
||||
|
<width>20</width> |
||||
|
<height>40</height> |
||||
|
</size> |
||||
|
</property> |
||||
|
</spacer> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="label_disable_info"> |
||||
|
<property name="text"> |
||||
|
<string>CPU settings are available only when game is not running.</string> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections/> |
||||
|
</ui> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue