Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Shader not working with MacOS & Metal?

Discussion in 'Shaders' started by ManjitSBedi, Nov 8, 2022.

  1. ManjitSBedi

    ManjitSBedi

    Joined:
    Mar 8, 2014
    Posts:
    58
    Hi, I have a shader that is made with ShaderLab & it works on Windows but not on MacOS with Metal. This error happens:

    Code (JavaScript):
    1. Metal: Vertex or Fragment Shader "AppName/WaveShader" requires a   ComputeBuffer at index 1 to be bound, but none provided. Skipping draw calls to avoid crashing.
    We are using a ComputeBuffer; I am guessing this is where the problem is with Metal on MacOs
    Code (CSharp):
    1. buffer = new ComputeBuffer(numberOfSamples, SamplePoint.GetSize());
    2.  
    3. buffer.SetData(SamplePointsList);
    4.  
    5. _waveformImage.materialForRendering.SetInt("_Channels", (int)channels);
    6.  
    7. _waveformImage.materialForRendering.SetInt("_SampleCount", numberOfSamples);
    8.  
    9. _waveformImage.materialForRendering.SetBuffer("_SamplesBuffer", buffer);
    I see that there are options with using registers in a shader; I don't know if this is where the issue is??
    Code (JavaScript):
    1. #if defined(SHADER_API_D3D11) || defined(SHADER_API_METAL)
    2.  
    3. StructuredBuffer<samplepoint> _SamplesBuffer;
    4.  
    5. #endif

    e.g

    Code (JavaScript):
    1. StructuredBuffer<samplepoint> _SamplesBuffer : register(t);
    I did experiment with adding a register parameter but I don't know what the the correct parameters are with Metal.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    Hi!
    I would suggest to file a bug report.
     
  3. HariskapSky

    HariskapSky

    Joined:
    Oct 17, 2022
    Posts:
    1
    Its unity error clearly. We has the same issue and with fixed it by removing the material from the mesh renderer in our case. If you have the material attached in the materials list, it spams the error that you have posted. if we assign material in runtime everything seems to be good.
    Code (CSharp):
    1.     meshRenderer.material = material;
     

    Attached Files:

  4. ManjitSBedi

    ManjitSBedi

    Joined:
    Mar 8, 2014
    Posts:
    58
    Hello and thanks for the replies. The problem turned out to be more complex. The issue originates elsewhere in the project which would manifest in a Metal shader error. It was to do with the use of Unicode strings and how they would be bridged to a C++ DLL; it would work correctly in Windows but not MacOS.

    The shader code would not function properly as the input data used to create a render was faulty.
     
  5. Rendfox2

    Rendfox2

    Joined:
    Feb 2, 2014
    Posts:
    1
    Terrific! Thank you @HariskapSky. This worked for me on 2022.1.9f1