BRG OnFinishedCulling Question

Hopefully this is a simple question for one of the developers to answer, but it is not documented anywhere.

What is the state of BatchCullingOutput in OnFinishedCulling? Has it already been processed? Or is it still safe to modify if I hold onto a reference to it?

The main reason I ask is that I would like to defer allocating and populating graphics buffers until this step, but some of the draw command types require specifying GraphicsBufferHandles in the output. I would like to “patch” the output with handles I generate (well really, fetch from a pool) after I know which draw commands I have determined to be visible. Is this reasonable? Or do I need to allocate everything upfront somehow?

Sounds fine to me! Unity only starts using BatchCullingOutput.drawCommands after OnFinishedCulling is done. Beware though that this is only true for the specific view for which the callback is invoked.

For example let’s say the OnFinishedCulling callback is invoked for a light, it is not safe to read/write the draw commands output of a camera, or any other light.

You want to make sure that the draw command output you’re patching from OnFinishedCulling is the one that comes from the corresponding OnPerformCulling call.

It can be identified using customCullingResult. The one you output from OnPerformCulling will be passed to its OnFinishedCulling call.