Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS patches #11222

Closed
wants to merge 3 commits into from
Closed

macOS patches #11222

wants to merge 3 commits into from

Conversation

nastys
Copy link
Contributor

@nastys nastys commented Dec 2, 2021

The macOS patches we've been working on on Discord.
This fork:branch is for reference — the actual patches will be uploaded as separate pull requests.

- [x] Building with GCC 11 (requires patching a couple of Qt libraries: qcoreapplication.h, qtconcurrentthreadengine.h; and a couple of 3rdparty libraries; ffmpeg needs to be rebuilt) I recommend using Homebrew clang/llvm instead, it's much more reliable

  • Building with Homebrew clang/llvm (brew install llvm — it doesn't even need most of the patches in this fork, so you can build master instead; tested with and without the patched Qt libraries above)
  • Fast interpreter
  • SPU ASMJIT
  • FAudio
  • Keyboard input (arrows keys not working)
  • DS4 controller input (USB)
  • Threaded downloader (linker errors when building with GCC, but works fine with brew clang/llvm — currently patched not to use Thread on macOS in this fork, so it's recommended to build master instead)
  • Cubeb (-DUSE_AUDIOUNIT=ON, not working with GCC)
  • SPU LLVM
  • PPU LLVM (generates huge logs, for some reason)
  • Bluetooth controller input
  • CI
  • DS3 controller input (USB; keeps flashing)
  • Generic controller handler (USB)
  • Discord integration (linker errors — untested with brew clang/llvm)
  • Building with clang/Xcode SDK (some semaphore functions required by RPCN are not available, and Vulkan fails with "Unknown context dma 0x%x")

Graphics:

  • Vulkan via moltenVK (currently requires "select" to be renamed "sel":rmacs3/"selection":master due to a bug in SPIRV-Cross, and existing Apple patches for correct colour rendering)
  • Unsupported texture/colour surface format conversion (mostly done)
  • VkLogicOp emulation
  • On-Disk Shader Cache (must be disabled in Config -> Advanced)
  • OpenGL (will probably never work — should probably be removed from macOS builds)

Games:

  • Project DIVA F
  • Project DIVA Dreamy Theater (missing projected shadows)
  • The Simpsons Game (minor graphical errors)
  • P****** 5 (only boots sometimes, maybe due to a race condition seems to work reliably with brew clang/llvm)
  • Kingdom Hearts 2.5
  • Tekken Tag Tournament 2 (requires "Write Color Buffers" for some textures)

Building

Build instructions are for x64. aarch64 may work with some changes once support for it is added to the emulator.
Install Homebrew.
Note that on M1, x64 Homebrew is required. Run the following command to install it:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Afterwards, the following script can be used to install any x64 dependencies. Copy the following text to TextEdit or nano:

eval "$(/usr/local/Homebrew/bin/brew shellenv)"
arch -x86_64 brew "$@"

save it as ~/brewx64.sh and run it like this to install the dependencies (one or two may be missing):

sh brewx64.sh install llvm sdl2 nasm molten-vk vulkan-headers qt@5 ninja glew cmake git

Env for building with Homebrew clang/llvm:

export CXX=clang++
export CC=clang
export Qt5_DIR="/usr/local/Cellar/qt@5/5.15.2_1/lib/cmake/Qt5"
export PATH="/usr/local/opt/llvm/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin"
export LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include -msse -msse2 -mcx16"
export CXXFLAGS="-I/usr/local/opt/llvm/include -msse -msse2 -mcx16"
export VULKAN_SDK="$HOME/VulkanSDK/1.2.198.1/macOS" # change the version if yours is different
export VK_ICD_FILENAMES="$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json"

Clone the repository:

git clone --recursive -b rmacs3 https://github.com/nastys/rpcs3.git

Fix dependencies:

sed -i '' "s/if(APPLE)/if(CMAKE_C_COMPILER_ID MATCHES \"AppleClang\")/g" rpcs3/3rdparty/wolfssl/wolfssl/CMakeLists.txt
sed -i '' "s/extern const double NSAppKitVersionNumber;/const double NSAppKitVersionNumber = 1343;/g" rpcs3/3rdparty/hidapi/hidapi/mac/hid.c

Copy libc++abi.1.0.dylib from /usr/local/Cellar/llvm/13.0.0_2/lib to bin/rpcs3.app/Contents/Frameworks/libc++abi.1.dylib after building (if RPCS3 crashes).
Vulkan requires the Vulkan SDK (if you get an error when you install it, just ignore it).
Finally:

mkdir rpcs3_build
cd rpcs3_build
cmake -DUSE_DISCORD_RPC=OFF -DUSE_VULKAN=ON -DUSE_ALSA=OFF -DUSE_PULSE=OFF -DUSE_AUDIOUNIT=ON -DCXXFLAGS="-msse -msse2 -mcx16" -G Ninja -DLLVM_CCACHE_BUILD=OFF -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_BUILD_RUNTIME=OFF -DLLVM_BUILD_TOOLS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TOOLS=OFF -DLLVM_INCLUDE_UTILS=OFF -DLLVM_USE_PERF=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF -DCMAKE_CXX_STANDARD=20 ../rpcs3/
ninja

Use LLVM for PPU and ASMJIT for SPU until LLVM is fixed; disable On-Disk Shader Cache until fixed.
If you've previously attempted to use PPU LLVM (before it was fixed), you'll need to clear the old cache or it'll crash.
Also check the wiki for game-specific settings.

@MSuih MSuih added the OS: macOS label Dec 2, 2021
@Vestrel
Copy link
Contributor

Vestrel commented Dec 3, 2021

Cubeb has macOS native api support. Idk why it tries to build with pulse/alsa.

@nastys
Copy link
Contributor Author

nastys commented Dec 3, 2021

Cubeb has macOS native api support. Idk why it tries to build with pulse/alsa.

It does build with PulseAudio and ALSA disabled, but it fails to initialize.

E Cubeb: cubeb_init() failed: 0xffffffff
E SYS: Audio renderer Cubeb could not be initialized, using a Null renderer instead

@Vestrel
Copy link
Contributor

Vestrel commented Dec 3, 2021

Try enabling AudioUnit

@nastys nastys mentioned this pull request Dec 5, 2021
4 tasks
@kd-11 kd-11 self-requested a review December 10, 2021 22:21
@nastys nastys closed this Dec 23, 2021
@nastys nastys reopened this Dec 23, 2021
@RPCS3 RPCS3 deleted a comment from adamtheman123 Jan 2, 2022
@kode54
Copy link

kode54 commented Jan 2, 2022

If the .zip that zip -r is producing doesn't extract a working .app bundle, maybe try ditto -c -k --sequesterRsrc --keepParent --zlibCompressionLevel 9 instead? It probably won't affect this package, but there's some Unicode normalization issue I remember there being with zip vs ditto.

@elliott44k
Copy link

For the controller support, if it's OS 12 then I believe that this is a known issue currently.

Current short term fix is provided https://github.com/libsdl-org/SDL/issues/4923#issuecomment-966722634.

@illusion0001
Copy link
Contributor

libsdl-org/SDL#4923 (comment) working url

@iMonZ
Copy link

iMonZ commented Jan 5, 2022

Hey
Is it possible to create a brew formula for easier testing and to resolve the Notarization issue?

@iMonZ
Copy link

iMonZ commented Jan 5, 2022

Question:
Would it be easier if RPCS3 would use SDL instead of cubeb?

@nastys nastys closed this Jan 8, 2022
@iMonZ
Copy link

iMonZ commented Jan 9, 2022

@nastys why have you closed it?
It worked so great it could be merged.

@kode54
Copy link

kode54 commented Jan 9, 2022

@iMonZ If you compare the branches, the only difference between the main branch and nastys' macOS branch is that the main contains newer commits, and nastys' branch contains the rewrite of the CI scripts for macOS building. I'm not sure how much of it was unmerged before, but those CI changes still need to be applied to the main project. The branch still exists on their RPCS3 fork. It could probably use a rebase to get those newer changes.

It would be nice to know why the PR was closed instead of rebased, though.

@nastys
Copy link
Contributor Author

nastys commented Jan 9, 2022

Because these changes have already been merged.

@kode54
Copy link

kode54 commented Jan 20, 2022

And yet when I attempt to run a build produced from the latest master commit, it throws a "Verification failed" error for vec_alloc from simd.hpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants