#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 Descriptor & | GetDescriptor () 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) |
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.
|
pure virtual |
Allocates a virtual address relative to the base address provided at initialization time.
byteCount | The number of bytes to allocate. |
byteAlignement | The alignment used to align the allocation. |
Implemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.
|
inline |
Helper for converting agnostic VirtualAddress type to pointer type. Will convert VirtualAddress::Null to nullptr.
|
inlinevirtual |
Clone the current allocator to the new allocator passed in.
Reimplemented in AZ::RHI::FreeListAllocator.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
pure virtual |
Returns the descriptor used to initialize the allocator.
Implemented in AZ::RHI::FreeListAllocator, AZ::RHI::LinearAllocator, and AZ::RHI::PoolAllocator.