|
CeresEngine 0.2.0
A game development framework
|
A template class that automatically manages a buffer pool. More...
#include <CeresEngine/RenderAPI/GPUBufferObject.hpp>
Public Types | |
| using | RawBuffer = B< UInt8[]> |
| The buffer type. | |
Public Member Functions | |
| GPUBufferPool (GPUDevice &device) | |
Creates a new BufferPool object. | |
| GPUBufferPool (GPUDevice &device, const GPUBufferSize baseAllocationSize) | |
Creates a new BufferPool object. | |
| void | reserve (const GPUBufferSize length) |
| Reserves space in the pool. | |
| template<typename T > | |
| B< T > | allocate () |
| Allocates a new object from the pool. | |
| void | reset () noexcept |
| Resets the buffer pool. | |
| bool | empty () const noexcept |
| Checks if the buffer pool is empty. | |
| void | flush (const GPUBufferSize offset=0, const GPUBufferSize size=GPUBuffer::whole) |
Flushes the cached memory data starting at offset with size bytes. | |
| void | invalidate (const GPUBufferSize offset=0, const GPUBufferSize size=GPUBuffer::whole) |
Invalidates the cached memory data starting at offset with size bytes. | |
Private Member Functions | |
| void | allocateBuffers (const size_t newLength) |
Private Attributes | |
| GPUDevicePtr | device = nullptr |
| The device to be used when allocating memory. | |
| Vector< RawBuffer > | buffers {} |
| A vector of allocated buffers. | |
| GPUBufferSize | next = 0 |
| The offset of the next allocated object. | |
| GPUBufferSize | length = 0 |
| The maximum buffer length. | |
| const GPUBufferSize | baseAlignment = 256 |
| The base alignment to be used for each object in pool. | |
| const GPUBufferSize | baseAllocationSize = 4 * 1024 * 1024 |
| The base allocation size used by the pool. | |
A template class that automatically manages a buffer pool.
This class will compute the required alignment (required by the GPU) and return references for objects of type T. In this pool, object sizes can vary and a call to allocate() will allocate a new buffer object.
| B | the underlying buffer storage type |
| using CeresEngine::GPUBufferPool< B >::RawBuffer = B<UInt8[]> |
The buffer type.
|
inlineexplicit |
Creates a new BufferPool object.
| device | The device to be used when allocating memory. |
|
inlineexplicit |
Creates a new BufferPool object.
| device | The device to be used when allocating memory. |
| baseAllocationSize | The base allocation size used by the pool. |
|
inline |
Allocates a new object from the pool.
|
inlineprivate |
|
inlinenoexcept |
Checks if the buffer pool is empty.
true if the buffer pool is empty and has no allocated objects on it.
|
inline |
Flushes the cached memory data starting at offset with size bytes.
| offset | The starting offset to be flushed |
| size | The amount of bytes to be flushed |
|
inline |
Invalidates the cached memory data starting at offset with size bytes.
| offset | The starting offset to be flushed |
| size | The amount of bytes to be flushed |
|
inline |
Reserves space in the pool.
| length | The number of objects to fit in the buffer pool |
|
inlinenoexcept |
Resets the buffer pool.
Does not release any allocated buffer. This method must be called every frame to ensure that old buffers are reused.
|
private |
The base alignment to be used for each object in pool.
|
private |
The base allocation size used by the pool.
|
private |
A vector of allocated buffers.
Each buffer has mBaseAllocationSize bytes.
|
private |
The device to be used when allocating memory.
|
private |
The maximum buffer length.
|
private |
The offset of the next allocated object.