HDRP - Batching does not work

Hello, trying to get batching to work with no results :frowning:

Have a simple scene with single prefab (mesh + material) being rendered with HDRP Lit material. Material is set to use GPU Instancing. Number of batches: 6

Each time I duplicate prefab, number of batches goes up, and up, and up - by 6 each time.

Material has one diffuse map and one emission map.

No scripts, no custom shader, all standard stuff (apart from mesh and textures).

Unity v. 2019.1.7f1, HDRP v. 5.16.1

What am doing wrong?

Screenshots:

Two prefabs are there (one duplicated off another), second one is disabled:

After enabling rendering for second one:

Prefab setup:

Bump - anyone? It seems that GPU instancing is not working here. I red through manual and tutorials on batching topic and everything is set up as it should be but still no result.

No particular information can be found also in profiler or frame debugger.

GPU Instancing works however in standard Unity rendering pipeline.

Whatā€™s happening?

Also happening for me.

OK, after more testing (because I have nothing more interesting to do than investigating whatā€™s wrong: Unity rendering or Unity documentationā€¦) it seems that docs are not updated.

Batching works, but:

  • when material is checked to use GPU Instancing and SRP Batcher is enabled thereā€™s no ā€œdraw instancedā€ calls in the frame debugger visible and Stats display batched calls with - sign

  • when material is checked to use GPU Instancing and SRP Batch is disabled, you can observe ā€œdraw instancedā€ calls in the frame debugger and Stats displays batched calls properly, as documented in the manual

Anyone from Unity Dev team please comment on this - is my understanding is correct?

Use the SRP Batcher? Unity - Manual: Scriptable Render Pipeline Batcher

Hi!

Have to admit itā€™s a bit confusing and weā€™re working on improving that. First, the statistics window is not up to date when batcher is ON ( because some numbers have no meaning in batcher context, ie ā€œsaved by batcherā€ ). This is not ideal situation and weā€™re working on refactoring that statistic window to provide good metrics (with certainly new names))

Anyway if you really want to measure performance with and without batcher, I recommend you to use a small script ( SRPBatcherProfiler.cs ) . More details in that blogpost.

Regarding automatic GPU instancing, we by pass it when SRP Batcher is ON ( because in real life scene, batcher is slightly faster ). Of course you still can use explicit GPU instancing via Graphics.DrawInstanced for dedicated things.

4 Likes

Hi,

I use the HDRP Lit shader and enabled GPU instancing for objects copied and scaled - rotated around, but the batches are still enormous (like 3000) and "saved by batchingā€™ metric reports a minus -2000, is this meaning the batching is working ?

Does the documentation need to be updated ? I donā€™t see an advanced options in the HDRP asset.

1 Like

In March 2020 I have no idea- that whole thing with SRP transitioning is a one huge mess, on unity side.

Maybe some big customers with dedicated support from unity have any understanding of how to properly and efficiently use new rendering pipeline.

Little guys like myself are left with nonexistent or outdated documentation, confusing blog posts and sponsor videos, completely unhelpful forum and bug report replies. Itā€™s hit and miss game.

Great that thereā€™s raytracing tech you can show off, but not being able to properly investigate performance, without using some loose scripts, posted somewhere on the forums (because I have too much free time I can spend on hacking around instead of developing my gameā€¦) its just pathetic. And this is just a tip of the iceberg of missing or broken things in the new pipeline.

I should have stayed with built in renderer. Itā€™s at least two years, if not more, before srp become ready to production use. I wish somebody would mentioned that in multiple blog posts and videos they advertised srp in.

6 Likes

Also still waiting on figuring out whether my batching works or not. It says 48 batches and -48 saved. Does that mean that I have successfully messed up every single instancing-attempt I have done, or does it mean that it works?

Iā€™m sorry, but I have to agree. Itā€™s impossible to do any real work here, without creating all the building blocks to fit into Unity to make it work. How is there not a single particle-shader for HDRP yet? Yes, Iā€™ve tried the beta-package they made, but those donā€™t support colors, so you have to write those yourself. Thatā€™s such a weird choice to me.

