UnleashedRecomp icon indicating copy to clipboard operation
UnleashedRecomp copied to clipboard

Add support for macOS.

Open squidbus opened this issue 10 months ago • 166 comments

Adds working macOS support.

  • Needs PR: https://github.com/hedge-dev/XenonRecomp/pull/22

squidbus avatar Mar 03 '25 07:03 squidbus

Can you provide details on how you managed to build directx-dxc? I was able to build it but the required cmake config files were missing

to-fuu avatar Mar 03 '25 08:03 to-fuu

Can you provide details on how you managed to build directx-dxc? I was able to build it but the required cmake config files were missing

I cloned DirectXShaderCompiler and built it like so:

mkdir build && cd build
cmake -C ../cmake/caches/PredefinedParams.cmake ..
make -j10

squidbus avatar Mar 03 '25 08:03 squidbus

Can you provide details on how you managed to build directx-dxc? I was able to build it but the required cmake config files were missing

I cloned DirectXShaderCompiler and built it like so:

mkdir build && cd build
cmake -C ../cmake/caches/PredefinedParams.cmake ..
make -j10

This error keeps coming

CMake Error at tools/XenosRecomp/XenosRecomp/CMakeLists.txt:22 (find_package):
  Could not find a package configuration file provided by "directx-dxc" with
  any of the following names:

    directx-dxcConfig.cmake
    directx-dxc-config.cmake

  Add the installation prefix of "directx-dxc" to CMAKE_PREFIX_PATH or set
  "directx-dxc_DIR" to a directory containing one of the above files.  If
  "directx-dxc" provides a separate development package or SDK, be sure it
  has been installed.

to-fuu avatar Mar 03 '25 12:03 to-fuu

This error keeps coming

After you build directx-dxc separately you need to tell CMake where to find it. Point the directx-dxc_DIR environment variable to wherever you built it.

IsaacMarovitz avatar Mar 03 '25 12:03 IsaacMarovitz

This error keeps coming

After you build directx-dxc separately you need to tell CMake where to find it. Point the directx-dxc_DIR environment variable to wherever you built it.

Exactly what I did. I'm probably missing something

to-fuu avatar Mar 03 '25 12:03 to-fuu

Current status: With everything here and in linked PRs in the original post, along with a build of latest MoltenVK and a fixed SPIRV-Cross, able to get fully working ARM Debug/RelWithDebInfo builds. Release builds still have an issue causing crash on game start that I need to look into.

squidbus avatar Mar 04 '25 02:03 squidbus

Hi @squidbus, where can I get the fixed SPIRV-Cross from? I am building from the latest commit on the main branch and am getting the following error when trying to load files:

program_source:26:43: error: as_type cast from 'ulong' (aka 'unsigned long') to 'device int2 *' is not allowed
    int2 _55 = int2(gl_FragCoord.xy) - (*(as_type<device int2*>(reinterpret_cast<ulong>(g_PushConstants.SharedConstants + 16ul))));
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
program_source:30:29: error: as_type cast from 'ulong' (aka 'unsigned long') to 'device int2 *' is not allowed
        _66 = any(_55 >= (*(as_type<device int2*>(reinterpret_cast<ulong>(g_PushConstants.SharedConstants + 24ul)))));
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
program_source:45:34: error: as_type cast from 'ulong' (aka 'unsigned long') to 'device float3 *' is not allowed
    float3 _81 = powr(_77.xyz, *(as_type<device float3*>(reinterpret_cast<ulong>(g_PushConstants.SharedConstants))));
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Yash-Singh1 avatar Mar 04 '25 15:03 Yash-Singh1

Hi @squidbus, where can I get the fixed SPIRV-Cross from? I am building from the latest commit on the main branch and am getting the following error when trying to load files:

https://github.com/KhronosGroup/SPIRV-Cross/pull/2452

IsaacMarovitz avatar Mar 04 '25 15:03 IsaacMarovitz

Still will need some other PR merges to be ready but should be able to build and run this without modifications now.

squidbus avatar Mar 04 '25 16:03 squidbus

I can confirm. I was able to get to the alias issue by doing some changes here and there but as of the latest commit, the build works without any modifications and the installer launches

to-fuu avatar Mar 04 '25 16:03 to-fuu

I was able to get in game, and play until the loop in the first level. Some of the first few cutscenes are a bit choppy, but it's more smooth during gameplay. After that, it crashes with a EXC_BAD_ACCESS.

Yash-Singh1 avatar Mar 04 '25 16:03 Yash-Singh1

