Skip to content

Add support for macOS. #745

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

squidbus
Copy link
Contributor

@squidbus squidbus commented Mar 3, 2025

Adds working macOS support.

@to-fuu
Copy link

to-fuu commented Mar 3, 2025

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

@squidbus
Copy link
Contributor Author

squidbus commented Mar 3, 2025

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

@to-fuu
Copy link

to-fuu commented Mar 3, 2025

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.

@IsaacMarovitz
Copy link
Contributor

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.

@to-fuu
Copy link

to-fuu commented Mar 3, 2025

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

@squidbus
Copy link
Contributor Author

squidbus commented Mar 4, 2025

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.

@Yash-Singh1
Copy link

Yash-Singh1 commented Mar 4, 2025

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))));
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@IsaacMarovitz
Copy link
Contributor

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:

KhronosGroup/SPIRV-Cross#2452

@squidbus
Copy link
Contributor Author

squidbus commented Mar 4, 2025

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

@to-fuu
Copy link

to-fuu commented Mar 4, 2025

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

@Yash-Singh1
Copy link

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.

@to-fuu
Copy link

to-fuu commented Mar 4, 2025

@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

@ArtisIan97
Copy link

Thank you so much for your hard work in fixing the game for M1/M2, it works great now! However, I have another bug to report. I recently upgraded to an M4 Air, and on the laptop screen itself, I'm very pleased with how the improved CPU/GPU can run Sonic Unleashed. When I plugged into my external monitor, though...

Screenshot 2025-04-18 at 1 11 29 PM
Link to video here

I know the M4 is capable of more, especially at a lower resolution than the internal display. So I don't know why the framerate is dipping so much. I'm connected to a 1080p display through HDMI via a USB-C hub. My M1 never had this issue. I even set the graphics settings to what made the M1 hit 60 FPS consistently and disabled all mods, but it still maintained sub-30 FPS. The Terminal log didn't show anything abnormal, either.
Yet...if I screen record or take a screenshot, the framerate jumps back up to 60+ FPS. So when I tried to screen record for this bug report, the game fixed itself...temporarily. It's almost as if macOS didn't want me proving this was an issue. 😅 Why would that be the case?

@phamtheman69
Copy link

Are you on the latest Unleashed Recomp version?

Do you still have this issue?

@ArtisIan97
Copy link

Are you on the latest Unleashed Recomp version?

Do you still have this issue?

Yes and yes. The performance actually has gotten a bit worse since my last reboot, yet it still speeds up whenever I am screen recording. I must emphasize--this only happens with my EXTERNAL display. For some reason, it runs flawlessly when disconnected and using the internal display. I'm using an M4 MacBook Air with the 10-core GPU running macOS 15.4.1 (the latest version as of this comment).

@phamtheman69
Copy link

Are you on the latest Unleashed Recomp version?
Do you still have this issue?

Yes and yes. The performance actually has gotten a bit worse since my last reboot, yet it still speeds up whenever I am screen recording. I must emphasize--this only happens with my EXTERNAL display. For some reason, it runs flawlessly when disconnected and using the internal display. I'm using an M4 MacBook Air with the 10-core GPU running macOS 15.4.1 (the latest version as of this comment).

This sounds like an issue with the Monitor or HDMI/Usb C hub. Does your cable support HDMI 2.0 or 2.1? Some older cables can't handle 1080p 60 fps. Also what Usb C hub are you using? Some only support HDMI 1.4, which could limit you to 30 FPS. The cable or hub could be bottlenecking your performance. You should also check the refresh rate and resolution of your monitor, if it's 60hz we know it's not the monitor.

  • you should also try disabling VSync and turning your fps to 60 manually in the settings, as VSync will detect what framerate the monitor is and cap your fps accordingly.

@ArtisIan97
Copy link

I've tried three times now to respond to this and every time something glitched that made me lose what I wrote. So, I'll cut to the chase.

This sounds like an issue with the Monitor or HDMI/Usb C hub.

