Lumen & Nanite on MacOS

I forgot to update the device selection! Try again with the new patch.

Also, I think I messed up the test on the AMD GPU. Atomics might potentially work there after all.

Got a bit further:
2023-03-07 19:47:49.806537+0100 Atomics[65013:1197051] Metal GPU Frame Capture Enabled

2023-03-07 19:47:49.806841+0100 Atomics[65013:1197051] Metal API Validation Enabled

Atomics/main.swift:95: Fatal error: Unexpectedly found nil while unwrapping an Optional value

2023-03-07 19:47:49.829117+0100 Atomics[65013:1197051] Atomics/main.swift:95: Fatal error: Unexpectedly found nil while unwrapping an Optional value

(lldb)

You sure the Metal shader is copied into the Xcode project and checked for inclusion in the current Xcode scheme?

Ah sorry. Not so familiar with XCode. Here’s the new output:

2023-03-08 21:55:39.386229+0100 Atomics[65754:1292291] Metal GPU Frame Capture Enabled

2023-03-08 21:55:39.386585+0100 Atomics[65754:1292291] Metal API Validation Enabled

Deviation: (colorDeviation: 0.0, depthDeviation: 0.0)

There were 187 data races with error code 1.

Test 1 took 6 milliseconds.

Deviation: (colorDeviation: 0.0, depthDeviation: 0.0)

There were 145 data races with error code 1.

Test 2 took 3 milliseconds.

Deviation: (colorDeviation: 0.0, depthDeviation: 0.0)

There were 133 data races with error code 1.

Test 3 took 3 milliseconds.

Deviation: (colorDeviation: 0.0, depthDeviation: 0.0)

There were 197 data races with error code 1.

Test 4 took 3 milliseconds.

Deviation: (colorDeviation: 0.0, depthDeviation: 0.0)

There were 151 data races with error code 1.

Test 5 took 3 milliseconds.

Program ended with exit code: 0

You tested the 64-bit atomic emulation, which succeeded. Can you disable the variable for emulating64BitAtomics and - if it succeeds - provide a screenshot (Shift + Cmd + 4) containing the script + its console output?

1 Like

here you go. I guess this means it’s not supported natively?

It is supported!!! Thanks so much for your help! Do you have a GitHub username for me to give you credit?

Updated uarch docs with this discovery: GitHub - philipturner/metal-benchmarks: Apple GPU microarchitecture

1 Like

Ooh cool! That’s great news actually. I thought the second last line was bad news haha
My username is jelmer3000 :slight_smile:

So… is there a way to make Nanite work (efficiently) on MacOS running on M2 SOCs?

edit: how can you check if Nanite is working? Because I have this heavy project that I opened on UE5.2 on MacOS on M2:

  • lots of meshes have Nanite enabled
  • those meshes show in the viewport Lit mode etc, everything looks like it does on Windows
  • However, nanite visualization does not show anything.

Since the project is running smoothly and the meshes are showing, is Nanite then secretly working? How to check?
I’m not so familiar with these debug tools, but don’t these stats say a lot? M2 Max 38 cores.
Screenshot 2023-03-14 at 16.49.23

Hi Menesis

I need your review on using this machine for UE5. I am planning to buy one of same config, but with 32GB memory

For me, using my Mac for UE is just a test so I can’t say too much about it. I work on a VR app am using UE primarily on Windows with a Desktop RTX3070.
I also do notice some visual artifacts in UE5.2 on Mac versus 5.1.1 on Windows, some firefly-effect in specular parts of the shaders in the distance it seems.
I must say that I am impressed with how my current project runs on the M2 mac, it feels just as smooth as on my desktop RTX 3070, but don’t have any hard data to draw a comparison between the M2(38) and an RT3070 in UE.

Nanite is in a half-enabled state. I detail it extensively on my README, it will probably answer your questions

3 Likes

Thanks mate for the info.

Definitely a huge performance improvement in 5.2 preview on Mac.

4 Likes

Hi all, I have some news to report from Epic. A checkin just went in to both the 5.2 and ue5-main branches on github that adds very experimental and (for now) unsupported, disabled-by-default capability for Nanite on M2-based Macs. Here’s a link to the 5.2 commit. (If you don’t have github access that will give you a 404 error.) There are many caveats about this, but someone was bound to notice it so we may as well stay ahead of the messaging curve here.

The only way to enable it is to modify the code and build the engine from source. The modifications are as follows:

  1. Set PLATFORM_MAC_ENABLE_EXPERIMENTAL_NANITE_SUPPORT=1 in UEBuildMac.cs
    source.
  2. Enable UE_EXPERIMENTAL_MAC_NANITE_SUPPORT in spirv_msl.hpp
  3. Rebuild ShaderConductor per the instructions in UEBuildMac.cs where the Nanite define is.

And just to reiterate, this will only work on M2 hardware.

There are no guarantees about performance or it even working at all. It is really just there as a foundational step for further development. That said, you are welcome to try it out and report any feedback here.

Thanks for your patience about this topic.

7 Likes

Well, a small step forward is better than no step at all! Thanks! :grin:

1 Like

How do I get GitHub access anyhoo?

1 Like

Hey there @SpideyComic_1511! Just follow the steps here and the system will automatically invite your account, just remember to accept the invite via email or Github notification. Unreal Engine on GitHub - Unreal Engine

2 Likes

Many thanks! :heart:

2 Likes

Thanks for finally getting this started! The hardware atomics would be easiest to begin with, but I do hope you expand to older Macs. The current commit added the logic for accessing from a buffer instead of a texture.

Next, I would recommend trying to debug my in-place emulated 64-bit atomics, then incorporating them into UE5. They were working in my other repo but I cannot understand why they’re failing when isolated from that repo (not enough time to investigate). My original idea (the only emulated atomic64 currently working, which splits up into non-contiguous representation) does not seem maintainable from a software engineering perspective. However, the original idea is also the only one that would run on Intel Macs.

5 Likes