Make codebase more CPU-agnostic + MacOS disclaimer #559

Merged
Exzap merged 6 commits from arm-fixes-1 into main 2022-12-06 21:48:24 -03:00
Exzap commented 2022-12-06 18:13:34 -03:00 (Migrated from github.com)

This is partially based on the porting work by @iamqk

This PR contains:

  • A new g_CPUFeatures class that unifies all the code for checking which CPU extensions are supported (AVX, SSE2, AES-NI, etc.). It also makes it easier to add additional architectures.
  • Make x86-specific code optional and wire up ARM ih264d

Bonus additions:

  • On linux/macos we now print the RAM amount to log
  • MacOS users are now warned about the unfinished/experimental state of the macOS port via a message box that will show up upon launch of Cemu (only once)
This is partially based on the porting work by @iamqk This PR contains: - A new g_CPUFeatures class that unifies all the code for checking which CPU extensions are supported (AVX, SSE2, AES-NI, etc.). It also makes it easier to add additional architectures. - Make x86-specific code optional and wire up ARM ih264d Bonus additions: - On linux/macos we now print the RAM amount to log - MacOS users are now warned about the unfinished/experimental state of the macOS port via a message box that will show up upon launch of Cemu (only once)
Tillsunset (Migrated from github.com) reviewed 2022-12-06 19:39:27 -03:00
@ -42,3 +47,4 @@
#include <sys/sysctl.h>
#endif
#if BOOST_OS_WINDOWS
Tillsunset (Migrated from github.com) commented 2022-12-06 19:39:27 -03:00

This is causing the build error on macOS, it doesn't get defined in macOS. I just replaced the define on line 42 with this outside the guards and it compiled just fine for all platforms.

#ifndef _putenv
#define _putenv(__s) putenv((char*)(__s))
#endif
This is causing the build error on macOS, it doesn't get defined in macOS. I just replaced the define on line 42 with this outside the guards and it compiled just fine for all platforms. ``` #ifndef _putenv #define _putenv(__s) putenv((char*)(__s)) #endif ```
lbibass (Migrated from github.com) reviewed 2022-12-07 19:14:00 -03:00
@ -141,0 +173,4 @@
"common/armv8/ih264_weighted_bi_pred_av8.s"
"common/armv8/ih264_weighted_pred_av8.s"
"decoder/arm/ih264d_function_selector_a9q.c"
"decoder/arm/ih264d_function_selector_av8.c"
lbibass (Migrated from github.com) commented 2022-12-07 19:14:00 -03:00

This should (probably) be

elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")

for compilation of this submodule on macos, as it reports the CPU architecture as arm64.

This should (probably) be ```elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")``` for compilation of this submodule on macos, as it reports the CPU architecture as arm64.
lbibass (Migrated from github.com) reviewed 2022-12-07 19:15:29 -03:00
lbibass (Migrated from github.com) commented 2022-12-07 19:15:29 -03:00

the same statement as above, it should also include arm64 cpu reporting.

the same statement as above, it should also include arm64 cpu reporting.
lbibass (Migrated from github.com) reviewed 2022-12-07 19:16:15 -03:00
lbibass (Migrated from github.com) commented 2022-12-07 19:16:15 -03:00

should be changed to

elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(AARCH64)|(arm64)")

should be changed to ```elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(AARCH64)|(arm64)")```
lbibass commented 2022-12-08 13:15:56 -03:00 (Migrated from github.com)

ih264 is throwing a lot of errors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its assembly.

error: ADR/ADRP relocations must be GOT relative

Seems that a lot of the ARM-specific code would have to be rewritten for macOS compatibility. I do not have the technical skills to do this unfortunately.

ih264 is throwing a lot of errors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its assembly. ```error: ADR/ADRP relocations must be GOT relative``` Seems that a lot of the ARM-specific code would have to be rewritten for macOS compatibility. I do not have the technical skills to do this unfortunately.
iamqk commented 2022-12-09 03:09:13 -03:00 (Migrated from github.com)

ors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its

Hi @lbibass , I'm working on build apple silicon version of Cemu.
This is my working git address, https://github.com/iamqk/Cemu.
You can find buildable code in aarch64 branch.

> ors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its Hi @lbibass , I'm working on build apple silicon version of Cemu. This is my working git address, https://github.com/iamqk/Cemu. You can find buildable code in aarch64 branch.
lbibass commented 2022-12-14 15:21:37 -03:00 (Migrated from github.com)

ors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its

Hi @lbibass , I'm working on build apple silicon version of Cemu. This is my working git address, https://github.com/iamqk/Cemu. You can find buildable code in aarch64 branch.

This did compile, but crashed immediately when trying to load into BOTW.