No, it's not, and I wrote my original message to convey that it wasn't. Yet, just to be sure, I tested with an official Apple USB-C hub I borrowed, and the same exact thing happened. I get 1080p60 output and 60 FPS in other Mac games and even Windows games through CrossOver (HDMI has always supported 1080p60, even before 1.4), but for Unleashed I somehow get worse performance than an M1.

image

As I said before:

My M1 never had this issue. I even set the graphics settings to what made the M1 hit 60 FPS consistently and disabled all mods, but it still maintained sub-30 FPS.

With the same monitor and USB-C hub, I got BETTER performance on the M1. Yet, as soon as I disconnect and run on the internal display, Unleashed runs at a locked 60 FPS with a higher resolution (2560x1600).
The other big thing, which didn't bother me until now, is that on my external display, there is a frame rate cap. It can't display at a variable frame rate; if the game ever dips below 60, it jumps right down to 30 instead of just skipping the frames. This is not an issue on the internal display. I don't know if this has to do with MoltenVK or something else...I'm not skilled with graphics programming, so I can only assume.

you should also try disabling VSync and turning your fps to 60 manually in the settings

I tried that, and it BARELY hits 60 with massive screen tearing, which distracts me more than the jarring frame rate dips. I want to know why, when I connect to an external display, the performance overall is worse on M4 compared to M1. I'd like to hear any thoughts on the matter from squidbus or another maintainer, and if there is any way I can get more logs or profiler data that would help shed light on this issue, I'd be happy to help. We do this to help make Unleashed run as best it can on Mac, right?

@squidbus
Copy link
Contributor Author

Have you tried turning off game mode when macOS automatically turns it on

@ArtisIan97
Copy link

Have you tried turning off game mode when macOS automatically turns it on

Performance is the same whether Game Mode is on or off.

@squidbus
Copy link
Contributor Author

Okay, second question: have you tried windowed mode?

@ArtisIan97
Copy link

Okay, second question: have you tried windowed mode?

Just tried it, and it helps a little bit. The performance is a bit better but it still dips every now and then. The frame rate also still locks at either 30 or 60.

@cadamsdotcom
Copy link

Hi!
Been loving watching the amazing work on this PR. Haven't even hit any issues I can report.

It's looking like these builds are really solid, working well in my tests. What's left before it can be merged and part of an official release?

Anything we can help with?

@squidbus
Copy link
Contributor Author

It's just waiting for someone to have time to review.

@cadamsdotcom
Copy link

cadamsdotcom commented May 12, 2025

Took a very quick look. No huge changes in any single file, which will help.

Does the XenosRecomp submodule path need to be changed back from your fork, @squidbus ?

Edit: same question for the XenonRecomp, so both submodules.

@squidbus
Copy link
Contributor Author

Those submodules are waiting on changes being merged to main as well. And by review I meant from the maintainers of this project.

@blueskythlikesclouds
Copy link
Member

The PRs are 100% going to be merged, I'm just taking a break from this project for a bit, so the reviews will take a while.

@cadamsdotcom
Copy link

cadamsdotcom commented May 12, 2025

@blueskythlikesclouds no worries at all, we have working builds, there is absolutely no rush, hope you’re enjoying your downtime. Thanks for coming back to respond.

Appreciate everyone’s work to get it this far.

@squidbus
Copy link
Contributor Author

Did some MoltenVK updates and have the latest build here: https://github.com/squidbus/UnleashedRecomp/actions/runs/15078018461

Would ask that anyone who had frame rate issues test again, I don't seem to have any with this current build.

@squidbus
Copy link
Contributor Author

Also if you do have frame rate issues still, it could be useful to open the profiler graph with F1 and send a screenshot of the graph and the time numbers below it.

@ArtisIan97
Copy link

Screenshot 2025-05-17 at 11 35 51 AM

Beautiful! It runs a lot smoother now, and I can even bump up a lot of the settings, like AA and shadow resolution, without it dipping below 60 FPS. Thank you so much!

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

Successfully merging this pull request may close these issues.