struct render::GpuUniformBuffer

Base class for all uniform buffers.

Public

Methods

~GpuUniformBuffer

virtual ~GpuUniformBuffer() noexcept

Initialize

virtual void Initialize() = 0

Destroy

virtual void Destroy()

GetSize

u32 GetSize() const

Returns the size of the uniform buffer, in bytes.

CreateBuffer

SPtr<GpuBuffer> CreateBuffer(GpuBufferFlags flags = GpuBufferFlag::StoreOnCPUWithGPUAccess) const

Allocates a new buffer that can store all the members defined in this uniform buffer.

For buffers that are modified every frame prefer using AllocateTransient() instead.

CreateBuffer

SPtr<GpuBuffer> CreateBuffer(u32 count, GpuBufferFlags flags = GpuBufferFlag::StoreOnCPUWithGPUAccess) const

Allocates a new buffer that can store all the members defined in this uniform buffer.

The buffer will have multiple sub-allocations, so it may store multiple instances of the data (e.g. one for each different objects). For buffers that are modified every frame prefer using AllocateTransient() instead.

AllocateTransient

GpuBufferSuballocation AllocateTransient()

Allocates a transient uniform buffer suballocation from the internal pool.

The transient allocation will remain valid for RenderThread::kMaximumFramesInFlight frames, after which it may be reused for other allocations. You should use this for uniform buffers that are updated every frame.

Note that transient buffer allocations might be larger than size returned by GetSize(), due to alignment requirements.

Protected

Fields

mBufferSize

u32 mBufferSize

mTransientAllocationPool

TransientGpuBufferPool mTransientAllocationPool