![]() |
ezEngine
Release 25.03
|
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... | |
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:
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.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. 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.
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.
void ezGALBufferPool::Initialize | ( | const ezGALBufferCreationDescription & | desc, |
ezStringView | sDebugName | ||
) |
Initializes the pool. Will not create any buffers yet. You need to call GetNewBuffer
first.
desc | The descriptor of all buffers in the pool. |
sDebugName | A 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. |