Performance for optimized shadow-casting lights with Entities Graphics?

This is 24 shadow-casting lights in Unity 6 and Entities Graphics.


It seems that each light performs its own culling one-by-one, causing new jobs to get spun up each time. And the overhead of scheduling these jobs takes up a significant amount of time.

While I’m sharing this with vanilla Entities Graphics, I normally use a heavily modified solution that also experiences this problem. So feel free to provide advanced suggestions.

1 Like

Hello! (I’m super new to this tech) but the devs I checked in with thought the syncs between OnPerformCulling calls were interesting and there may be a potential optimisation to be made. Would you be willing to submit a bug for us so we could take a look?

Done. IN-87351

Feel free to reach out to me via PM if you need more info or understanding of what is going on!

1 Like

Hi!

Having 24 real time shadow lights is not quite common, but you’re right that performance are not really good in this un-usual case. We have few different ideas to improve this:

  • make the entities.graphics culling callback code Burst compatible. It should improve perf significantly and mos timportant reduce the main-thread time
  • cleanup a bit the job chain sequence and maybe tweak a bit ScheduleJob granularity (to reduce a bit all “bubbles” between jobs in your screenshot
  • Also add a new kind of callback to BRG like “OnPerformCullingMulti” to reduce a bit the amount of callback calls.

From these 3 points I think the first one will have the most impact pon performance.

I can’t tell you any ETA but at least it’s on our radar.

I’ve done 1 and 2 personally. The first reduced the time per callback on my modified implementation from 160 microseconds down to about 110. The second shaved off another 15 microseconds (though I didn’t go all-in on it. I discussed it in detail here: Latios-Framework-Documentation/Optimization Adventures/Part 15 - Frustum Culling 2.md at main · Dreaming381/Latios-Framework-Documentation · GitHub

I’ve heard there are some new performance improvements to the job system coming. Once those are all out, I will benchmark again. But if they aren’t significant enough, I think option 3 will be necessary.