XII Release 0.1.0
Loading...
Searching...
No Matches
xiiGALVertexBufferPool< VertexType, MutexType, AllocatorWrapper > Class Template Reference

A templated vertex buffer pool that manages dynamic vertex allocations. This divides its memory into one or more chunks to minimize reallocation and supports thread-safe allocation, update, and tracking of vertex usage. More...

#include <VertexBufferPool.h>

Classes

struct  AllocationHandle
 A handle for a vertex allocation. More...
 
struct  UsageStatistics
 Aggregated usage statistics for the pool. More...
 

Public Member Functions

 xiiGALVertexBufferPool (xiiStringView sName={}, xiiAllocatorBase *pAllocator=AllocatorWrapper::GetAllocator(), xiiUInt32 uiInitialChunkSize=1024, xiiUInt32 uiExpansionFactor=2U)
 Constructs the vertex buffer pool.
 
AllocationHandle Allocate (xiiUInt32 uiCount)
 Allocates a block of vertices from the pool.
 
void Update (const AllocationHandle &handle, xiiArrayPtr< const VertexType > pData, xiiSharedPtr< xiiGALCommandList > pCommandList)
 Updates the data stored in a given allocation.
 
xiiArrayPtr< const VertexType > GetAllocationPointer (const AllocationHandle &handle) const
 Returns a read-only pointer to the allocated vertex data.
 
xiiSharedPtr< xiiGALBufferGetGPUBuffer (const AllocationHandle &handle) const
 
void Reset ()
 
xiiGALVertexBufferPool::UsageStatistics GetUsageStatistics () const
 

Detailed Description

template<typename VertexType, typename MutexType = xiiNoMutex, typename AllocatorWrapper = xiiDefaultAllocatorWrapper>
class xiiGALVertexBufferPool< VertexType, MutexType, AllocatorWrapper >

A templated vertex buffer pool that manages dynamic vertex allocations. This divides its memory into one or more chunks to minimize reallocation and supports thread-safe allocation, update, and tracking of vertex usage.

Constructor & Destructor Documentation

◆ xiiGALVertexBufferPool()

template<typename VertexType, typename MutexType, typename AllocatorWrapper>
XII_ALWAYS_INLINE xiiGALVertexBufferPool< VertexType, MutexType, AllocatorWrapper >::xiiGALVertexBufferPool ( xiiStringView sName = {},
xiiAllocatorBase * pAllocator = AllocatorWrapper::GetAllocator(),
xiiUInt32 uiInitialChunkSize = 1024,
xiiUInt32 uiExpansionFactor = 2U )

Constructs the vertex buffer pool.

Parameters
uiInitialChunkSize- The number of vertices in the first (and minimum) chunk.
uiExpansionFactor- Determines the size of new chunks (e.g. 2 means double the previous chunk).

Member Function Documentation

◆ Allocate()

template<typename VertexType, typename MutexType = xiiNoMutex, typename AllocatorWrapper = xiiDefaultAllocatorWrapper>
AllocationHandle xiiGALVertexBufferPool< VertexType, MutexType, AllocatorWrapper >::Allocate ( xiiUInt32 uiCount)

Allocates a block of vertices from the pool.

Parameters
uiCount- The number of vertices requested.
Returns
An AllocationHandle that describes where the vertices live.

◆ GetAllocationPointer()

template<typename VertexType, typename MutexType, typename AllocatorWrapper>
XII_ALWAYS_INLINE xiiArrayPtr< const VertexType > xiiGALVertexBufferPool< VertexType, MutexType, AllocatorWrapper >::GetAllocationPointer ( const AllocationHandle & handle) const

Returns a read-only pointer to the allocated vertex data.

Note
Use with caution – modifications via the pointer are not protected by the pool’s mutex.

◆ Update()

template<typename VertexType, typename MutexType, typename AllocatorWrapper>
XII_ALWAYS_INLINE void xiiGALVertexBufferPool< VertexType, MutexType, AllocatorWrapper >::Update ( const AllocationHandle & handle,
xiiArrayPtr< const VertexType > pData,
xiiSharedPtr< xiiGALCommandList > pCommandList )

Updates the data stored in a given allocation.

Parameters
handle- The allocation handle previously returned by Allocate().
pData- An array containing the new vertex data.

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