Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Node is not compatible with SRP batcher?

Discussion in 'General Graphics' started by jayatubi, May 9, 2020.

  1. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    I have a shader which is SRP batcher compatible and it batches fine in the Editor. After I built it to Android the frame debugger told the drawcall is not batched with an error `node is not compatible with SRP batcher`. What does the error mean?

    The graphic API for Android is set to OpenGLES3.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,061
    Hi!
    Which devices did you try?
     
  3. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    I tried the Windows Editor and the Android device with OpenGLES 3. A few hours later I found the reason. I have some useless global float uniforms in my shader and after removing them the batcher on Android became fine. But no matter I remove them or not the batcher on Windows Editor always works.
     
    zhuhaiyia1 likes this.
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,061
    Ah, this explains it :)
    SRP batcher requires everything to be in CBUFFERs. On DX11 all global variables end up in a global CBUFFER anyway, but that's not the case with OpenGL or OpenGL ES.
     
    zhuhaiyia1 likes this.
  5. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    Does that mean I need to explict put all my globals into another CBUFFER?
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,061
    Only if you need to run on OpenGL ES.
     
  7. a-chambriat

    a-chambriat

    Joined:
    Apr 27, 2014
    Posts:
    26
    Hello, do we need to explicit put all globals into a CBUFFER for batching on Vulkan (android) ?
    And iOS/Metal ?
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,061
    Vulkan and Metal should work the same as DX in this regard.
     
  9. a-chambriat

    a-chambriat

    Joined:
    Apr 27, 2014
    Posts:
    26
    great, thanks!
     
  10. viliusnbg

    viliusnbg

    Joined:
    Nov 3, 2020
    Posts:
    2
    Hey @aleksandrk - long time no see! Does this mean that even the builtin default shaders will not get SRP batched on OpenGL ES? I've tried adding a bunch of cubes with the URP lit material and running the scene on an Oculus Quest 2 and I get the same message - "SRP: Node is not compatible with SRP batcher".

    If this sounds like a bug, I could make a simple repro project.
    If it's intentional - what are the steps to get the builtin shaders to work with the SRP batcher on OpenGL ES?

    Moreover, I want to write some shaders that are based on the builtin shaders and reuse as much of the unity HLSL code possible. It seems that if I include the core library, it defines the CBUFFER_START macros, but it also defines the global variables - so if I try and put them in a buffer inside my shader, I get an error that I'm redefining the existing variables.

    Hopefully I'm just missing something here. I'm on Unity 2020.3.3f1, URP 10.4.0
     
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,061
  12. viliusnbg

    viliusnbg

    Joined:
    Nov 3, 2020
    Posts:
    2