Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Compute shaders broken on OSX Mojave?

Discussion in 'Shaders' started by PhilippCh, Sep 11, 2020.

  1. PhilippCh

    PhilippCh

    Joined:
    Jun 14, 2013
    Posts:
    19
    I'm trying to get any compute shader to work (testing by trying to use FindKernel) on OSX Mojave using the Metal API. I'm always getting the usual "Kernel CSMain not found" error when it works just fine under Windows. Is there anything I need to be aware of when using compute shaders under OSX (I read the Unity doc for Compute Shaders and since I'm using the default compute shader for my testing purposes I think I shouldn't be doing anything wrong).

    Here's the shader I'm currently testing with:

    Code (CSharp):
    1. // Each #kernel tells which function to compile; you can have many kernels
    2. #pragma kernel CSMain
    3.  
    4. // Create a RenderTexture with enableRandomWrite flag and set it
    5. // with cs.SetTexture
    6. RWTexture2D<float4> Result;
    7.  
    8. [numthreads(8,8,1)]
    9. void CSMain (uint3 id : SV_DispatchThreadID)
    10. {
    11.     // TODO: insert actual code here!
    12.  
    13.     Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0);
    14. }
    15.  
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,660
    Hi!
    Which graphics API are you using?
     
  3. PhilippCh

    PhilippCh

    Joined:
    Jun 14, 2013
    Posts:
    19
    The shader showed Metal behind the Kernels so I automatically assumed Metal was my active API, but I had OpenGL activated per default. Switching to Metal in the Player settings fixed it, thanks a lot!
     
    aleksandrk likes this.
unityunity