I am using Unity 2019.37f1, HDRP.

I still have this problem about batching, I have a lot of objects with the exact same material and texture on them, the are not marked as static batch since they are moving, and the material is mark to GPU Instance batch. Guess what? I get exactly the same result that you guys: A high number in ā€œBatchesā€ and a negative number as high in ā€œSaved by batchingā€.

I donā€™t find any place in Settings or HDRP asset to turn on/off SRP batching neither!

Could someone from Unity shine a real light here? Please

Regards,
Carlos

+1 to this. In frame debugger it shows that SRP Batcher works and batches things, however, if you try and use RenderDoc, youā€™ll see that in fact absolutely nothing gets batched, even static stuff. Unity 2020.1b8, HDRP 8.1.0

5907665--630764--upload_2020-5-28_2-51-29.png

Making the boxes non static and enabling GPU instancing on their material does nothing as well. Theres still one drawcall per box.

cc @arnaud-carre

1 Like

Look in detail on the draw call and the definition of SRP batching youā€™ll see the difference .It indeed does 1 draw call each but reduced the states changes from 5-10 to 1. Thatā€™s what SRP batcher does, reducing CPU overhead by reducing the state changes that occurs when you change the shader.

Without SRP

With SRP

Still 2 draw calls, but overhead for each is significantly reduced.

regards

JP

1 Like

Can someone please provide me with how to use batching properly in HDRP I have looked at all the documentation and itā€™s either all outdated or very difficult to follow. Static batching no longer works in HDRP and GPU instancing seems to be causing trouble with certain people.

I have an RTX 3070 and I am getting 500 batches on simple scenes and 20K batches on larger but medium sized scenes I cannot release a game like this if profiling it is broken as the fps count is very low.
I was told about the SRP batcher but I canā€™t find it in HDRP and the docs donā€™t help or are telling me to use scripts and such and such. I thought HDRP was production ready?

After working with both pipelines for long time now, I think SRPs are nowhere even close to near production ready, URP not even has point light shadows and both URP and even more HDRP are generally extremely slow comparing to standard, both pipelines are largely useless imo for any serious project atm, i give it 1-2 years to be fully realized, if ever can be with such complexity and overhead.

Thatā€™s a real shame because I was just getting to like HDRP. I canā€™t go back however because of things like Subsurface Scattering and the beauty of the shaders. A lot of what you say is right and particle effects arenā€™t working in HDRP properly and other stuff but there hasnā€™t been anything serious until the batching issue.

Though I still didnā€™t get an answer to my question about how to use the batching?
I will have to bring out mesh combine studio if the batching is really that bad because it uses its own batching system and works on all pipelines.
If all else fails Iā€™ll have to go back to standard but weā€™ll see Iā€™ve come to far to turn back now.

If you want/need to use it - then use it. Sure, its not an ideal solution, but its really good nevertheless. We use it for our project btw:
https://www.youtube.com/watch?v=2Xhcb2iJCU4

They do, you just need to use HDRP compliant particle shaders.

Static batching still works, i dont know where you got the information that it does not. SRP Batcher is enabled by default in HDRP and can only be disabled through scripting. Anyways, batches is just one of performance metrics, open up GPU profiler and look at what exactly is taking the most time. And if you think something takes more than it should - file a bug report.

1 Like

I find only one easy way to force HDRP to use instancing - import hybrid rendering package to project, and throw all static geometry in to the entity world.

You are probably right itā€™s probably a bug because if the Batcher itā€™s enabled by default then it means Unity just canā€™t handle so many objects and they need to be combinedā€¦

In regards to the particles it looks like they are listed in the package manager instead of out of the box.

Congratulations on getting onto the PS5!

Ah I just looked up the Hybrid Renderer and I understand now. Thanks for that at first I didnā€™t understand what you meant by Hybrid Renderer I was thinking is this a new renderer that combines HDRP and URP but nope itā€™s just some troll at Unity who should get a pay cut for naming it something other than DOTS.