diff options
Diffstat (limited to 'src')
10 files changed, 42 insertions, 8 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt index 151362124..ef10b209f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt | |||
| @@ -10,6 +10,7 @@ enum class IntSetting( | |||
| 10 | override val category: Settings.Category, | 10 | override val category: Settings.Category, |
| 11 | override val androidDefault: Int? = null | 11 | override val androidDefault: Int? = null |
| 12 | ) : AbstractIntSetting { | 12 | ) : AbstractIntSetting { |
| 13 | CPU_BACKEND("cpu_backend", Settings.Category.Cpu), | ||
| 13 | CPU_ACCURACY("cpu_accuracy", Settings.Category.Cpu), | 14 | CPU_ACCURACY("cpu_accuracy", Settings.Category.Cpu), |
| 14 | REGION_INDEX("region_index", Settings.Category.System), | 15 | REGION_INDEX("region_index", Settings.Category.System), |
| 15 | LANGUAGE_INDEX("language_index", Settings.Category.System), | 16 | LANGUAGE_INDEX("language_index", Settings.Category.System), |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index 6aba69dbe..1f090424b 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt | |||
| @@ -79,6 +79,15 @@ abstract class SettingsItem( | |||
| 79 | ) | 79 | ) |
| 80 | put( | 80 | put( |
| 81 | SingleChoiceSetting( | 81 | SingleChoiceSetting( |
| 82 | IntSetting.CPU_BACKEND, | ||
| 83 | R.string.cpu_backend, | ||
| 84 | 0, | ||
| 85 | R.array.cpuBackendNames, | ||
| 86 | R.array.cpuBackendValues | ||
| 87 | ) | ||
| 88 | ) | ||
| 89 | put( | ||
| 90 | SingleChoiceSetting( | ||
| 82 | IntSetting.CPU_ACCURACY, | 91 | IntSetting.CPU_ACCURACY, |
| 83 | R.string.cpu_accuracy, | 92 | R.string.cpu_accuracy, |
| 84 | 0, | 93 | 0, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index 8b71e32f3..7425728c6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt | |||
| @@ -269,6 +269,7 @@ class SettingsFragmentPresenter( | |||
| 269 | add(BooleanSetting.RENDERER_DEBUG.key) | 269 | add(BooleanSetting.RENDERER_DEBUG.key) |
| 270 | 270 | ||
| 271 | add(HeaderSetting(R.string.cpu)) | 271 | add(HeaderSetting(R.string.cpu)) |
| 272 | add(IntSetting.CPU_BACKEND.key) | ||
| 272 | add(IntSetting.CPU_ACCURACY.key) | 273 | add(IntSetting.CPU_ACCURACY.key) |
| 273 | add(BooleanSetting.CPU_DEBUG_MODE.key) | 274 | add(BooleanSetting.CPU_DEBUG_MODE.key) |
| 274 | add(SettingsItem.FASTMEM_COMBINED) | 275 | add(SettingsItem.FASTMEM_COMBINED) |
diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index 51bcc49a3..2756e5cc9 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml | |||
| @@ -175,6 +175,16 @@ | |||
| 175 | <item>2</item> | 175 | <item>2</item> |
| 176 | </integer-array> | 176 | </integer-array> |
| 177 | 177 | ||
| 178 | <string-array name="cpuBackendNames"> | ||
| 179 | <item>@string/cpu_backend_dynarmic</item> | ||
| 180 | <item>@string/cpu_backend_nce</item> | ||
| 181 | </string-array> | ||
| 182 | |||
| 183 | <integer-array name="cpuBackendValues"> | ||
| 184 | <item>0</item> | ||
| 185 | <item>1</item> | ||
| 186 | </integer-array> | ||
| 187 | |||
| 178 | <string-array name="cpuAccuracyNames"> | 188 | <string-array name="cpuAccuracyNames"> |
| 179 | <item>@string/auto</item> | 189 | <item>@string/auto</item> |
| 180 | <item>@string/cpu_accuracy_accurate</item> | 190 | <item>@string/cpu_accuracy_accurate</item> |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 471af8795..f07121f6a 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -185,6 +185,7 @@ | |||
| 185 | <string name="frame_limit_enable_description">Limits emulation speed to a specified percentage of normal speed.</string> | 185 | <string name="frame_limit_enable_description">Limits emulation speed to a specified percentage of normal speed.</string> |
| 186 | <string name="frame_limit_slider">Limit speed percent</string> | 186 | <string name="frame_limit_slider">Limit speed percent</string> |
| 187 | <string name="frame_limit_slider_description">Specifies the percentage to limit emulation speed. 100% is the normal speed. Values higher or lower will increase or decrease the speed limit.</string> | 187 | <string name="frame_limit_slider_description">Specifies the percentage to limit emulation speed. 100% is the normal speed. Values higher or lower will increase or decrease the speed limit.</string> |
| 188 | <string name="cpu_backend">CPU Backend</string> | ||
| 188 | <string name="cpu_accuracy">CPU accuracy</string> | 189 | <string name="cpu_accuracy">CPU accuracy</string> |
| 189 | <string name="value_with_units">%1$s%2$s</string> | 190 | <string name="value_with_units">%1$s%2$s</string> |
| 190 | 191 | ||
| @@ -416,6 +417,10 @@ | |||
| 416 | <string name="ratio_force_sixteen_ten">Force 16:10</string> | 417 | <string name="ratio_force_sixteen_ten">Force 16:10</string> |
| 417 | <string name="ratio_stretch">Stretch to window</string> | 418 | <string name="ratio_stretch">Stretch to window</string> |
| 418 | 419 | ||
| 420 | <!-- CPU Backend --> | ||
| 421 | <string name="cpu_backend_dynarmic">Dynarmic (Slow)</string> | ||
| 422 | <string name="cpu_backend_nce">Native code execution (NCE)</string> | ||
| 423 | |||
| 419 | <!-- CPU Accuracy --> | 424 | <!-- CPU Accuracy --> |
| 420 | <string name="cpu_accuracy_accurate">Accurate</string> | 425 | <string name="cpu_accuracy_accurate">Accurate</string> |
| 421 | <string name="cpu_accuracy_unsafe">Unsafe</string> | 426 | <string name="cpu_accuracy_unsafe">Unsafe</string> |
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 38d7b29f7..8a869e558 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp | |||
| @@ -363,13 +363,13 @@ private: | |||
| 363 | 363 | ||
| 364 | #ifdef ARCHITECTURE_arm64 | 364 | #ifdef ARCHITECTURE_arm64 |
| 365 | 365 | ||
| 366 | uint64_t GetRandomU64() { | 366 | static uint64_t GetRandomU64() { |
| 367 | uint64_t ret; | 367 | uint64_t ret; |
| 368 | ASSERT(getrandom(&ret, sizeof(ret), 0) == 0); | 368 | ASSERT(getrandom(&ret, sizeof(ret), 0) == 0); |
| 369 | return ret; | 369 | return ret; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | void* ChooseVirtualBase(size_t virtual_size) { | 372 | static void* ChooseVirtualBase(size_t virtual_size) { |
| 373 | constexpr uintptr_t Map39BitSize = (1ULL << 39); | 373 | constexpr uintptr_t Map39BitSize = (1ULL << 39); |
| 374 | constexpr uintptr_t Map36BitSize = (1ULL << 36); | 374 | constexpr uintptr_t Map36BitSize = (1ULL << 36); |
| 375 | 375 | ||
| @@ -410,7 +410,7 @@ void* ChooseVirtualBase(size_t virtual_size) { | |||
| 410 | return MAP_FAILED; | 410 | return MAP_FAILED; |
| 411 | } | 411 | } |
| 412 | #else | 412 | #else |
| 413 | void* ChooseVirtualBase(size_t virtual_size) { | 413 | static void* ChooseVirtualBase(size_t virtual_size) { |
| 414 | return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, | 414 | return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, |
| 415 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); | 415 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); |
| 416 | } | 416 | } |
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 81a036ef0..90e7475d7 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -159,7 +159,13 @@ bool IsFastmemEnabled() { | |||
| 159 | static bool is_nce_enabled = false; | 159 | static bool is_nce_enabled = false; |
| 160 | 160 | ||
| 161 | void SetNceEnabled(bool is_39bit) { | 161 | void SetNceEnabled(bool is_39bit) { |
| 162 | is_nce_enabled = values.cpu_backend.GetValue() == CpuBackend::Nce && is_39bit; | 162 | const bool is_nce_selected = values.cpu_backend.GetValue() == CpuBackend::Nce; |
| 163 | is_nce_enabled = is_nce_selected && is_39bit; | ||
| 164 | if (is_nce_selected && !is_nce_enabled) { | ||
| 165 | LOG_WARNING( | ||
| 166 | Common, | ||
| 167 | "Program does not utilize 39-bit address space, unable to natively execute code"); | ||
| 168 | } | ||
| 163 | } | 169 | } |
| 164 | 170 | ||
| 165 | bool IsNceEnabled() { | 171 | bool IsNceEnabled() { |
diff --git a/src/common/signal_chain.cpp b/src/common/signal_chain.cpp index e0c6b9d4e..2e4fecc48 100644 --- a/src/common/signal_chain.cpp +++ b/src/common/signal_chain.cpp | |||
| @@ -18,7 +18,7 @@ T* LookupLibcSymbol(const char* name) { | |||
| 18 | UNREACHABLE_MSG("Failed to open libc!"); | 18 | UNREACHABLE_MSG("Failed to open libc!"); |
| 19 | } | 19 | } |
| 20 | #else | 20 | #else |
| 21 | // For other operating environments, we assume the symbol is not overriden. | 21 | // For other operating environments, we assume the symbol is not overridden. |
| 22 | const char* base = nullptr; | 22 | const char* base = nullptr; |
| 23 | Common::DynamicLibrary provider(base); | 23 | Common::DynamicLibrary provider(base); |
| 24 | #endif | 24 | #endif |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index e7fc8f438..31c00f0a3 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -129,8 +129,10 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect | |||
| 129 | } | 129 | } |
| 130 | metadata.Print(); | 130 | metadata.Print(); |
| 131 | 131 | ||
| 132 | // Enable NCE only for 64-bit programs. | 132 | // Enable NCE only for programs with 39-bit address space. |
| 133 | Settings::SetNceEnabled(metadata.Is64BitProgram()); | 133 | const bool is_39bit = |
| 134 | metadata.GetAddressSpaceType() == FileSys::ProgramAddressSpaceType::Is39Bit; | ||
| 135 | Settings::SetNceEnabled(is_39bit); | ||
| 134 | 136 | ||
| 135 | const std::array static_modules = {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", | 137 | const std::array static_modules = {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", |
| 136 | "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", | 138 | "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 49cf90317..76ff38041 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -199,6 +199,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process, | |||
| 199 | 199 | ||
| 200 | codeset.DataSegment().size += bss_size; | 200 | codeset.DataSegment().size += bss_size; |
| 201 | program_image.resize(static_cast<u32>(program_image.size()) + bss_size); | 201 | program_image.resize(static_cast<u32>(program_image.size()) + bss_size); |
| 202 | size_t image_size = program_image.size(); | ||
| 202 | 203 | ||
| 203 | #ifdef ARCHITECTURE_arm64 | 204 | #ifdef ARCHITECTURE_arm64 |
| 204 | const auto& code = codeset.CodeSegment(); | 205 | const auto& code = codeset.CodeSegment(); |
| @@ -208,7 +209,6 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process, | |||
| 208 | 209 | ||
| 209 | // Create NCE patcher | 210 | // Create NCE patcher |
| 210 | Core::NCE::Patcher patch{}; | 211 | Core::NCE::Patcher patch{}; |
| 211 | size_t image_size = program_image.size(); | ||
| 212 | 212 | ||
| 213 | if (Settings::IsNceEnabled()) { | 213 | if (Settings::IsNceEnabled()) { |
| 214 | // Patch SVCs and MRS calls in the guest code | 214 | // Patch SVCs and MRS calls in the guest code |