@squidbus @Yash-Singh1 Tried release build The cutscenes lag and the crashes are gone. The game so far runs at a perfect 120fps without any issues. I was able to finish apotos act 2 image

to-fuu avatar Mar 04 '25 16:03 to-fuu

Looks good to me on M1 2020!

image

Ramen2X avatar Mar 04 '25 18:03 Ramen2X

wait how do i get the macos build up and running

phamtheman69 avatar Mar 04 '25 22:03 phamtheman69

wait how do i get the macos build up and running

Something along the lines of

brew install cmake ninja freetype
git clone --recurse-submodules https://github.com/hedge-dev/UnleashedRecomp
cd UnleashedRecomp
git remote add squidbus https://github.com/squidbus/UnleashedRecomp/
git fetch squidbus
git checkout squidbus/mac-support

Add the private files needed in UnleashedRecompLib

cmake . --preset macos-release
cmake --build ./out/build/macos-release/ --target UnleashedRecomp

IsaacMarovitz avatar Mar 04 '25 22:03 IsaacMarovitz

cmake . --preset macos-release

I'm getting this error. I am building on arm btw CMake Error at tools/XenosRecomp/XenosRecomp/CMakeLists.txt:21 (find_package): Could not find a package configuration file provided by "directx-dxc" with any of the following names:

directx-dxcConfig.cmake
directx-dxc-config.cmake

Add the installation prefix of "directx-dxc" to CMAKE_PREFIX_PATH or set "directx-dxc_DIR" to a directory containing one of the above files. If "directx-dxc" provides a separate development package or SDK, be sure it has been installed.

EDIT: Nevermind I forgot to clone one of the PRs haha

fm360 avatar Mar 04 '25 23:03 fm360

isaac, when i do those commands it gives me this

Last login: Wed Feb 26 13:41:42 on ttys000 jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha ~ % brew install cmake ninja git clone --recurse-submodules https://github.com/hedge-dev/UnleashedRecomp cd UnleashedRecomp git remote add squidbus https://github.com/squidbus/UnleashedRecomp/ git fetch squidbus git checkout squidbus/mac-support cmake . --preset macos-release cmake --build ./out/build/macos-release/ --target UnleashedRecomp Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake or specify the --cask flag. To silence this message, use the --formula flag. Warning: cmake 3.31.6 is already installed and up-to-date. To reinstall 3.31.6, run: brew reinstall cmake Warning: ninja 1.12.1 is already installed and up-to-date. To reinstall 1.12.1, run: brew reinstall ninja fatal: destination path 'UnleashedRecomp' already exists and is not an empty directory. error: remote squidbus already exists. error: Your local changes to the following files would be overwritten by checkout: CMakeLists.txt Please commit your changes or stash them before you switch branches. Aborting CMake Error: No such preset in /Users/jaydenpham/UnleashedRecomp: "macos-release" Error: /Users/jaydenpham/UnleashedRecomp/out/build/macos-release is not a directory jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp % cmake . --preset macos-release cmake --build ./out/build/macos-release/ --target UnleashedRecomp CMake Error: No such preset in /Users/jaydenpham/UnleashedRecomp: "macos-release" Error: /Users/jaydenpham/UnleashedRecomp/out/build/macos-release is not a directory jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp %

it says that unleashed recomp out build macos is not a directory

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

@phamtheman69 Delete the UnleashedRecomp directory and rerun the commands one by one and post where you get the error.

Yash-Singh1 avatar Mar 05 '25 00:03 Yash-Singh1

isaac, when i do those commands it gives me this

Last login: Wed Feb 26 13:41:42 on ttys000

jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha ~ % brew install cmake ninja

git clone --recurse-submodules https://github.com/hedge-dev/UnleashedRecomp

cd UnleashedRecomp

git remote add squidbus https://github.com/squidbus/UnleashedRecomp/

git fetch squidbus

git checkout squidbus/mac-support

cmake . --preset macos-release

cmake --build ./out/build/macos-release/ --target UnleashedRecomp

Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake or specify the --cask flag. To silence this message, use the --formula flag.

Warning: cmake 3.31.6 is already installed and up-to-date.

To reinstall 3.31.6, run:

brew reinstall cmake

Warning: ninja 1.12.1 is already installed and up-to-date.

To reinstall 1.12.1, run:

brew reinstall ninja

fatal: destination path 'UnleashedRecomp' already exists and is not an empty directory.

error: remote squidbus already exists.

