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::LinearAllocator Class Referencefinal

#include <LinearAllocator.h>

Inherits AZ::RHI::Allocator.

Classes

struct  Descriptor
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (LinearAllocator, AZ::SystemAllocator)
 
void Init (const Descriptor &descriptor)
 
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 GetAllocatedByteCount () const override
 
const DescriptorGetDescriptor () const override
 Returns the descriptor used to initialize the allocator.
 
void SetBaseAddress (VirtualAddress address)
 
- 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 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

A linear allocator where each allocation is a simple increment to the cursor. Garbage collection controls when the cursor resets back to the beginning.

Member Function Documentation

◆ Allocate()

VirtualAddress AZ::RHI::LinearAllocator::Allocate ( size_t  byteCount,
size_t  byteAlignment 
)
overridevirtual

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.

Implements AZ::RHI::Allocator.

◆ DeAllocate()

void AZ::RHI::LinearAllocator::DeAllocate ( VirtualAddress  offset)
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.

◆ GarbageCollect()

void AZ::RHI::LinearAllocator::GarbageCollect ( )
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.

◆ GarbageCollectForce()

void AZ::RHI::LinearAllocator::GarbageCollectForce ( )
overridevirtual

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

Implements AZ::RHI::Allocator.

◆ GetAllocatedByteCount()

size_t AZ::RHI::LinearAllocator::GetAllocatedByteCount ( ) const
overridevirtual

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

Reimplemented from AZ::RHI::Allocator.

◆ GetDescriptor()

const Descriptor & AZ::RHI::LinearAllocator::GetDescriptor ( ) const
overridevirtual

Returns the descriptor used to initialize the allocator.

Implements AZ::RHI::Allocator.

◆ Shutdown()

void AZ::RHI::LinearAllocator::Shutdown ( )
overridevirtual

Implements AZ::RHI::Allocator.


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