> > ors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its > > Hi @lbibass , I'm working on build apple silicon version of Cemu. This is my working git address, https://github.com/iamqk/Cemu. You can find buildable code in aarch64 branch. This did compile, but crashed immediately when trying to load into BOTW.
iamqk commented 2022-12-25 21:43:55 -03:00 (Migrated from github.com)

ors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its

Hi @lbibass , I'm working on build apple silicon version of Cemu. This is my working git address, https://github.com/iamqk/Cemu. You can find buildable code in aarch64 branch.

This did compile, but crashed immediately when trying to load into BOTW.

try start with --force-interpreter

> > > ors when compiling arm64 code on macOS. It seems that the assembly code is not compatible with how Apple compiles its > > > > > > Hi @lbibass , I'm working on build apple silicon version of Cemu. This is my working git address, https://github.com/iamqk/Cemu. You can find buildable code in aarch64 branch. > > This did compile, but crashed immediately when trying to load into BOTW. try start with --force-interpreter
leomeneguzzi commented 2023-02-21 14:52:32 -03:00 (Migrated from github.com)

@iamqk I was able to compile and run, but crashed when I tried to load
I notice that if I go to "graphics settings" tab, the "Graphics API" don't load "Vulkan", just OpenGL

@iamqk I was able to compile and run, but crashed when I tried to load I notice that if I go to "graphics settings" tab, the "Graphics API" don't load "Vulkan", just OpenGL
leomeneguzzi commented 2023-02-21 15:28:05 -03:00 (Migrated from github.com)

@iamqk I got the log, the problem seems to be Vulkan loader not available, do you face it too?

[15:24:18.593] Invariant TSC not supported
[15:24:18.642] ------- Init Cemu 2.0 (experimental) -------
[15:24:18.642] Init Wii U memory space (base: 0x0000000280000000)
[15:24:18.642] mlc01 path: /Users/leo/wii-emulator/mlc
[15:24:18.642] Used CPU extensions: 
[15:24:18.642] IOSU_CRYPTO: No otp.bin found. Online mode cannot be used
[15:24:18.642] IOSU_CRYPTO: No Seeprom.bin found. Online mode cannot be used
[15:24:18.683] Failed to read valid PlayDiary header
[15:24:18.918] Vulkan loader not available.
[15:24:23.245] Vulkan cant list devices because Vulkan loader failed
[15:24:40.069] can't store custom mlc path in permanent storage: can't get LOCALAPPDATA
[15:24:40.867] Mounting title 00050000101c9400
[15:24:40.867] Base: /Users/leo/wii-emulator/mlc/usr/title/00050000/101c9400 [Folder]
[15:24:40.867] Update: /Users/leo/wii-emulator/mlc/usr/title/0005000e/101c9400 [Folder]
[15:24:40.867] DLC: /Users/leo/wii-emulator/mlc/usr/title/0005000c/101c9400 [Folder]
[15:24:42.102] Load /internal/current_title/code/U-King.rpx Code-Offset: -0x0
[15:24:42.196] COS: System fonts found. Generated shareddata (26609KB)
[15:24:42.206] Creating OpenGL canvas
[15:24:42.209] ------- Loaded title -------
[15:24:42.209] TitleId: 00050000-101c9400
[15:24:42.209] TitleVersion: v208
[15:24:42.209] TitleRegion: US
[15:24:42.209] Save path:   /Users/leo/wii-emulator/mlc/usr/save/00050000/101C9400/user/
[15:24:42.209] Shader cache file: shaderCache/transferable/00050000101c9400.bin
[15:24:42.209] gameprofile path: gameProfiles/default/00050000101c9400.ini
[15:24:42.209] RPX hash (updated): fb7911ad
[15:24:42.209] RPX hash (base): dcac9927
[15:24:42.544] Loaded module 'u-king' with checksum 0x6267bfd0
[15:24:42.544] RPL link time: 323ms
[15:24:42.597] HLE: Patch BotW busy loop 2 at 0x030df674
[15:24:42.708] HLE scan time: 164ms
[15:24:42.708] ------- Active settings -------
[15:24:42.708] CPU-Mode: Multi-core recompiler
[15:24:42.708] Load shared libraries: true
[15:24:42.708] Use precompiled shaders: auto (gameprofile)
[15:24:42.708] Full sync at GX2DrawDone: true
[15:24:42.708] Console language: English
@iamqk I got the log, the problem seems to be `Vulkan loader not available`, do you face it too? ``` [15:24:18.593] Invariant TSC not supported [15:24:18.642] ------- Init Cemu 2.0 (experimental) ------- [15:24:18.642] Init Wii U memory space (base: 0x0000000280000000) [15:24:18.642] mlc01 path: /Users/leo/wii-emulator/mlc [15:24:18.642] Used CPU extensions: [15:24:18.642] IOSU_CRYPTO: No otp.bin found. Online mode cannot be used [15:24:18.642] IOSU_CRYPTO: No Seeprom.bin found. Online mode cannot be used [15:24:18.683] Failed to read valid PlayDiary header [15:24:18.918] Vulkan loader not available. [15:24:23.245] Vulkan cant list devices because Vulkan loader failed [15:24:40.069] can't store custom mlc path in permanent storage: can't get LOCALAPPDATA [15:24:40.867] Mounting title 00050000101c9400 [15:24:40.867] Base: /Users/leo/wii-emulator/mlc/usr/title/00050000/101c9400 [Folder] [15:24:40.867] Update: /Users/leo/wii-emulator/mlc/usr/title/0005000e/101c9400 [Folder] [15:24:40.867] DLC: /Users/leo/wii-emulator/mlc/usr/title/0005000c/101c9400 [Folder] [15:24:42.102] Load /internal/current_title/code/U-King.rpx Code-Offset: -0x0 [15:24:42.196] COS: System fonts found. Generated shareddata (26609KB) [15:24:42.206] Creating OpenGL canvas [15:24:42.209] ------- Loaded title ------- [15:24:42.209] TitleId: 00050000-101c9400 [15:24:42.209] TitleVersion: v208 [15:24:42.209] TitleRegion: US [15:24:42.209] Save path: /Users/leo/wii-emulator/mlc/usr/save/00050000/101C9400/user/ [15:24:42.209] Shader cache file: shaderCache/transferable/00050000101c9400.bin [15:24:42.209] gameprofile path: gameProfiles/default/00050000101c9400.ini [15:24:42.209] RPX hash (updated): fb7911ad [15:24:42.209] RPX hash (base): dcac9927 [15:24:42.544] Loaded module 'u-king' with checksum 0x6267bfd0 [15:24:42.544] RPL link time: 323ms [15:24:42.597] HLE: Patch BotW busy loop 2 at 0x030df674 [15:24:42.708] HLE scan time: 164ms [15:24:42.708] ------- Active settings ------- [15:24:42.708] CPU-Mode: Multi-core recompiler [15:24:42.708] Load shared libraries: true [15:24:42.708] Use precompiled shaders: auto (gameprofile) [15:24:42.708] Full sync at GX2DrawDone: true [15:24:42.708] Console language: English ```
iamqk commented 2023-02-22 04:18:09 -03:00 (Migrated from github.com)

