DepthOfFieldEffect did not destroy DepthRenderer

I used the Default Rendering pipeline and enabled DepthOfField, then disposed of the Default Rendering pipeline according to the situation, but at this point, the DepthRenderer in the scene was not destroyed.

I saw the DepthRenderer used during the creation process:

When disposing:


look again SSAORenderingPipeline:

Determine whether to destroy DepthRender based on the dispose paramete:

Suggest increasing the count to determine if DepthRenderer has been referenced by other methods. If it has been referenced, transfer the processing authority to the user to disable DepthRenderer

The depth renderer is a shared ressource, and enableDepthRenderer is used to get a pointer on the renderer (it won’t create a renderer if it already exists).

The current existing code (in Babylon and user code) dealing with depth renderers would probably break if we ref-counted the renderer, because it’s possible enableDepthRenderer is called multiple times instead of storing the pointer when the renderer is needed at different location in the code. It’s not a problem at the time, but it would be if we added ref-counting.

So, it’s currently the user responsibility to destroy the depth renderer. Note that once frame graph is added to Babylon (we are actively working on it!), this problem won’t exist anymore.

2 Likes

When can it be completed? I’m looking forward to it :grin:

We don’t have a fixed date, it will take months because it’s such a big task. But I think we’re planning to deliver something for the next version of Babylon (around March/April).

Okay, got it :ok_hand: :ok_hand: