Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RHI::Allocator Class Referenceabstract

#include <Allocator.h>

Inherited by AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.

Classes

struct  Descriptor
 

Public Member Functions

virtual void Shutdown ()=0
 
virtual VirtualAddress Allocate (size_t byteCount, size_t byteAlignment)=0
 
virtual void DeAllocate (VirtualAddress offset)=0
 
virtual void GarbageCollect ()=0
 
virtual void GarbageCollectForce ()=0
 Forces garbage collection of all allocations, regardless of the GC latency.
 
virtual size_t GetAllocationCount () const
 
virtual size_t GetAllocatedByteCount () const
 
virtual const DescriptorGetDescriptor () const =0
 Returns the descriptor used to initialize the allocator.
 
virtual float ComputeFragmentation () const
 
virtual void Clone (RHI::Allocator *newAllocator)
 Clone the current allocator to the new allocator passed in.
 
template<typename T >
T * AllocateAs (size_t byteCount, size_t byteAlignment)
 

Detailed Description

An allocator interface used for external GPU allocations. The allocator does not manage the host memory. Instead, the user specifies a base address (which may be 0, in order to allocate offsets from a base resource). The allocator interface also provides an API for garbage collection. If used to manage GPU resources, these are often deferred-released after N frames. The user may provide a garbage collection latency, which controls the number of GarbageCollect calls that must occur before an allocation is actually reclaimed. The intended use case is to garbage collect at the end of each frame.

Member Function Documentation

◆ Allocate()

virtual VirtualAddress AZ::RHI::Allocator::Allocate ( size_t  byteCount,
size_t  byteAlignment 
)
pure virtual

Allocates a virtual address relative to the base address provided at initialization time.

Parameters
byteCountThe number of bytes to allocate.
byteAlignementThe alignment used to align the allocation.

Implemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.

◆ AllocateAs()

template<typename T >
T * AZ::RHI::Allocator::AllocateAs ( size_t  byteCount,
size_t  byteAlignment 
)
inline

Helper for converting agnostic VirtualAddress type to pointer type. Will convert VirtualAddress::Null to nullptr.

◆ Clone()

virtual void AZ::RHI::Allocator::Clone ( RHI::Allocator newAllocator)
inlinevirtual

Clone the current allocator to the new allocator passed in.

Reimplemented in AZ::RHI::FreeListAllocator.

◆ ComputeFragmentation()

virtual float AZ::RHI::Allocator::ComputeFragmentation ( ) const
inlinevirtual

Compute the fragmentation present in the allocator (possibly an estimate). The returned value is expected to be a measure between 0.f and 1.f inclusive, with 0.f indicating zero fragmentation.

Reimplemented in AZ::RHI::FreeListAllocator.

◆ DeAllocate()

virtual void AZ::RHI::Allocator::DeAllocate ( VirtualAddress  offset)
pure virtual

Deallocates an allocation. The memory is not reclaimed until garbage collect is called. Depending on the garbage collection latency, it may take several garbage collection cycles before the memory is reclaimed.

Implemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.

◆ GarbageCollect()

virtual void AZ::RHI::Allocator::GarbageCollect ( )
pure virtual

Allocations are deferred-released until a specific number of GC cycles have occurred. This is useful for allocations actively being consumed by the GPU.

Implemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.

◆ GarbageCollectForce()

virtual void AZ::RHI::Allocator::GarbageCollectForce ( )
pure virtual

Forces garbage collection of all allocations, regardless of the GC latency.

Implemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.

◆ GetAllocatedByteCount()

virtual size_t AZ::RHI::Allocator::GetAllocatedByteCount ( ) const
inlinevirtual

Returns the number of bytes used by the allocator. This includes allocations that are pending garbage collection.

Reimplemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.

◆ GetAllocationCount()

virtual size_t AZ::RHI::Allocator::GetAllocationCount ( ) const
inlinevirtual

Returns the number of allocations active for this allocator. This includes allocations that are pending garbage collection.

Reimplemented in AZ::RHI::FreeListAllocator, and AZ::RHI::PoolAllocator.

◆ GetDescriptor()

virtual const Descriptor & AZ::RHI::Allocator::GetDescriptor ( ) const
pure virtual

Returns the descriptor used to initialize the allocator.

Implemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.


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