@iamqk I got the log, the problem seems to be Vulkan loader not available, do you face it too?

[15:24:18.593] Invariant TSC not supported
[15:24:18.642] ------- Init Cemu 2.0 (experimental) -------
[15:24:18.642] Init Wii U memory space (base: 0x0000000280000000)
[15:24:18.642] mlc01 path: /Users/leo/wii-emulator/mlc
[15:24:18.642] Used CPU extensions: 
[15:24:18.642] IOSU_CRYPTO: No otp.bin found. Online mode cannot be used
[15:24:18.642] IOSU_CRYPTO: No Seeprom.bin found. Online mode cannot be used
[15:24:18.683] Failed to read valid PlayDiary header
[15:24:18.918] Vulkan loader not available.
[15:24:23.245] Vulkan cant list devices because Vulkan loader failed
[15:24:40.069] can't store custom mlc path in permanent storage: can't get LOCALAPPDATA
[15:24:40.867] Mounting title 00050000101c9400
[15:24:40.867] Base: /Users/leo/wii-emulator/mlc/usr/title/00050000/101c9400 [Folder]
[15:24:40.867] Update: /Users/leo/wii-emulator/mlc/usr/title/0005000e/101c9400 [Folder]
[15:24:40.867] DLC: /Users/leo/wii-emulator/mlc/usr/title/0005000c/101c9400 [Folder]
[15:24:42.102] Load /internal/current_title/code/U-King.rpx Code-Offset: -0x0
[15:24:42.196] COS: System fonts found. Generated shareddata (26609KB)
[15:24:42.206] Creating OpenGL canvas
[15:24:42.209] ------- Loaded title -------
[15:24:42.209] TitleId: 00050000-101c9400
[15:24:42.209] TitleVersion: v208
[15:24:42.209] TitleRegion: US
[15:24:42.209] Save path:   /Users/leo/wii-emulator/mlc/usr/save/00050000/101C9400/user/
[15:24:42.209] Shader cache file: shaderCache/transferable/00050000101c9400.bin
[15:24:42.209] gameprofile path: gameProfiles/default/00050000101c9400.ini
[15:24:42.209] RPX hash (updated): fb7911ad
[15:24:42.209] RPX hash (base): dcac9927
[15:24:42.544] Loaded module 'u-king' with checksum 0x6267bfd0
[15:24:42.544] RPL link time: 323ms
[15:24:42.597] HLE: Patch BotW busy loop 2 at 0x030df674
[15:24:42.708] HLE scan time: 164ms
[15:24:42.708] ------- Active settings -------
[15:24:42.708] CPU-Mode: Multi-core recompiler
[15:24:42.708] Load shared libraries: true
[15:24:42.708] Use precompiled shaders: auto (gameprofile)
[15:24:42.708] Full sync at GX2DrawDone: true
[15:24:42.708] Console language: English

