Entities (Graphics) + GPU Resident Drawer + GPU Instancing?

Does it make any sense to combine entities and the GPU Resident Drawer in one project? From my understanding the GPU Resident Drawer is basically doing the same with game objects as how entities are handled anyway. So the GPU Resident Drawer should not affect or change anything to how entities in a sub scene are rendered at all right?

I had a weird behaviour where the ground mesh in a sub scene was rendered black as soon as I enabled the GPU Resident Drawer but everything was fine when it was disabled or when I moved the ground mesh outside the sub scene. This contradicts my understanding somehow that the GPU Resident Drawer is basically doing the same with game objects as how entities are handled anyway and shouldn’t really affect entities. But something seams to happen there.

I thought it could still be beneficial to have the GPU Resident Drawer enabled if you also still have some game objects or e.g. an user interface beside entities (which I have), but didn’t expect it to affect the entities in the sub scene. And while looking at the Profile Analyzer and comparing GPU Resident Drawer enabled/disabled, it seams to be even slower when it is enabled.

And one more question: “Enable GPU Instancing” on a shader only works if the shader
isn’t compatible with the SRP Batcher. So it doesn’t make sense in an ecs based project at all, right?

Regarding the GPU Instancing, we don’t have to use Entities Graphics to render entities, so GPU Instancing could make sense. GPU Instancing works if the material is incompatible with the SRP Batcher (the shader can remain compatible). I’ve not tested out Entities Graphics yet so I’m unsure how this works there.

The docs seem to indicate that Entities Graphics requires the SRP Batcher because it uses the BatchRendererGroup API, which uses DOTS Instancing as opposed to direct GPU Instancing.

I have been interested to see the performance of this vs. the GPU Instancer asset, which has been the fastest form of GPU Instancing I’ve tested (I’ve not tested the GPU Resident Drawer (GPU RD)).

GPU RD is interesting because the GPU Instancer asset, for example, recommends only using it for objects with large instance counts; whereas GPU RD seems to instance everything. This could cause a performance regression as you noted.

Regarding the black ground mesh, the docs state:


The GPU Resident Drawer works only with the following:


If you are using URP, you may need to try Forward+; but the docs do state that the GPU RD should apply only to GameObjects. It’s possible that you have found a bug.

Thanks for the reply, should have mentioned that I have an ecs based project using all the ecs packages including entities graphics. And I don’t think (but not entirely sure) that GPU Instancing has any benefit in that case.

Regarding the resident drawer, I do have quite some objects like healthbars in combination with entities, so I thought they could benefit from it. My project and objects all meet the mentioned requirements.

Not sure if it’s a bug, would be nice to get an official answer, so I could create a bug report if that’s unusual.

I guess my understanding is not that wrong, but I miss something in the official documentation that explicitly differentiates the 3 “concepts” mentioned in the title from each other or clarifies possible combinations or similarities.

Entities Graphics and GPU RD are both tech that simply converts high-level data into BatchRendererGroup draw commands and GPU buffers. BatchRendererGroup is an object that you can have multiple instances of, and each of these owns their own. They do not interact with each other in any way.

If enabling and disabling GPU RD is causing entities to render differently, that sounds like a bug in the engine backend. Report it.

As for whether it makes sense to use both in the same project, I would say only if you have a bunch of thinks that cannot be entities but can somehow still be rendered with GPU RD. To be honest, I don’t have a clue what that would even be. But then again, I’m a little out-of-date with vanilla Entities Graphics as my own stack can handle more use cases entities-side.

I should also note that Entities Graphics and GPU RD are not very effective at small scales, as they schedule a lot of jobs to do their work, and scheduling jobs are still slow (even with the latest announced improvements).

BatchRendererGroup always uses “DOTS Instancing”, which ignores the “Enable Instancing” property on materials and always does its own thing. This thing is special, because it combines instancing within the SRP batcher infrastructure using clever graphics memory tricks. It can still be advantageous even when all the meshes are unique, but the benefits grow as you start to have small duplicates. Compared to traditional instancing, BRG especially shines when you have 2-10 instances of something, as tacking on instances has very low overhead in BRG. Whereas with traditional instancing, that means making a bunch of small arrays and swapping between them, which can be expensive.

4 Likes

Thanks, that really helped! So to sum it up very simply: neither “Enable Instancing” nor the GPU RD should have any effect on entities in a sub scene, right?

So as you both said, guess I should write a bug report then ;-).