class render::TransientGpuBufferPool

Pool allocator for GPU buffer suballocations.

Allocates suballocations transiently - each allocation is valid for one frame and automatically recycled after all in-flight frames complete (typically 3).

Public

Constructors

TransientGpuBufferPool

TransientGpuBufferPool() noexcept(false) = default

TransientGpuBufferPool

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

Constructs and immediately initializes the pool.

See Initialize().

Methods

~TransientGpuBufferPool

~TransientGpuBufferPool() noexcept = 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 for the current frame.

The suballocation is valid until AdvanceFrame() is called N times, where N is the number of frames in-flight (typically 3).

If no free suballocations are available, the pool automatically grows by allocating a new GpuBuffer.

Returns: Suballocation handle (always valid)

AdvanceFrame

void AdvanceFrame()

Advances to the next frame and recycles old suballocations.

Call once per frame after submitting all command buffers.

This marks all current allocations as not in-use for the next frame, and rebuilds the free-list to include suballocations from frame N-3 that are now safe to reuse.

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

mCurrentFrameNumber

u64 mCurrentFrameNumber

mFreeListHead

u32 mFreeListHead

mSuballocations

TInlineArray<SuballocationEntry, 4> mSuballocations

mBuffers

TInlineArray<SPtr<GpuBuffer>, 1> mBuffers