#include <PoolAllocator.h>
Inherits AZ::RHI::Allocator.
Classes | |
struct | Descriptor |
Public Member Functions | |
AZ_CLASS_ALLOCATOR (PoolAllocator, AZ::SystemAllocator) | |
void | Init (const Descriptor &descriptor) |
VirtualAddress | Allocate () |
void | Shutdown () override |
VirtualAddress | Allocate (size_t byteCount, size_t byteAlignment) override |
void | DeAllocate (VirtualAddress allocation) override |
void | GarbageCollect () override |
void | GarbageCollectForce () override |
Forces garbage collection of all allocations, regardless of the GC latency. | |
size_t | GetAllocationCount () const override |
size_t | GetAllocatedByteCount () const override |
const Descriptor & | GetDescriptor () const override |
Returns the descriptor used to initialize the allocator. | |
Public Member Functions inherited from AZ::RHI::Allocator | |
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) |
This class can be used to efficiently allocate small chunks of memory from an externally managed source (DMA / Gpu memory). It will recycle freed blocks by deferring for a configurable number of ticks. If the memory is being used as GPU local memory, its common for the CPU to write to that memory and for the GPU to read it several frames later. The garbage collection latency can be set to match the maximum number of buffered frames, so the user can allocate and free at will without stomping over regions of memory being read.
|
overridevirtual |
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. |
Implements AZ::RHI::Allocator.
|
overridevirtual |
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.
Implements AZ::RHI::Allocator.
|
overridevirtual |
Allocations are deferred-released until a specific number of GC cycles have occurred. This is useful for allocations actively being consumed by the GPU.
Implements AZ::RHI::Allocator.
|
overridevirtual |
Forces garbage collection of all allocations, regardless of the GC latency.
Implements AZ::RHI::Allocator.
|
overridevirtual |
Returns the number of bytes used by the allocator. This includes allocations that are pending garbage collection.
Reimplemented from AZ::RHI::Allocator.
|
overridevirtual |
Returns the number of allocations active for this allocator. This includes allocations that are pending garbage collection.
Reimplemented from AZ::RHI::Allocator.
|
overridevirtual |
Returns the descriptor used to initialize the allocator.
Implements AZ::RHI::Allocator.
|
overridevirtual |
Implements AZ::RHI::Allocator.