class
render::GpuBufferPool
GPU buffer pool with manual or automatic lifetime management.
Returned allocations are sub-allocated from GpuBuffers, which makes them lightweight and efficient.
Usage - Non-tracked (manual release required): GpuBufferSuballocation allocation = pool.Allocate(); // ... use allocation ... pool.Release(allocation);
Usage - Tracked (automatic release on destruction): UPtr
<TrackedGpuBufferSuballocation
> allocation = pool.AllocateTracked(); // ... use allocation ... // Automatically released when allocation goes out of scope
Public
Constructors
GpuBufferPool
Methods
~GpuBufferPool
Initialize
Initializes the pool.
Must be called before use.
- device
- GPU device for querying capabilities.
- createInfo
- Buffer creation info (size is per-suballocation).
- suballocationsPerBuffer
- Number of suballocations per GpuBuffer.
- initialBufferCount
- Initial number of buffers, each with suballocations.
Allocate
Allocates a suballocation (non-tracked).
The allocation persists until manually released via Release(). If no free suballocations are available, the pool automatically grows.
Returns: Suballocation handle (always valid)
AllocateTracked
Allocates a tracked suballocation.
The allocation is automatically released when the returned object is destroyed. If no free suballocations are available, the pool automatically grows.
Returns: Tracked suballocation handle (always valid)
Release
Manually releases a suballocation.
Only needed for non-tracked allocations from Allocate(). Do NOT call this for tracked allocations - they release automatically.
- allocation
- Allocation to release (must be from this pool and currently allocated)
GetSuballocationSize
Gets the size per suballocation (aligned).
May be larger than the requested size due to GPU alignment requirements (typically 256 bytes for uniform buffers).
GetBufferCount
Gets the number of currently allocated buffers.
GetTotalSuballocationCount
Gets the total number of suballocations (used + free).
Destroy
Releases all GPU resources held by this pool.
All allocations must be released before calling this method. Call before destroying the GPU device. After this call, the pool is empty and cannot be used until Initialize() is called again.