GpuBufferDeferredCloser

Defers closing or recycling of GPU buffers until the GPU has finished using them.

This class uses fences to ensure that a buffer is not closed/recycled while it is still referenced by in-flight GPU work. Call add after the last use of a buffer in the current frame, then call tryClose in a later frame after command submission.

Both methods must be called on the render thread.

Constructors

Link copied to clipboard
constructor()
Creates a deferred closer with default action close.
constructor(closeAction: Consumer<GpuBuffer>)
Creates a deferred closer.

Functions

Link copied to clipboard
open fun add(buffer: GpuBuffer)
Defers closing/recycling of the given buffer until all GPU work submitted before this call has completed.
open fun add(buffers: Collection<GpuBuffer>)
Defers closing/recycling all given buffers behind a single fence.
Link copied to clipboard
open fun close()
Link copied to clipboard
open fun tryClose()
Non-blockingly checks all pending buffers and runs the configured action on those whose fences have completed.