error: Your local changes to the following files would be overwritten by checkout:

CMakeLists.txt

Please commit your changes or stash them before you switch branches.

Aborting

CMake Error: No such preset in /Users/jaydenpham/UnleashedRecomp: "macos-release"

Error: /Users/jaydenpham/UnleashedRecomp/out/build/macos-release is not a directory

jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp % cmake . --preset macos-release

cmake --build ./out/build/macos-release/ --target UnleashedRecomp

CMake Error: No such preset in /Users/jaydenpham/UnleashedRecomp: "macos-release"

Error: /Users/jaydenpham/UnleashedRecomp/out/build/macos-release is not a directory

jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp %

it says that unleashed recomp out build macos is not a directory

Did you checkout to the mac-support branch?

to-fuu avatar Mar 05 '25 00:03 to-fuu

it says that unleashed recomp out build macos is not a directory

Don't just copy paste the whole block that wont necessarily work, input line by line and respond accordingly if any issues crop up.

IsaacMarovitz avatar Mar 05 '25 00:03 IsaacMarovitz

jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp % git fetch squidbus remote: Enumerating objects: 139, done. remote: Counting objects: 100% (55/55), done. remote: Compressing objects: 100% (24/24), done. remote: Total 139 (delta 38), reused 34 (delta 31), pack-reused 84 (from 2) Receiving objects: 100% (139/139), 1.61 MiB | 6.96 MiB/s, done. Resolving deltas: 100% (68/68), completed with 14 local objects. From https://github.com/squidbus/UnleashedRecomp

  • [new branch] mac-support -> squidbus/mac-support
  • [new branch] macos -> squidbus/macos
  • [new branch] main -> squidbus/main Fetching submodule tools/XenonRecomp Fetching submodule tools/XenosRecomp Could not access submodule 'thirdparty/MoltenVK/MoltenVK' at commit afc7241 Could not access submodule 'thirdparty/MoltenVK/SPIRV-Cross' at commit f92141b Could not access submodule 'thirdparty/dxc-bin' at commit ffc5656 From https://github.com/hedge-dev/XenosRecomp
  • branch 3223c18c1c4531343089d93ddd02a7ac882ba5ee -> FETCH_HEAD
  • branch 702e0e5174d2a0af6928aa736f5c518ceb6a6f0c -> FETCH_HEAD From https://github.com/hedge-dev/XenonRecomp
  • branch 8237abe22e6ed222b0afb984c2e56617d049c54b -> FETCH_HEAD

is this the error? it says could not access some submodels

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

Performing Test CXX_FLAG_WA_NOEXECSTACK - Success -- CMAKE_INSTALL_PREFIX: /Users/jaydenpham/UnleashedRecomp/out/install/macos-release -- CMAKE_INSTALL_LIBDIR: lib -- ZSTD_LEGACY_SUPPORT defined! -- ZSTD_MULTITHREAD_SUPPORT is enabled CMake Error at tools/XenosRecomp/XenosRecomp/CMakeLists.txt:21 (find_package): Could not find a package configuration file provided by "directx-dxc" with any of the following names:

directx-dxcConfig.cmake
directx-dxc-config.cmake

Add the installation prefix of "directx-dxc" to CMAKE_PREFIX_PATH or set "directx-dxc_DIR" to a directory containing one of the above files. If "directx-dxc" provides a separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred! jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp %

Performing Test COMPILER_SUPPORTS_FOBJC_ARC - Success -- Configuring SDL2_mixer 2.8.0 -- Enabled ogg music: using stb_vorbis -- MoltenVK revision: 7f1226b CMake Error at thirdparty/MoltenVK/CMakeLists.txt:17 (file): file failed to open for reading (No such file or directory):

/Users/jaydenpham/UnleashedRecomp/thirdparty/MoltenVK/MoltenVK/MoltenVK/MoltenVK/API/mvk_private_api.h

-- MoltenVK version: .. CMake Error at thirdparty/MoltenVK/CMakeLists.txt:41 (add_subdirectory): The source directory

/Users/jaydenpham/UnleashedRecomp/thirdparty/MoltenVK/SPIRV-Cross

does not contain a CMakeLists.txt file.

I continued with the other commands and ran into more errors

this is from "cmake . --preset macos-release cmake --build ./out/build/macos-release/ --target UnleashedRecomp"

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

cmake . --preset macos-release

I'm getting this error. I am building on arm btw CMake Error at tools/XenosRecomp/XenosRecomp/CMakeLists.txt:21 (find_package): Could not find a package configuration file provided by "directx-dxc" with any of the following names:

directx-dxcConfig.cmake
directx-dxc-config.cmake

Add the installation prefix of "directx-dxc" to CMAKE_PREFIX_PATH or set "directx-dxc_DIR" to a directory containing one of the above files. If "directx-dxc" provides a separate development package or SDK, be sure it has been installed.

EDIT: Nevermind I forgot to clone one of the PRs haha

fm how did you fix this? I'm getting the same issue. what pr and what terminal command did you use to fix this?

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

You need to git checkout squidbus/mac-support

IsaacMarovitz avatar Mar 05 '25 00:03 IsaacMarovitz

jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp % git checkout squidbus/mac-support M tools/XenonRecomp M tools/XenosRecomp HEAD is now at 7f1226b Initial macOS build workflow.

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

that was the result

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp % brew install cmake ninja freetype ==> Downloading https://formulae.brew.sh/api/formula.jws.json ==> Downloading https://formulae.brew.sh/api/cask.jws.json Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake or specify the --cask flag. To silence this message, use the --formula flag. Warning: cmake 3.31.6 is already installed and up-to-date. To reinstall 3.31.6, run: brew reinstall cmake Warning: ninja 1.12.1 is already installed and up-to-date. To reinstall 1.12.1, run: brew reinstall ninja Warning: freetype 2.13.3 is already installed and up-to-date. To reinstall 2.13.3, run: brew reinstall freetype jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha UnleashedRecomp % cmake --build ./out/build/macos-release/ --target UnleashedRecomp ninja: error: loading 'build.ninja': No such file or directory

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

You need to run the first cmake command before the build command

IsaacMarovitz avatar Mar 05 '25 00:03 IsaacMarovitz

ok wait ill start again

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69

i did all those again and then did the cmake preset first and then i got these

-- Check size of long long - done -- Using vendored vorbis + vorbisfile CMake Deprecation Warning at thirdparty/SDL_mixer/external/vorbis/CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake.

Update the VERSION argument value. Or, use the ... syntax to tell CMake that the project requires at least but has been updated to work with policies introduced by or earlier.

-- Configuring vorbis 1.3.7 -- MoltenVK revision: 7f1226b CMake Error at thirdparty/MoltenVK/CMakeLists.txt:17 (file): file failed to open for reading (No such file or directory):

/Users/jaydenpham/UnleashedRecomp/thirdparty/MoltenVK/MoltenVK/MoltenVK/MoltenVK/API/mvk_private_api.h

-- MoltenVK version: .. CMake Error at thirdparty/MoltenVK/CMakeLists.txt:41 (add_subdirectory): The source directory

/Users/jaydenpham/UnleashedRecomp/thirdparty/MoltenVK/SPIRV-Cross

does not contain a CMakeLists.txt file.

-- {fmt} version: 11.0.2 -- Build type: Release CMake Deprecation Warning at tools/XenonRecomp/thirdparty/xxHash/cmake_unofficial/CMakeLists.txt:8 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake.

Update the VERSION argument value. Or, use the ... syntax to tell CMake that the project requires at least but has been updated to work with policies introduced by or earlier.

-- xxHash build type: Release -- Architecture: x86_64 CMake Deprecation Warning at tools/XenonRecomp/XenonRecomp/CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake.

Update the VERSION argument value. Or, use the ... syntax to tell CMake that the project requires at least but has been updated to work with policies introduced by or earlier.

-- ZSTD VERSION: 1.5.7 -- CMAKE_INSTALL_PREFIX: /Users/jaydenpham/UnleashedRecomp/out/install/macos-release -- CMAKE_INSTALL_LIBDIR: lib -- ZSTD_LEGACY_SUPPORT defined! -- ZSTD_MULTITHREAD_SUPPORT is enabled CMake Error at tools/XenosRecomp/XenosRecomp/CMakeLists.txt:21 (find_package): Could not find a package configuration file provided by "directx-dxc" with any of the following names:

directx-dxcConfig.cmake
directx-dxc-config.cmake

Add the installation prefix of "directx-dxc" to CMAKE_PREFIX_PATH or set "directx-dxc_DIR" to a directory containing one of the above files. If "directx-dxc" provides a separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred!

how do i get the direct x shader compiler? I already did the git checkout squidbus/mac support thingy before so idk what im doing wrong

phamtheman69 avatar Mar 05 '25 00:03 phamtheman69