Would changing a GO-game, to entities+HRv1, help decrease gpu usage/rendering load?

* i know that HRv2 is better but my shaders are not compatible and I failed to convert them manually

  • i know that Entities are mainly a thing to decrease CPU load, by dividing the job on every single thread youre not maxxing one thread but instead having every thread work very little, it decreases load on main cpu thread and results in high fps * but what about gpu? * i have newest unity + HRv1 + default rendering pipeline, the reason why not using universal pipeline is my failure to convert shaders

Entities are mainly for optimising your memory access time, by structuring your data in linear way in arrays where same components are laid out one after another, so you can have less CPU idle times when it awaits for another cache line of data, because you can already have the data you need in cache line loaded to your CPU's cache.

This decrease CPU times, but in practice you just make your CPU work more in less time, because of less time it has to wait for the data to be copied from RAM to CPU cache, so it can perform some operations on it.

On top of that you have Job System which is nicely integrated into ECS systems. Maybe too nice, because at first it's not obvious what happens when you do Entities.Foreach().ScheduleParallel(). Either way it makes it easier to write safe parallel code.

And then on top of that you have Burst Compiler which can make your Job code "magically" faster. Thanks to ECS using Job System and Burst behind it you can utilize all this power for iterating over your entities.

It's of course possible to use Jobs and Burst for some performance heavy places with normal MonoBehaviour based game, but it often requires you to prepare the data you use in correct way. Entities makes it a bit easier, because data in IComponentData structs don't require any special preparation if you use them in Entities.ForEach().Schedule() or ScheduleParallel().

1 Like

HR V1 does a better job batching draw calls than traditional GameObjects if your renderers are static. For dynamic objects, it may be more of a wash. They optimized it since I last experimented with it by adding a property cache, so it might still be a win for dynamic objects, but not by much.

As for actual GPU performance (assuming you aren't draw-call bound), no. Entities do not help in any way unless you can write an algorithm that reduces the amount of work the GPU does. HR V1 already does frustum culling. HR V2 does occlusion culling, which you might be able to port to HR V1. HLODs are a new feature to DOTS that may be worth exploring. You can more efficiently swap meshes with imposters facing the camera, since that type of operation can now be run in Burst jobs. But you are never going to increase your polygon budget using DOTS.

1 Like

HRV1 is pretty slow for dynamic objects. In your case all the pieces would be dynamic, as you can't bake them to the scene.

[quote=“SebastianAaltonen”, post:4, topic: 840834]
HRV1 is pretty slow for dynamic objects. In your case all the pieces would be dynamic, as you can’t bake them to the scene.
[/quote]

hey man, according to this:
DOTS Hybrid Renderer | Hybrid Renderer | 0.11.0-preview.43 (unity3d.com)

v1 doesnt have dynamic occlussion culling, and v2 has, but thats occlussion culling, so objects behind other objects, are not rendererd.

but in my case i see massive performance improvements when i deactivate rendermesh of entities outside the frustrum/camera view aka frustrum culling

do you have any info about frustrum culling for dots (for both hr1 and hr2)?
because id swear it doesnt work

[quote=“DreamingImLatios”, post:3, topic: 840834]
HR V2 does occlusion culling, which you might be able to port to HR V1.
[/quote]

Has anyone had any success with the HRv2 occlusion culling? I tried and failed getting it to work a couple of times. It would be very helpful on some of the subscenes I work with (runtime performance is sometimes even worse than with purely GO-based scenes).

[quote=“mailfromthewilds”, post:5, topic: 840834]
do you have any info about frustrum culling for dots (for both hr1 and hr2)?
because id swear it doesnt work
[/quote]
It definitely works. The implementation is in HybridV2Culling.cs. You should be able to see it at work in the profiler under job workers like this:

7236110--871193--upload_2021-6-14_12-46-19.png

[quote=“mailfromthewilds”, post:5, topic: 840834]
but in my case i see massive performance improvements when i deactivate rendermesh of entities outside the frustrum/camera view aka frustrum culling
[/quote]
Have you measured whether these improvements are on the CPU or the GPU side? I think dynamic entities can be pretty slow at the moment (even when outside the camera frustum), are you using the StaticOptimizeEntity component (it saves a lot of CPU time)? Hybrid components are currently pretty slow as well .

[quote=“apkdev”, post:6, topic: 840834]
Has anyone had any success with the HRv2 occlusion culling? I tried and failed getting it to work a couple of times. It would be very helpful on some of the subscenes I work with (runtime performance is sometimes even worse than with purely GO-based scenes).

It definitely works. The implementation is in HybridV2Culling.cs. You should be able to see it at work in the profiler under job workers like this:

Have you measured whether these improvements are on the CPU or the GPU side? I think dynamic entities can be pretty slow at the moment (even when outside the camera frustrum), are you using the StaticOptimizeEntity component (it saves a lot of CPU time)? Hybrid components are currently pretty slow as well .
[/quote]

so is the implenentation in V2 only?

[quote=“mailfromthewilds”, post:7, topic: 840834]
so is the implenentation in V2 only?
[/quote]
I’m fairly sure that the frustum culling is always present and enabled in all Hybrid Renderer versions. I don’t think it’s even possible to disable it. The Megacity demo wouldn’t work without it.

Occlusion culling is disabled by default and requires HRv2:

#if ENABLE_UNITY_OCCLUSION && ENABLE_HYBRID_RENDERER_V2 && UNITY_2020_2_OR_NEWER && (HDRP_9_0_0_OR_NEWER || URP_9_0_0_OR_NEWER)