Open 3D Engine Atom Gem API Reference
24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
|
Represents pure allocation algorithm and a data structure with allocations in some memory block, without actually allocating any GPU memory. More...
#include <D3D12MemAlloc.h>
Inherits IUnknownImpl.
Public Member Functions | |
BOOL | IsEmpty () const |
Returns true if the block is empty - contains 0 allocations. | |
void | GetAllocationInfo (VirtualAllocation allocation, VIRTUAL_ALLOCATION_INFO *pInfo) const |
Returns information about an allocation - its offset, size and custom pointer. | |
HRESULT | Allocate (const VIRTUAL_ALLOCATION_DESC *pDesc, VirtualAllocation *pAllocation, UINT64 *pOffset) |
Creates new allocation. More... | |
void | FreeAllocation (VirtualAllocation allocation) |
Frees the allocation. More... | |
void | Clear () |
Frees all the allocations. | |
void | SetAllocationPrivateData (VirtualAllocation allocation, void *pPrivateData) |
Changes custom pointer for an allocation to a new value. | |
void | GetStatistics (Statistics *pStats) const |
Retrieves basic statistics of the virtual block that are fast to calculate. More... | |
void | CalculateStatistics (DetailedStatistics *pStats) const |
Retrieves detailed statistics of the virtual block that are slower to calculate. More... | |
void | BuildStatsString (WCHAR **ppStatsString) const |
Builds and returns statistics as a string in JSON format, including the list of allocations with their parameters. More... | |
void | FreeStatsString (WCHAR *pStatsString) const |
Frees memory of a string returned from VirtualBlock::BuildStatsString. | |
Protected Member Functions | |
void | ReleaseThis () override |
Friends | |
D3D12MA_API HRESULT | CreateVirtualBlock (const VIRTUAL_BLOCK_DESC *, VirtualBlock **) |
Creates new D3D12MA::VirtualBlock object and returns it through ppVirtualBlock . More... | |
template<typename T > | |
void | D3D12MA_DELETE (const ALLOCATION_CALLBACKS &, T *) |
Represents pure allocation algorithm and a data structure with allocations in some memory block, without actually allocating any GPU memory.
This class allows to use the core algorithm of the library custom allocations e.g. CPU memory or sub-allocation regions inside a single GPU buffer.
To create this object, fill in D3D12MA::VIRTUAL_BLOCK_DESC and call CreateVirtualBlock(). To destroy it, call its method VirtualBlock::Release()
. You need to free all the allocations within this block or call Clear() before destroying it.
This object is not thread-safe - should not be used from multiple threads simultaneously, must be synchronized externally.
HRESULT D3D12MA::VirtualBlock::Allocate | ( | const VIRTUAL_ALLOCATION_DESC * | pDesc, |
VirtualAllocation * | pAllocation, | ||
UINT64 * | pOffset | ||
) |
Creates new allocation.
pDesc | ||
[out] | pAllocation | Unique indentifier of the new allocation within single block. |
[out] | pOffset | Returned offset of the new allocation. Optional, can be null. |
S_OK
if allocation succeeded, E_OUTOFMEMORY
if it failed.If the allocation failed, pAllocation->AllocHandle
is set to 0 and pOffset
, if not null, is set to UINT64_MAX
.
void D3D12MA::VirtualBlock::BuildStatsString | ( | WCHAR ** | ppStatsString | ) | const |
Builds and returns statistics as a string in JSON format, including the list of allocations with their parameters.
[out] | ppStatsString | Must be freed using VirtualBlock::FreeStatsString. |
void D3D12MA::VirtualBlock::CalculateStatistics | ( | DetailedStatistics * | pStats | ) | const |
Retrieves detailed statistics of the virtual block that are slower to calculate.
[out] | pStats | Statistics of the virtual block. |
void D3D12MA::VirtualBlock::FreeAllocation | ( | VirtualAllocation | allocation | ) |
Frees the allocation.
Calling this function with allocation.AllocHandle == 0
is correct and does nothing.
void D3D12MA::VirtualBlock::GetStatistics | ( | Statistics * | pStats | ) | const |
Retrieves basic statistics of the virtual block that are fast to calculate.
[out] | pStats | Statistics of the virtual block. |
|
friend |
Creates new D3D12MA::VirtualBlock object and returns it through ppVirtualBlock
.
Note you don't need to create D3D12MA::Allocator to use virtual blocks.