ezEngine  Release 25.03
ezGALBufferPool Class Reference

Manages a growing ring buffer of one or more buffers. The behaviour of the class changes depending on whether Initialize is called with or without a ezGALBufferUsageFlags::Transient buffer descriptor: More...

#include <BufferPool.h>

Public Member Functions

void Initialize (const ezGALBufferCreationDescription &desc, ezStringView sDebugName)
 Initializes the pool. Will not create any buffers yet. You need to call GetNewBuffer first. More...
 
void Deinitialize ()
 Destroys all buffers in this pool.
 
bool IsInitialized () const
 Returns whether the buffer pool is initialized.
 
ezGALBufferHandle GetNewBuffer () const
 Adds a new buffer to the pool and makes it the current buffer. For transient pools this needs to be called at the start of every frame before use. More...
 
ezGALBufferHandle GetCurrentBuffer () const
 Returns the current buffer in the pool. For transient pools this will be invalid at the start of every frame until GetNewBuffer is called. More...
 

Detailed Description

Manages a growing ring buffer of one or more buffers. The behaviour of the class changes depending on whether Initialize is called with or without a ezGALBufferUsageFlags::Transient buffer descriptor:

  • Transient: You must call GetNewBuffer at the start of every frame and whenever your current buffer has run out of space. Use this for transient data that uses every frame.
  • Persistent: GetNewBuffer must be called once after which you can re-use it every frame and the content in it will persist. You can use this fact to allocate the buffer lazily only in case you actually need it. If you feel the need to call GetNewBuffer after the first lazy allocation, you should consider switching to a transient buffer or using a resizable buffer instead.

Member Function Documentation

◆ GetCurrentBuffer()

ezGALBufferHandle ezGALBufferPool::GetCurrentBuffer ( ) const

Returns the current buffer in the pool. For transient pools this will be invalid at the start of every frame until GetNewBuffer is called.

Returns
Handle to the current buffer.

◆ GetNewBuffer()

ezGALBufferHandle ezGALBufferPool::GetNewBuffer ( ) const

Adds a new buffer to the pool and makes it the current buffer. For transient pools this needs to be called at the start of every frame before use.

Returns
Handle to the new buffer.

◆ Initialize()

void ezGALBufferPool::Initialize ( const ezGALBufferCreationDescription desc,
ezStringView  sDebugName 
)

Initializes the pool. Will not create any buffers yet. You need to call GetNewBuffer first.

Parameters
descThe descriptor of all buffers in the pool.
sDebugNameA debug name that is prepended to all buffers created from this pool. The final name will look like this: `{sDebugName}-{UniqueID}#{BufferIndex}, where UniqueID is constant for this pool instance and BufferIndex is the creation index of the buffer inside this pool.

The documentation for this class was generated from the following files: