URP batching

I’m using an empty new URP (package version 12.1.4) project in Unity 2021.2.13f1. I’m spawning 10,000 cubes with the same material (URP/Lit). I’m trying to profile the rendering.

First thing to note is that in URP enabling GPU instancing on the material has no effect on rendering. Neither CPU time nor render thread time change at all.

On the built-in render pipeline the effect used to be dramatic. Both the CPU and render thread time got cut in half. Batches went from 20,000 to just 41.

With URP that doesn’t seem to be the case anymore, and if I understand correctly that is because of the SRP batcher. If I turn the SRP batcher off in the URP settings asset, then enabling GPU instancing has a similar effect to what it used to have. Batches go down from 20,000 to 88. CPU and render thread times go down, albeit not as much as before.

I tried to profile the SRP batcher, but none of the batching numbers in the Rendering module of the Profiler window make any sense. I grabbed the SPRBatcherProfiler from GitHub but it reports all zero when the SRP batcher is enabled. Hilariously it reports non-zero on the Standard code path when the SRP batcher is disabled.

What is going on?
How does batching work in URP?
How to profile batching in URP?

2 Likes

I found out that GPU instancing does nothing because Unity prioritizes SRP batching over GPU instancing.

Profiling the SRP batcher doesn’t work, but the Frame Debugger shows what’s going on.

Now if only the Rendering module and Stats panel would work…

2 Likes

Thanks for investigating the batching stats @JonasRara !
Could you please file a bug and reference it in this thread :slight_smile:

SRP batcher, gpu instancing, and static batching each have their own benefits and downsides. We found that for stuff like grass, it makes a lot more sense to just manually mesh combine things into big groups and let the SRP batcher work on top of that. We were having issues with the internal srp batcher’s cbuffer growing to enormous sizes haha. But after keeping the actual object count low we got really nice performance on quest 2 with tons of foliage.

I’m also using URP in Unity 2019 LTS and Unity 2021.1.28. Tested on both.
URP is made for faster performance but im not getting better performance then Build-in rendering pipeline.

Issue 01:
After switch to URP
i got 3000+ warning :warning: for overlapping UVS.

Issue 02:
In URP im getting 30fps on editor and 26fps on mobile And 1 batching.
SRP batching On
GPU instancing On
Static batching On
All baked scene

In Build-in rendering pipeline i getting 40 to 60+fps and 900 to 3000 batching.

My Scene:
I made building using same cube mesh + same material.

I spend 2 days to convert project to urp and now i see performance.
Im switching back build-in rendering pipeline.
I tested in editor + Android.

2 Likes