Sorry, now deal to work reason, I do not have dev environment at hand.
But as much as I can recall, I think you should install vulkan for Mac from link below.
https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html
https://vulkan.lunarg.com/sdk/home
After install this SDK, you should have vulkan option in the menu.

> @iamqk I got the log, the problem seems to be `Vulkan loader not available`, do you face it too? > > ``` > [15:24:18.593] Invariant TSC not supported > [15:24:18.642] ------- Init Cemu 2.0 (experimental) ------- > [15:24:18.642] Init Wii U memory space (base: 0x0000000280000000) > [15:24:18.642] mlc01 path: /Users/leo/wii-emulator/mlc > [15:24:18.642] Used CPU extensions: > [15:24:18.642] IOSU_CRYPTO: No otp.bin found. Online mode cannot be used > [15:24:18.642] IOSU_CRYPTO: No Seeprom.bin found. Online mode cannot be used > [15:24:18.683] Failed to read valid PlayDiary header > [15:24:18.918] Vulkan loader not available. > [15:24:23.245] Vulkan cant list devices because Vulkan loader failed > [15:24:40.069] can't store custom mlc path in permanent storage: can't get LOCALAPPDATA > [15:24:40.867] Mounting title 00050000101c9400 > [15:24:40.867] Base: /Users/leo/wii-emulator/mlc/usr/title/00050000/101c9400 [Folder] > [15:24:40.867] Update: /Users/leo/wii-emulator/mlc/usr/title/0005000e/101c9400 [Folder] > [15:24:40.867] DLC: /Users/leo/wii-emulator/mlc/usr/title/0005000c/101c9400 [Folder] > [15:24:42.102] Load /internal/current_title/code/U-King.rpx Code-Offset: -0x0 > [15:24:42.196] COS: System fonts found. Generated shareddata (26609KB) > [15:24:42.206] Creating OpenGL canvas > [15:24:42.209] ------- Loaded title ------- > [15:24:42.209] TitleId: 00050000-101c9400 > [15:24:42.209] TitleVersion: v208 > [15:24:42.209] TitleRegion: US > [15:24:42.209] Save path: /Users/leo/wii-emulator/mlc/usr/save/00050000/101C9400/user/ > [15:24:42.209] Shader cache file: shaderCache/transferable/00050000101c9400.bin > [15:24:42.209] gameprofile path: gameProfiles/default/00050000101c9400.ini > [15:24:42.209] RPX hash (updated): fb7911ad > [15:24:42.209] RPX hash (base): dcac9927 > [15:24:42.544] Loaded module 'u-king' with checksum 0x6267bfd0 > [15:24:42.544] RPL link time: 323ms > [15:24:42.597] HLE: Patch BotW busy loop 2 at 0x030df674 > [15:24:42.708] HLE scan time: 164ms > [15:24:42.708] ------- Active settings ------- > [15:24:42.708] CPU-Mode: Multi-core recompiler > [15:24:42.708] Load shared libraries: true > [15:24:42.708] Use precompiled shaders: auto (gameprofile) > [15:24:42.708] Full sync at GX2DrawDone: true > [15:24:42.708] Console language: English > ``` Sorry, now deal to work reason, I do not have dev environment at hand. But as much as I can recall, I think you should install vulkan for Mac from link below. https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html https://vulkan.lunarg.com/sdk/home After install this SDK, you should have vulkan option in the menu.
Tillsunset commented 2023-02-22 14:16:24 -03:00 (Migrated from github.com)

@leomeneguzzi make sure you have molten-vk installed. It is included in the pre-releases, but since you were building it yourself, you need to install it separately. The vulkan sdk shouldn't be needed. Instructions to get a working build are here. If you're still having trouble head over to the troubleshooting channel of the official discord.

@leomeneguzzi make sure you have [molten-vk](https://formulae.brew.sh/formula/molten-vk) installed. It is included in the pre-releases, but since you were building it yourself, you need to install it separately. The vulkan sdk shouldn't be needed. Instructions to get a working build are [here](https://github.com/cemu-project/Cemu/blob/main/BUILD.md). If you're still having trouble head over to the troubleshooting channel of the official discord.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: cemu-project_Mirror/Cemu-2024-03-05#559
No description provided.