diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-05-19 04:54:58 +0200 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-07-21 16:56:07 +0200 |
commit | daa31121ee75dedcb636011e02815b816a7cc446 (patch) | |
tree | ea05baafa53b7acf49724299ddbe6897279af313 /src | |
parent | configuration: Use a mapping of setting value to name (diff) | |
download | yuzu-daa31121ee75dedcb636011e02815b816a7cc446.tar yuzu-daa31121ee75dedcb636011e02815b816a7cc446.tar.gz yuzu-daa31121ee75dedcb636011e02815b816a7cc446.tar.bz2 yuzu-daa31121ee75dedcb636011e02815b816a7cc446.tar.lz yuzu-daa31121ee75dedcb636011e02815b816a7cc446.tar.xz yuzu-daa31121ee75dedcb636011e02815b816a7cc446.tar.zst yuzu-daa31121ee75dedcb636011e02815b816a7cc446.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/yuzu/configuration/configure_cpu.cpp | 138 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_cpu.h | 11 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_cpu.ui | 129 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 3 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_per_game.cpp | 3 |
5 files changed, 94 insertions, 190 deletions
diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index ecaeb1a6b..0982e006d 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -5,88 +5,83 @@ #include <memory> #include "common/common_types.h" #include "common/settings.h" +#include "configuration/shared_widget.h" #include "core/core.h" #include "ui_configure_cpu.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_cpu.h" -ConfigureCpu::ConfigureCpu(const Core::System& system_, - std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, - QWidget* parent) - : Tab(group, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_} { +ConfigureCpu::ConfigureCpu( + const Core::System& system_, + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, + const ConfigurationShared::TranslationMap& translations_, + const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) + : Tab(group, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_}, + translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); - SetupPerGameUI(); + Setup(); SetConfiguration(); - connect(ui->accuracy, qOverload<int>(&QComboBox::currentIndexChanged), this, + connect(accuracy_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this, &ConfigureCpu::UpdateGroup); } ConfigureCpu::~ConfigureCpu() = default; -void ConfigureCpu::SetConfiguration() { +void ConfigureCpu::SetConfiguration() {} +void ConfigureCpu::Setup() { const bool runtime_lock = !system.IsPoweredOn(); + auto* accuracy_layout = ui->widget_accuracy->layout(); + auto* unsafe_layout = ui->unsafe_widget->layout(); + std::map<std::string, QWidget*> unsafe_hold{}; + + std::forward_list<Settings::BasicSetting*> settings; + const auto push = [&](Settings::Category category) { + for (const auto setting : Settings::values.linkage.by_category[category]) { + settings.push_front(setting); + } + }; + + push(Settings::Category::Cpu); + push(Settings::Category::CpuUnsafe); + + for (const auto setting : settings) { + auto* widget = new ConfigurationShared::Widget(setting, translations, combobox_translations, + this, runtime_lock, apply_funcs); + + if (!widget->Valid()) { + delete widget; + continue; + } + + if (setting->Id() == Settings::values.cpu_accuracy.Id()) { + accuracy_layout->addWidget(widget); + accuracy_combobox = widget->combobox; + } else { + unsafe_hold.insert({setting->GetLabel(), widget}); + } + } - ui->accuracy->setEnabled(runtime_lock); - ui->cpuopt_unsafe_unfuse_fma->setEnabled(runtime_lock); - ui->cpuopt_unsafe_reduce_fp_error->setEnabled(runtime_lock); - ui->cpuopt_unsafe_ignore_standard_fpcr->setEnabled(runtime_lock); - ui->cpuopt_unsafe_inaccurate_nan->setEnabled(runtime_lock); - ui->cpuopt_unsafe_fastmem_check->setEnabled(runtime_lock); - ui->cpuopt_unsafe_ignore_global_monitor->setEnabled(runtime_lock); - - ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma.GetValue()); - ui->cpuopt_unsafe_reduce_fp_error->setChecked( - Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()); - ui->cpuopt_unsafe_ignore_standard_fpcr->setChecked( - Settings::values.cpuopt_unsafe_ignore_standard_fpcr.GetValue()); - ui->cpuopt_unsafe_inaccurate_nan->setChecked( - Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()); - ui->cpuopt_unsafe_fastmem_check->setChecked( - Settings::values.cpuopt_unsafe_fastmem_check.GetValue()); - ui->cpuopt_unsafe_ignore_global_monitor->setChecked( - Settings::values.cpuopt_unsafe_ignore_global_monitor.GetValue()); - - 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()); + for (const auto& [label, widget] : unsafe_hold) { + unsafe_layout->addWidget(widget); } - UpdateGroup(ui->accuracy->currentIndex()); + + UpdateGroup(accuracy_combobox->currentIndex()); } void ConfigureCpu::UpdateGroup(int index) { - if (!Settings::IsConfiguringGlobal()) { - index -= ConfigurationShared::USE_GLOBAL_OFFSET; - } - const auto accuracy = static_cast<Settings::CPUAccuracy>(index); + const auto accuracy = static_cast<Settings::CPUAccuracy>( + combobox_translations.at(typeid(Settings::CPUAccuracy))[index].first); ui->unsafe_group->setVisible(accuracy == Settings::CPUAccuracy::Unsafe); } void ConfigureCpu::ApplyConfiguration() { - ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpu_accuracy, ui->accuracy); - 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); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_ignore_standard_fpcr, - ui->cpuopt_unsafe_ignore_standard_fpcr, - cpuopt_unsafe_ignore_standard_fpcr); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_inaccurate_nan, - ui->cpuopt_unsafe_inaccurate_nan, - cpuopt_unsafe_inaccurate_nan); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_fastmem_check, - ui->cpuopt_unsafe_fastmem_check, - cpuopt_unsafe_fastmem_check); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_ignore_global_monitor, - ui->cpuopt_unsafe_ignore_global_monitor, - cpuopt_unsafe_ignore_global_monitor); + const bool is_powered_on = system.IsPoweredOn(); + for (const auto& apply_func : apply_funcs) { + apply_func(is_powered_on); + } } void ConfigureCpu::changeEvent(QEvent* event) { @@ -100,32 +95,3 @@ void ConfigureCpu::changeEvent(QEvent* event) { void ConfigureCpu::RetranslateUI() { ui->retranslateUi(this); } - -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); - ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_ignore_standard_fpcr, - Settings::values.cpuopt_unsafe_ignore_standard_fpcr, - cpuopt_unsafe_ignore_standard_fpcr); - ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_inaccurate_nan, - Settings::values.cpuopt_unsafe_inaccurate_nan, - cpuopt_unsafe_inaccurate_nan); - ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_fastmem_check, - Settings::values.cpuopt_unsafe_fastmem_check, - cpuopt_unsafe_fastmem_check); - ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_ignore_global_monitor, - Settings::values.cpuopt_unsafe_ignore_global_monitor, - cpuopt_unsafe_ignore_global_monitor); -} diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index 187d080b6..fb970122d 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h @@ -19,6 +19,8 @@ class ConfigureCpu : public ConfigurationShared::Tab { public: explicit ConfigureCpu(const Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, + const ConfigurationShared::TranslationMap& translations, + const ConfigurationShared::ComboboxTranslationMap& combobox_translations, QWidget* parent = nullptr); ~ConfigureCpu() override; @@ -31,7 +33,7 @@ private: void UpdateGroup(int index); - void SetupPerGameUI(); + void Setup(); std::unique_ptr<Ui::ConfigureCpu> ui; @@ -43,4 +45,11 @@ private: ConfigurationShared::CheckState cpuopt_unsafe_ignore_global_monitor; const Core::System& system; + + const ConfigurationShared::TranslationMap& translations; + const ConfigurationShared::ComboboxTranslationMap& combobox_translations; + + std::forward_list<std::function<void(bool)>> apply_funcs{}; + + QComboBox* accuracy_combobox; }; diff --git a/src/yuzu/configuration/configure_cpu.ui b/src/yuzu/configuration/configure_cpu.ui index 8ae569ee6..835788c1f 100644 --- a/src/yuzu/configuration/configure_cpu.ui +++ b/src/yuzu/configuration/configure_cpu.ui @@ -27,38 +27,19 @@ <layout class="QVBoxLayout"> <item> <widget class="QWidget" name="widget_accuracy" native="true"> - <layout class="QHBoxLayout" name="layout_accuracy"> - <item> - <widget class="QLabel" name="label_accuracy"> - <property name="text"> - <string>Accuracy:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="accuracy"> - <item> - <property name="text"> - <string>Auto</string> - </property> - </item> - <item> - <property name="text"> - <string>Accurate</string> - </property> - </item> - <item> - <property name="text"> - <string>Unsafe</string> - </property> - </item> - <item> - <property name="text"> - <string>Paranoid (disables most optimizations)</string> - </property> - </item> - </widget> - </item> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> </layout> </widget> </item> @@ -96,75 +77,21 @@ </widget> </item> <item> - <widget class="QCheckBox" name="cpuopt_unsafe_unfuse_fma"> - <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> - <property name="text"> - <string>Unfuse FMA (improve performance on CPUs without FMA)</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_unsafe_reduce_fp_error"> - <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> - <property name="text"> - <string>Faster FRSQRTE and FRECPE</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_unsafe_ignore_standard_fpcr"> - <property name="toolTip"> - <string> - <div>This option improves the speed of 32 bits ASIMD floating-point functions by running with incorrect rounding modes.</div> - </string> - </property> - <property name="text"> - <string>Faster ASIMD instructions (32 bits only)</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_unsafe_inaccurate_nan"> - <property name="toolTip"> - <string> - <div>This option improves speed by removing NaN checking. Please note this also reduces accuracy of certain floating-point instructions.</div> - </string> - </property> - <property name="text"> - <string>Inaccurate NaN handling</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_unsafe_fastmem_check"> - <property name="toolTip"> - <string> - <div>This option improves speed by eliminating a safety check before every memory read/write in guest. Disabling it may allow a game to read/write the emulator's memory.</div> - </string> - </property> - <property name="text"> - <string>Disable address space checks</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_unsafe_ignore_global_monitor"> - <property name="toolTip"> - <string> - <div>This option improves speed by relying only on the semantics of cmpxchg to ensure safety of exclusive access instructions. Please note this may result in deadlocks and other race conditions.</div> - </string> - </property> - <property name="text"> - <string>Ignore global monitor</string> - </property> + <widget class="QWidget" name="unsafe_widget" native="true"> + <layout class="QVBoxLayout" name="unsafe_layout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + </layout> </widget> </item> </layout> diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 1a339a227..c7d132fc8 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -37,7 +37,8 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, combobox_translations{ConfigurationShared::ComboboxEnumeration(this)}, audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *translations, *combobox_translations, this)}, - cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, this)}, + cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, *translations, + *combobox_translations, this)}, debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *translations, diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 845ffeeb8..5863beca0 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -53,7 +53,8 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *translations, *combobox_translations, this); - cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, this); + cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, *translations, + *combobox_translations, this); graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>( system_, tab_group, *translations, *combobox_translations, this); graphics_tab = std::make_unique<ConfigureGraphics>( |