ndepoel / FSR3Unity

FSR 3.1 Upscaler integration for Unity built-in render pipeline, with support for DX11, Mac, Linux and consoles.
https://discussions.unity.com/t/open-source-fidelityfx-super-resolution-3-1-fsr3-upscaler-for-unity-birp-dx11-ppv2-hdrp17-multi-platform/917847
MIT License
251 stars 30 forks source link

Question: new Metal 3.1 shading language supports image atomics needed by this project? #4

Closed oscarbg closed 1 year ago

oscarbg commented 1 year ago

Hi, Thanks for your project.. Hope you can solve my doubt.. Have seen on twitter a post saying: “Metal 3.1 just received support for 64-bit atomic texture operations!!“ You say: “With Metal, the biggest limitation is its lack of texture atomics” So seems that missing are some kind of atomics you need, as other kinds of image atomics are supported, right? Also may be a hw compatibility problem with m1 or m2 missing features supported by Amd metal driver? Just questions..

thanks..

ndepoel commented 1 year ago

Hi, thanks for your message.

As it happens, I have been looking into this subject again last week and pulled out the Metal documentation from Apple as well. You're right that Metal 3.1 supports atomic texture operations and that those would be suitable for implementing the missing InterlockedAdd/Min/Max functions that I had to work around.

The problem is that Unity does not implement support for Metal 3. Unity's documentation is rather unclear about which exact Metal version they support, but the general consensus is that it's some version of Metal 2. Metal 2 does actually have some atomic functions as well that may work, but either way we're limited by what Unity's shader cross-compiler will output and as soon as you use one of the Interlocked functions, you'll inevitably get an error message saying:

HLSLcc: Texture atomics are not supported in Metal at kernel CS (on metal)

My guess is that Unity favors broad compatibility with older devices over supporting all of the latest features, which would be why they don't support Metal 3 yet. Or maybe they simply don't have the manpower to fully support Mac with all of its latest features. It would be great to see some conditional shader compilation features being added to Unity on Mac so we can make use of more advanced techniques in Metal, but for the time being that's just not possible.

So perhaps I could have been a bit more clear in my documentation about what the limitation is: it's not Metal that's lacking texture atomics, it's Unity's implementation of the Metal API that's lacking support for atomic texture functions.

oscarbg commented 1 year ago

Thanks for detailed response.. now makes sense..