From a76a8fb5fecb4731a9a9231f3e06d5743c34e090 Mon Sep 17 00:00:00 2001 From: amazingfate Date: Sun, 26 Nov 2023 20:25:18 -0500 Subject: qt: add cpu_backend configuration --- src/common/CMakeLists.txt | 2 +- src/common/settings.h | 2 +- src/common/wall_clock.cpp | 4 ++-- src/core/CMakeLists.txt | 3 +-- src/yuzu/configuration/configure_cpu.cpp | 12 +++++++++++ src/yuzu/configuration/configure_cpu.h | 1 + src/yuzu/configuration/configure_cpu.ui | 30 +++++++++++++++++++++++++++ src/yuzu/configuration/shared_translation.cpp | 6 ++++++ 8 files changed, 54 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 98fd5f1e4..d38d5c6d1 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -199,7 +199,7 @@ if(ARCHITECTURE_x86_64) target_link_libraries(common PRIVATE xbyak::xbyak) endif() -if (ARCHITECTURE_arm64 AND (ANDROID OR LINUX)) +if (HAS_NCE) target_sources(common PRIVATE arm64/native_clock.cpp diff --git a/src/common/settings.h b/src/common/settings.h index fea639ee3..508615011 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -182,7 +182,7 @@ struct Values { // Cpu SwitchableSetting cpu_backend{ linkage, CpuBackend::Dynarmic, CpuBackend::Dynarmic, -#ifdef ARCHITECTURE_arm64 +#ifdef HAS_NCE CpuBackend::Nce, #else CpuBackend::Dynarmic, diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index caca9a123..012fdc1e0 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -10,7 +10,7 @@ #include "common/x64/rdtsc.h" #endif -#if defined(ARCHITECTURE_arm64) && defined(__linux__) +#ifdef HAS_NCE #include "common/arm64/native_clock.h" #endif @@ -68,7 +68,7 @@ std::unique_ptr CreateOptimalClock() { // - Is not more precise than 1 GHz (1ns resolution) return std::make_unique(); } -#elif defined(ARCHITECTURE_arm64) && defined(__linux__) +#elif defined(HAS_NCE) return std::make_unique(); #else return std::make_unique(); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e0bfb5b95..c3ab5ecf9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -926,8 +926,7 @@ if (ENABLE_WEB_SERVICE) target_link_libraries(core PRIVATE web_service) endif() -if (ARCHITECTURE_arm64 AND (ANDROID OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")) - target_compile_definitions(core PRIVATE -DHAS_NCE) +if (HAS_NCE) enable_language(C ASM) set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index a51359903..7e16cf17d 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -27,6 +27,13 @@ ConfigureCpu::ConfigureCpu(const Core::System& system_, connect(accuracy_combobox, qOverload(&QComboBox::currentIndexChanged), this, &ConfigureCpu::UpdateGroup); + + connect(backend_combobox, qOverload(&QComboBox::currentIndexChanged), this, + &ConfigureCpu::UpdateGroup); + +#ifdef HAS_NCE + ui->backend_group->setVisible(true); +#endif } ConfigureCpu::~ConfigureCpu() = default; @@ -34,6 +41,7 @@ ConfigureCpu::~ConfigureCpu() = default; void ConfigureCpu::SetConfiguration() {} void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) { auto* accuracy_layout = ui->widget_accuracy->layout(); + auto* backend_layout = ui->widget_backend->layout(); auto* unsafe_layout = ui->unsafe_widget->layout(); std::map unsafe_hold{}; @@ -62,6 +70,9 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) { // Keep track of cpu_accuracy combobox to display/hide the unsafe settings accuracy_layout->addWidget(widget); accuracy_combobox = widget->combobox; + } else if (setting->Id() == Settings::values.cpu_backend.Id()) { + backend_layout->addWidget(widget); + backend_combobox = widget->combobox; } else { // Presently, all other settings here are unsafe checkboxes unsafe_hold.insert({setting->Id(), widget}); @@ -73,6 +84,7 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) { } UpdateGroup(accuracy_combobox->currentIndex()); + UpdateGroup(backend_combobox->currentIndex()); } void ConfigureCpu::UpdateGroup(int index) { diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index 61a6de7aa..a102b4c1f 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h @@ -49,4 +49,5 @@ private: std::vector> apply_funcs{}; QComboBox* accuracy_combobox; + QComboBox* backend_combobox; }; diff --git a/src/yuzu/configuration/configure_cpu.ui b/src/yuzu/configuration/configure_cpu.ui index f734e842e..13fd43605 100644 --- a/src/yuzu/configuration/configure_cpu.ui +++ b/src/yuzu/configuration/configure_cpu.ui @@ -59,6 +59,36 @@ + + + + CPU Backend + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + false + + + diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index a7b5def32..daf0e1663 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -44,6 +44,7 @@ std::unique_ptr InitializeTranslations(QWidget* parent) { // Cpu INSERT(Settings, cpu_accuracy, tr("Accuracy:"), QStringLiteral()); + INSERT(Settings, cpu_backend, tr("Backend:"), QStringLiteral()); // Cpu Debug @@ -240,6 +241,11 @@ std::unique_ptr ComboboxEnumeration(QWidget* parent) { PAIR(CpuAccuracy, Unsafe, tr("Unsafe")), PAIR(CpuAccuracy, Paranoid, tr("Paranoid (disables most optimizations)")), }}); + translations->insert({Settings::EnumMetadata::Index(), + { + PAIR(CpuBackend, Dynarmic, tr("Dynarmic")), + PAIR(CpuBackend, Nce, tr("NCE")), + }}); translations->insert({Settings::EnumMetadata::Index(), { PAIR(FullscreenMode, Borderless, tr("Borderless Windowed")), -- cgit v1.2.3