diff options
-rwxr-xr-x | README.md | 2 | ||||
-rwxr-xr-x | src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt | 3 | ||||
-rwxr-xr-x | src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt | 10 | ||||
-rwxr-xr-x | src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt | 1 | ||||
-rwxr-xr-x | src/android/app/src/main/res/layout/list_item_setting_switch.xml | 2 | ||||
-rwxr-xr-x | src/android/app/src/main/res/values/arrays.xml | 17 | ||||
-rwxr-xr-x | src/android/app/src/main/res/values/strings.xml | 8 | ||||
-rwxr-xr-x | src/core/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | src/core/file_sys/ips_layer.cpp | 7 | ||||
-rwxr-xr-x | src/core/hle/kernel/k_capabilities.cpp | 6 | ||||
-rwxr-xr-x | src/core/hle/service/jit/jit.cpp | 59 | ||||
-rwxr-xr-x | src/core/hle/service/jit/jit_code_memory.cpp | 54 | ||||
-rwxr-xr-x | src/core/hle/service/jit/jit_code_memory.h | 49 | ||||
-rwxr-xr-x | src/yuzu/main.cpp | 4 | ||||
-rwxr-xr-x | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 2 | ||||
-rwxr-xr-x | src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | 3 |
16 files changed, 204 insertions, 25 deletions
@@ -1,7 +1,7 @@ | |||
1 | yuzu emulator early access | 1 | yuzu emulator early access |
2 | ============= | 2 | ============= |
3 | 3 | ||
4 | This is the source code for early-access 4039. | 4 | This is the source code for early-access 4040. |
5 | 5 | ||
6 | ## Legal Notice | 6 | ## Legal Notice |
7 | 7 | ||
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 21e4e1afd..df760440f 100755 --- 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 | |||
@@ -18,7 +18,8 @@ enum class IntSetting(override val key: String) : AbstractIntSetting { | |||
18 | RENDERER_ANTI_ALIASING("anti_aliasing"), | 18 | RENDERER_ANTI_ALIASING("anti_aliasing"), |
19 | RENDERER_SCREEN_LAYOUT("screen_layout"), | 19 | RENDERER_SCREEN_LAYOUT("screen_layout"), |
20 | RENDERER_ASPECT_RATIO("aspect_ratio"), | 20 | RENDERER_ASPECT_RATIO("aspect_ratio"), |
21 | AUDIO_OUTPUT_ENGINE("output_engine"); | 21 | AUDIO_OUTPUT_ENGINE("output_engine"), |
22 | MAX_ANISOTROPY("max_anisotropy"); | ||
22 | 23 | ||
23 | override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal) | 24 | override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal) |
24 | 25 | ||
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 2e97aee2c..12f7aa1ab 100755 --- 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 | |||
@@ -245,6 +245,15 @@ abstract class SettingsItem( | |||
245 | ) | 245 | ) |
246 | put( | 246 | put( |
247 | SingleChoiceSetting( | 247 | SingleChoiceSetting( |
248 | IntSetting.MAX_ANISOTROPY, | ||
249 | R.string.anisotropic_filtering, | ||
250 | R.string.anisotropic_filtering_description, | ||
251 | R.array.anisoEntries, | ||
252 | R.array.anisoValues | ||
253 | ) | ||
254 | ) | ||
255 | put( | ||
256 | SingleChoiceSetting( | ||
248 | IntSetting.AUDIO_OUTPUT_ENGINE, | 257 | IntSetting.AUDIO_OUTPUT_ENGINE, |
249 | R.string.audio_output_engine, | 258 | R.string.audio_output_engine, |
250 | 0, | 259 | 0, |
@@ -298,6 +307,7 @@ abstract class SettingsItem( | |||
298 | 307 | ||
299 | override val key: String = FASTMEM_COMBINED | 308 | override val key: String = FASTMEM_COMBINED |
300 | override val isRuntimeModifiable: Boolean = false | 309 | override val isRuntimeModifiable: Boolean = false |
310 | override val pairedSettingKey = BooleanSetting.CPU_DEBUG_MODE.key | ||
301 | override val defaultValue: Boolean = true | 311 | override val defaultValue: Boolean = true |
302 | override val isSwitchable: Boolean = true | 312 | override val isSwitchable: Boolean = true |
303 | override var global: Boolean | 313 | override var global: Boolean |
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 a7e965589..db1a1076c 100755 --- 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 | |||
@@ -149,6 +149,7 @@ class SettingsFragmentPresenter( | |||
149 | add(IntSetting.RENDERER_VSYNC.key) | 149 | add(IntSetting.RENDERER_VSYNC.key) |
150 | add(IntSetting.RENDERER_SCALING_FILTER.key) | 150 | add(IntSetting.RENDERER_SCALING_FILTER.key) |
151 | add(IntSetting.RENDERER_ANTI_ALIASING.key) | 151 | add(IntSetting.RENDERER_ANTI_ALIASING.key) |
152 | add(IntSetting.MAX_ANISOTROPY.key) | ||
152 | add(IntSetting.RENDERER_SCREEN_LAYOUT.key) | 153 | add(IntSetting.RENDERER_SCREEN_LAYOUT.key) |
153 | add(IntSetting.RENDERER_ASPECT_RATIO.key) | 154 | add(IntSetting.RENDERER_ASPECT_RATIO.key) |
154 | add(BooleanSetting.PICTURE_IN_PICTURE.key) | 155 | add(BooleanSetting.PICTURE_IN_PICTURE.key) |
diff --git a/src/android/app/src/main/res/layout/list_item_setting_switch.xml b/src/android/app/src/main/res/layout/list_item_setting_switch.xml index 5cb84182e..1c08e2e1b 100755 --- a/src/android/app/src/main/res/layout/list_item_setting_switch.xml +++ b/src/android/app/src/main/res/layout/list_item_setting_switch.xml | |||
@@ -24,7 +24,7 @@ | |||
24 | android:layout_width="0dp" | 24 | android:layout_width="0dp" |
25 | android:layout_height="wrap_content" | 25 | android:layout_height="wrap_content" |
26 | android:layout_marginEnd="24dp" | 26 | android:layout_marginEnd="24dp" |
27 | android:gravity="center_vertical" | 27 | android:layout_gravity="center_vertical" |
28 | android:orientation="vertical" | 28 | android:orientation="vertical" |
29 | android:layout_weight="1"> | 29 | android:layout_weight="1"> |
30 | 30 | ||
diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index e3915ef4f..c882a8e62 100755 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml | |||
@@ -267,4 +267,21 @@ | |||
267 | <item>3</item> | 267 | <item>3</item> |
268 | </integer-array> | 268 | </integer-array> |
269 | 269 | ||
270 | <string-array name="anisoEntries"> | ||
271 | <item>@string/auto</item> | ||
272 | <item>@string/slider_default</item> | ||
273 | <item>@string/multiplier_two</item> | ||
274 | <item>@string/multiplier_four</item> | ||
275 | <item>@string/multiplier_eight</item> | ||
276 | <item>@string/multiplier_sixteen</item> | ||
277 | </string-array> | ||
278 | <integer-array name="anisoValues"> | ||
279 | <item>0</item> | ||
280 | <item>1</item> | ||
281 | <item>2</item> | ||
282 | <item>3</item> | ||
283 | <item>4</item> | ||
284 | <item>5</item> | ||
285 | </integer-array> | ||
286 | |||
270 | </resources> | 287 | </resources> |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 0b80b04a4..4d5c268fe 100755 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
@@ -225,6 +225,8 @@ | |||
225 | <string name="renderer_reactive_flushing_description">Improves rendering accuracy in some games at the cost of performance.</string> | 225 | <string name="renderer_reactive_flushing_description">Improves rendering accuracy in some games at the cost of performance.</string> |
226 | <string name="use_disk_shader_cache">Disk shader cache</string> | 226 | <string name="use_disk_shader_cache">Disk shader cache</string> |
227 | <string name="use_disk_shader_cache_description">Reduces stuttering by locally storing and loading generated shaders.</string> | 227 | <string name="use_disk_shader_cache_description">Reduces stuttering by locally storing and loading generated shaders.</string> |
228 | <string name="anisotropic_filtering">Anisotropic filtering</string> | ||
229 | <string name="anisotropic_filtering_description">Improves the quality of textures when viewed at oblique angles</string> | ||
228 | 230 | ||
229 | <!-- Debug settings strings --> | 231 | <!-- Debug settings strings --> |
230 | <string name="cpu">CPU</string> | 232 | <string name="cpu">CPU</string> |
@@ -506,6 +508,12 @@ | |||
506 | <string name="oboe">oboe</string> | 508 | <string name="oboe">oboe</string> |
507 | <string name="cubeb">cubeb</string> | 509 | <string name="cubeb">cubeb</string> |
508 | 510 | ||
511 | <!-- Anisotropic filtering options --> | ||
512 | <string name="multiplier_two">2x</string> | ||
513 | <string name="multiplier_four">4x</string> | ||
514 | <string name="multiplier_eight">8x</string> | ||
515 | <string name="multiplier_sixteen">16x</string> | ||
516 | |||
509 | <!-- Black backgrounds theme --> | 517 | <!-- Black backgrounds theme --> |
510 | <string name="use_black_backgrounds">Black backgrounds</string> | 518 | <string name="use_black_backgrounds">Black backgrounds</string> |
511 | <string name="use_black_backgrounds_description">When using the dark theme, apply black backgrounds.</string> | 519 | <string name="use_black_backgrounds_description">When using the dark theme, apply black backgrounds.</string> |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 48e174a9d..726ae9ece 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
@@ -988,6 +988,8 @@ if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) | |||
988 | arm/dynarmic/dynarmic_cp15.h | 988 | arm/dynarmic/dynarmic_cp15.h |
989 | arm/dynarmic/dynarmic_exclusive_monitor.cpp | 989 | arm/dynarmic/dynarmic_exclusive_monitor.cpp |
990 | arm/dynarmic/dynarmic_exclusive_monitor.h | 990 | arm/dynarmic/dynarmic_exclusive_monitor.h |
991 | hle/service/jit/jit_code_memory.cpp | ||
992 | hle/service/jit/jit_code_memory.h | ||
991 | hle/service/jit/jit_context.cpp | 993 | hle/service/jit/jit_context.cpp |
992 | hle/service/jit/jit_context.h | 994 | hle/service/jit/jit_context.h |
993 | hle/service/jit/jit.cpp | 995 | hle/service/jit/jit.cpp |
diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index 67d9df5d9..69abc37b5 100755 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp | |||
@@ -73,6 +73,9 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { | |||
73 | return nullptr; | 73 | return nullptr; |
74 | 74 | ||
75 | auto in_data = in->ReadAllBytes(); | 75 | auto in_data = in->ReadAllBytes(); |
76 | if (in_data.size() == 0) { | ||
77 | return nullptr; | ||
78 | } | ||
76 | 79 | ||
77 | std::vector<u8> temp(type == IPSFileType::IPS ? 3 : 4); | 80 | std::vector<u8> temp(type == IPSFileType::IPS ? 3 : 4); |
78 | u64 offset = 5; // After header | 81 | u64 offset = 5; // After header |
@@ -88,6 +91,10 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { | |||
88 | else | 91 | else |
89 | real_offset = (temp[0] << 16) | (temp[1] << 8) | temp[2]; | 92 | real_offset = (temp[0] << 16) | (temp[1] << 8) | temp[2]; |
90 | 93 | ||
94 | if (real_offset > in_data.size()) { | ||
95 | return nullptr; | ||
96 | } | ||
97 | |||
91 | u16 data_size{}; | 98 | u16 data_size{}; |
92 | if (ips->ReadObject(&data_size, offset) != sizeof(u16)) | 99 | if (ips->ReadObject(&data_size, offset) != sizeof(u16)) |
93 | return nullptr; | 100 | return nullptr; |
diff --git a/src/core/hle/kernel/k_capabilities.cpp b/src/core/hle/kernel/k_capabilities.cpp index 274fee493..d2288c30d 100755 --- a/src/core/hle/kernel/k_capabilities.cpp +++ b/src/core/hle/kernel/k_capabilities.cpp | |||
@@ -185,6 +185,10 @@ Result KCapabilities::ProcessMapRegionCapability(const u32 cap, F f) { | |||
185 | case RegionType::NoMapping: | 185 | case RegionType::NoMapping: |
186 | break; | 186 | break; |
187 | case RegionType::KernelTraceBuffer: | 187 | case RegionType::KernelTraceBuffer: |
188 | if constexpr (!IsKTraceEnabled) { | ||
189 | break; | ||
190 | } | ||
191 | [[fallthrough]]; | ||
188 | case RegionType::OnMemoryBootImage: | 192 | case RegionType::OnMemoryBootImage: |
189 | case RegionType::DTB: | 193 | case RegionType::DTB: |
190 | R_TRY(f(MemoryRegions[static_cast<u32>(type)], perm)); | 194 | R_TRY(f(MemoryRegions[static_cast<u32>(type)], perm)); |
@@ -330,8 +334,6 @@ Result KCapabilities::SetCapabilities(std::span<const u32> caps, KProcessPageTab | |||
330 | 334 | ||
331 | // Map the range. | 335 | // Map the range. |
332 | R_TRY(this->MapRange_(cap, size_cap, page_table)); | 336 | R_TRY(this->MapRange_(cap, size_cap, page_table)); |
333 | } else if (GetCapabilityType(cap) == CapabilityType::MapRegion && !IsKTraceEnabled) { | ||
334 | continue; | ||
335 | } else { | 337 | } else { |
336 | R_TRY(this->SetCapability(cap, set_flags, set_svc, page_table)); | 338 | R_TRY(this->SetCapability(cap, set_flags, set_svc, page_table)); |
337 | } | 339 | } |
diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index 5dc9a96c0..771563d4d 100755 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp | |||
@@ -4,11 +4,11 @@ | |||
4 | #include "core/arm/debug.h" | 4 | #include "core/arm/debug.h" |
5 | #include "core/arm/symbols.h" | 5 | #include "core/arm/symbols.h" |
6 | #include "core/core.h" | 6 | #include "core/core.h" |
7 | #include "core/hle/kernel/k_code_memory.h" | ||
8 | #include "core/hle/kernel/k_transfer_memory.h" | 7 | #include "core/hle/kernel/k_transfer_memory.h" |
9 | #include "core/hle/result.h" | 8 | #include "core/hle/result.h" |
10 | #include "core/hle/service/ipc_helpers.h" | 9 | #include "core/hle/service/ipc_helpers.h" |
11 | #include "core/hle/service/jit/jit.h" | 10 | #include "core/hle/service/jit/jit.h" |
11 | #include "core/hle/service/jit/jit_code_memory.h" | ||
12 | #include "core/hle/service/jit/jit_context.h" | 12 | #include "core/hle/service/jit/jit_context.h" |
13 | #include "core/hle/service/server_manager.h" | 13 | #include "core/hle/service/server_manager.h" |
14 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
@@ -23,10 +23,12 @@ struct CodeRange { | |||
23 | 23 | ||
24 | class IJitEnvironment final : public ServiceFramework<IJitEnvironment> { | 24 | class IJitEnvironment final : public ServiceFramework<IJitEnvironment> { |
25 | public: | 25 | public: |
26 | explicit IJitEnvironment(Core::System& system_, Kernel::KProcess& process_, CodeRange user_rx, | 26 | explicit IJitEnvironment(Core::System& system_, |
27 | CodeRange user_ro) | 27 | Kernel::KScopedAutoObject<Kernel::KProcess>&& process_, |
28 | : ServiceFramework{system_, "IJitEnvironment"}, process{&process_}, | 28 | CodeMemory&& user_rx_, CodeMemory&& user_ro_) |
29 | context{process->GetMemory()} { | 29 | : ServiceFramework{system_, "IJitEnvironment"}, process{std::move(process_)}, |
30 | user_rx{std::move(user_rx_)}, user_ro{std::move(user_ro_)}, | ||
31 | context{system_.ApplicationMemory()} { | ||
30 | // clang-format off | 32 | // clang-format off |
31 | static const FunctionInfo functions[] = { | 33 | static const FunctionInfo functions[] = { |
32 | {0, &IJitEnvironment::GenerateCode, "GenerateCode"}, | 34 | {0, &IJitEnvironment::GenerateCode, "GenerateCode"}, |
@@ -39,10 +41,13 @@ public: | |||
39 | RegisterHandlers(functions); | 41 | RegisterHandlers(functions); |
40 | 42 | ||
41 | // Identity map user code range into sysmodule context | 43 | // Identity map user code range into sysmodule context |
42 | configuration.user_ro_memory = user_ro; | 44 | configuration.user_rx_memory.size = user_rx.GetSize(); |
43 | configuration.user_rx_memory = user_rx; | 45 | configuration.user_rx_memory.offset = user_rx.GetAddress(); |
44 | configuration.sys_ro_memory = user_ro; | 46 | configuration.user_ro_memory.size = user_ro.GetSize(); |
45 | configuration.sys_rx_memory = user_rx; | 47 | configuration.user_ro_memory.offset = user_ro.GetAddress(); |
48 | |||
49 | configuration.sys_rx_memory = configuration.user_rx_memory; | ||
50 | configuration.sys_ro_memory = configuration.user_ro_memory; | ||
46 | } | 51 | } |
47 | 52 | ||
48 | void GenerateCode(HLERequestContext& ctx) { | 53 | void GenerateCode(HLERequestContext& ctx) { |
@@ -318,6 +323,8 @@ private: | |||
318 | } | 323 | } |
319 | 324 | ||
320 | Kernel::KScopedAutoObject<Kernel::KProcess> process; | 325 | Kernel::KScopedAutoObject<Kernel::KProcess> process; |
326 | CodeMemory user_rx; | ||
327 | CodeMemory user_ro; | ||
321 | GuestCallbacks callbacks; | 328 | GuestCallbacks callbacks; |
322 | JITConfiguration configuration; | 329 | JITConfiguration configuration; |
323 | JITContext context; | 330 | JITContext context; |
@@ -335,6 +342,7 @@ public: | |||
335 | RegisterHandlers(functions); | 342 | RegisterHandlers(functions); |
336 | } | 343 | } |
337 | 344 | ||
345 | private: | ||
338 | void CreateJitEnvironment(HLERequestContext& ctx) { | 346 | void CreateJitEnvironment(HLERequestContext& ctx) { |
339 | LOG_DEBUG(Service_JIT, "called"); | 347 | LOG_DEBUG(Service_JIT, "called"); |
340 | 348 | ||
@@ -380,20 +388,35 @@ public: | |||
380 | return; | 388 | return; |
381 | } | 389 | } |
382 | 390 | ||
383 | const CodeRange user_rx{ | 391 | CodeMemory rx, ro; |
384 | .offset = GetInteger(rx_mem->GetSourceAddress()), | 392 | Result res; |
385 | .size = parameters.rx_size, | ||
386 | }; | ||
387 | 393 | ||
388 | const CodeRange user_ro{ | 394 | res = rx.Initialize(*process, *rx_mem, parameters.rx_size, |
389 | .offset = GetInteger(ro_mem->GetSourceAddress()), | 395 | Kernel::Svc::MemoryPermission::ReadExecute, generate_random); |
390 | .size = parameters.ro_size, | 396 | if (R_FAILED(res)) { |
391 | }; | 397 | LOG_ERROR(Service_JIT, "rx_mem could not be mapped for handle=0x{:08X}", rx_mem_handle); |
398 | IPC::ResponseBuilder rb{ctx, 2}; | ||
399 | rb.Push(res); | ||
400 | return; | ||
401 | } | ||
402 | |||
403 | res = ro.Initialize(*process, *ro_mem, parameters.ro_size, | ||
404 | Kernel::Svc::MemoryPermission::Read, generate_random); | ||
405 | if (R_FAILED(res)) { | ||
406 | LOG_ERROR(Service_JIT, "ro_mem could not be mapped for handle=0x{:08X}", ro_mem_handle); | ||
407 | IPC::ResponseBuilder rb{ctx, 2}; | ||
408 | rb.Push(res); | ||
409 | return; | ||
410 | } | ||
392 | 411 | ||
393 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 412 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
394 | rb.Push(ResultSuccess); | 413 | rb.Push(ResultSuccess); |
395 | rb.PushIpcInterface<IJitEnvironment>(system, *process, user_rx, user_ro); | 414 | rb.PushIpcInterface<IJitEnvironment>(system, std::move(process), std::move(rx), |
415 | std::move(ro)); | ||
396 | } | 416 | } |
417 | |||
418 | private: | ||
419 | std::mt19937_64 generate_random{}; | ||
397 | }; | 420 | }; |
398 | 421 | ||
399 | void LoopProcess(Core::System& system) { | 422 | void LoopProcess(Core::System& system) { |
diff --git a/src/core/hle/service/jit/jit_code_memory.cpp b/src/core/hle/service/jit/jit_code_memory.cpp new file mode 100755 index 000000000..2b480488a --- /dev/null +++ b/src/core/hle/service/jit/jit_code_memory.cpp | |||
@@ -0,0 +1,54 @@ | |||
1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
3 | |||
4 | #include "core/hle/service/jit/jit_code_memory.h" | ||
5 | |||
6 | namespace Service::JIT { | ||
7 | |||
8 | Result CodeMemory::Initialize(Kernel::KProcess& process, Kernel::KCodeMemory& code_memory, | ||
9 | size_t size, Kernel::Svc::MemoryPermission perm, | ||
10 | std::mt19937_64& generate_random) { | ||
11 | auto& page_table = process.GetPageTable(); | ||
12 | const u64 alias_code_start = | ||
13 | GetInteger(page_table.GetAliasCodeRegionStart()) / Kernel::PageSize; | ||
14 | const u64 alias_code_size = page_table.GetAliasCodeRegionSize() / Kernel::PageSize; | ||
15 | |||
16 | // NOTE: This will retry indefinitely until mapping the code memory succeeds. | ||
17 | while (true) { | ||
18 | // Generate a new trial address. | ||
19 | const u64 mapped_address = | ||
20 | (alias_code_start + (generate_random() % alias_code_size)) * Kernel::PageSize; | ||
21 | |||
22 | // Try to map the address | ||
23 | R_TRY_CATCH(code_memory.MapToOwner(mapped_address, size, perm)) { | ||
24 | R_CATCH(Kernel::ResultInvalidMemoryRegion) { | ||
25 | // If we could not map here, retry. | ||
26 | continue; | ||
27 | } | ||
28 | } | ||
29 | R_END_TRY_CATCH; | ||
30 | |||
31 | // Set members. | ||
32 | m_code_memory = std::addressof(code_memory); | ||
33 | m_size = size; | ||
34 | m_address = mapped_address; | ||
35 | m_perm = perm; | ||
36 | |||
37 | // Open a new reference to the code memory. | ||
38 | m_code_memory->Open(); | ||
39 | |||
40 | // We succeeded. | ||
41 | R_SUCCEED(); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | void CodeMemory::Finalize() { | ||
46 | if (m_code_memory) { | ||
47 | R_ASSERT(m_code_memory->UnmapFromOwner(m_address, m_size)); | ||
48 | m_code_memory->Close(); | ||
49 | } | ||
50 | |||
51 | m_code_memory = nullptr; | ||
52 | } | ||
53 | |||
54 | } // namespace Service::JIT | ||
diff --git a/src/core/hle/service/jit/jit_code_memory.h b/src/core/hle/service/jit/jit_code_memory.h new file mode 100755 index 000000000..6376d4c4e --- /dev/null +++ b/src/core/hle/service/jit/jit_code_memory.h | |||
@@ -0,0 +1,49 @@ | |||
1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
3 | |||
4 | #pragma once | ||
5 | |||
6 | #include <random> | ||
7 | |||
8 | #include "core/hle/kernel/k_code_memory.h" | ||
9 | |||
10 | namespace Service::JIT { | ||
11 | |||
12 | class CodeMemory { | ||
13 | public: | ||
14 | YUZU_NON_COPYABLE(CodeMemory); | ||
15 | |||
16 | explicit CodeMemory() = default; | ||
17 | |||
18 | CodeMemory(CodeMemory&& rhs) { | ||
19 | std::swap(m_code_memory, rhs.m_code_memory); | ||
20 | std::swap(m_size, rhs.m_size); | ||
21 | std::swap(m_address, rhs.m_address); | ||
22 | std::swap(m_perm, rhs.m_perm); | ||
23 | } | ||
24 | |||
25 | ~CodeMemory() { | ||
26 | this->Finalize(); | ||
27 | } | ||
28 | |||
29 | public: | ||
30 | Result Initialize(Kernel::KProcess& process, Kernel::KCodeMemory& code_memory, size_t size, | ||
31 | Kernel::Svc::MemoryPermission perm, std::mt19937_64& generate_random); | ||
32 | void Finalize(); | ||
33 | |||
34 | size_t GetSize() const { | ||
35 | return m_size; | ||
36 | } | ||
37 | |||
38 | u64 GetAddress() const { | ||
39 | return m_address; | ||
40 | } | ||
41 | |||
42 | private: | ||
43 | Kernel::KCodeMemory* m_code_memory{}; | ||
44 | size_t m_size{}; | ||
45 | u64 m_address{}; | ||
46 | Kernel::Svc::MemoryPermission m_perm{}; | ||
47 | }; | ||
48 | |||
49 | } // namespace Service::JIT | ||
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 0ff120f36..241bc4c74 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
@@ -5342,6 +5342,10 @@ int main(int argc, char* argv[]) { | |||
5342 | if (QString::fromLocal8Bit(qgetenv("DISPLAY")).isEmpty()) { | 5342 | if (QString::fromLocal8Bit(qgetenv("DISPLAY")).isEmpty()) { |
5343 | qputenv("DISPLAY", ":0"); | 5343 | qputenv("DISPLAY", ":0"); |
5344 | } | 5344 | } |
5345 | |||
5346 | // Fix the Wayland appId. This needs to match the name of the .desktop file without the .desktop | ||
5347 | // suffix. | ||
5348 | QGuiApplication::setDesktopFileName(QStringLiteral("org.yuzu_emu.yuzu")); | ||
5345 | #endif | 5349 | #endif |
5346 | 5350 | ||
5347 | SetHighDPIAttributes(); | 5351 | SetHighDPIAttributes(); |
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 2ceca5f53..8d11a8e23 100755 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | |||
@@ -20,7 +20,7 @@ EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_, Co | |||
20 | : input_subsystem{input_subsystem_}, system{system_} { | 20 | : input_subsystem{input_subsystem_}, system{system_} { |
21 | input_subsystem->Initialize(); | 21 | input_subsystem->Initialize(); |
22 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) { | 22 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) { |
23 | LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); | 23 | LOG_CRITICAL(Frontend, "Failed to initialize SDL2: {}, Exiting...", SDL_GetError()); |
24 | exit(1); | 24 | exit(1); |
25 | } | 25 | } |
26 | SDL_SetMainReady(); | 26 | SDL_SetMainReady(); |
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp index 233914091..73a7bcc63 100755 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | |||
@@ -28,7 +28,8 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsyste | |||
28 | SDL_SysWMinfo wm; | 28 | SDL_SysWMinfo wm; |
29 | SDL_VERSION(&wm.version); | 29 | SDL_VERSION(&wm.version); |
30 | if (SDL_GetWindowWMInfo(render_window, &wm) == SDL_FALSE) { | 30 | if (SDL_GetWindowWMInfo(render_window, &wm) == SDL_FALSE) { |
31 | LOG_CRITICAL(Frontend, "Failed to get information from the window manager"); | 31 | LOG_CRITICAL(Frontend, "Failed to get information from the window manager: {}", |
32 | SDL_GetError()); | ||
32 | std::exit(EXIT_FAILURE); | 33 | std::exit(EXIT_FAILURE); |
33 | } | 34 | } |
34 | 35 | ||