Node is not compatible with SRP batcher?

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.

Hi!
Which devices did you try?

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.

1 Like

Ah, this explains it :slight_smile:
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.

1 Like

Does that mean I need to explict put all my globals into another CBUFFER?

Only if you need to run on OpenGL ES.

Hello, do we need to explicit put all globals into a CBUFFER for batching on Vulkan (android) ?
And iOS/Metal ?

Vulkan and Metal should work the same as DX in this regard.

great, thanks!

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

Hi! :slight_smile:

Builtin for the builtin pipeline?

There was a bug specifically on GL/GLES discussed here: https://discussions.unity.com/t/837563

Ah, yes - I updated the editor and URP versions and batching appears to be working now. Sweet, thank you!

Hey @aleksandrk , i’ve rendered several meshes with exact same shaders and preferences, but some of them on some reason not compatible with srp

The shader is either compatible or not.
I think it simply doesn’t ever report incompatibility for the first draw call in a batch.