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

GpuBufferPool() = default

Methods

~GpuBufferPool

~GpuBufferPool() = default

Initialize

void Initialize(GpuDevice &device, const GpuBufferCreateInformation &createInfo, u32 suballocationsPerBuffer, u32 initialBufferCount = 1)

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

GpuBufferSuballocation 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

UPtr<TrackedGpuBufferSuballocation> 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

void Release(const GpuBufferSuballocation &allocation)

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

u32 GetSuballocationSize() const

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

u32 GetBufferCount() const

Gets the number of currently allocated buffers.

GetTotalSuballocationCount

u32 GetTotalSuballocationCount() const

Gets the total number of suballocations (used + free).

Destroy

void 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.

Private

Methods

AddNewBufferToPool

void AddNewBufferToPool()

Grows the pool by allocating a new GpuBuffer.

Fields

mDevice

GpuDevice * mDevice

mBufferCreateInformation

GpuBufferCreateInformation mBufferCreateInformation

mSuballocationSize

u32 mSuballocationSize

mSuballocationsPerBuffer

u32 mSuballocationsPerBuffer

mSuballocations

TInlineArray<SuballocationEntry, 64> mSuballocations

mBuffers

TInlineArray<BufferEntry, 1> mBuffers