Direct3D 12 Memory Allocator
Loading...
Searching...
No Matches
Public Member Functions | List of all members
D3D12MA::Allocation Class Reference

Represents single memory allocation. More...

#include <D3D12MemAlloc.h>

Inheritance diagram for D3D12MA::Allocation:

Public Member Functions

UINT64 GetOffset () const
 Returns offset in bytes from the start of memory heap.
 
UINT64 GetAlignment () const
 Returns alignment that resource was created with.
 
UINT64 GetSize () const
 Returns size in bytes of the allocation.
 
ID3D12Resource * GetResource () const
 Returns D3D12 resource associated with this object.
 
void SetResource (ID3D12Resource *pResource)
 Releases the resource currently pointed by the allocation (if any), sets it to new one, incrementing its reference counter (if not null).
 
ID3D12Heap * GetHeap () const
 Returns memory heap that the resource is created in.
 
void SetPrivateData (void *pPrivateData)
 Changes custom pointer for an allocation to a new value.
 
void * GetPrivateData () const
 Get custom pointer associated with the allocation.
 
void SetName (LPCWSTR Name)
 Associates a name with the allocation object. This name is for use in debug diagnostics and tools.
 
LPCWSTR GetName () const
 Returns the name associated with the allocation object.
 

Detailed Description

Represents single memory allocation.

It may be either implicit memory heap dedicated to a single resource or a specific region of a bigger heap plus unique offset.

To create such object, fill structure D3D12MA::ALLOCATION_DESC and call function Allocator::CreateResource.

The object remembers size and some other information. To retrieve this information, use methods of this class.

The object also remembers ID3D12Resource and "owns" a reference to it, so it calls Release() on the resource when destroyed.

Member Function Documentation

◆ GetAlignment()

UINT64 D3D12MA::Allocation::GetAlignment ( ) const
inline

Returns alignment that resource was created with.

◆ GetHeap()

ID3D12Heap * D3D12MA::Allocation::GetHeap ( ) const

Returns memory heap that the resource is created in.

If the Allocation represents committed resource with implicit heap, returns NULL.

◆ GetName()

LPCWSTR D3D12MA::Allocation::GetName ( ) const
inline

Returns the name associated with the allocation object.

Returned string points to an internal copy.

If no name was associated with the allocation, returns null.

◆ GetOffset()

UINT64 D3D12MA::Allocation::GetOffset ( ) const

Returns offset in bytes from the start of memory heap.

You usually don't need to use this offset. If you create a buffer or a texture together with the allocation using function D3D12MA::Allocator::CreateResource, functions that operate on that resource refer to the beginning of the resource, not entire memory heap.

If the Allocation represents committed resource with implicit heap, returns 0.

◆ GetPrivateData()

void * D3D12MA::Allocation::GetPrivateData ( ) const
inline

Get custom pointer associated with the allocation.

◆ GetResource()

ID3D12Resource * D3D12MA::Allocation::GetResource ( ) const
inline

Returns D3D12 resource associated with this object.

Calling this method doesn't increment resource's reference counter.

◆ GetSize()

UINT64 D3D12MA::Allocation::GetSize ( ) const
inline

Returns size in bytes of the allocation.

  • If you created a buffer or a texture together with the allocation using function D3D12MA::Allocator::CreateResource, this is the size of the resource returned by ID3D12Device::GetResourceAllocationInfo.
  • For allocations made out of bigger memory blocks, this also is the size of the memory region assigned exclusively to this allocation.
  • For resources created as committed, this value may not be accurate. DirectX implementation may optimize memory usage internally so that you may even observe regions of ID3D12Resource::GetGPUVirtualAddress() + Allocation::GetSize() to overlap in memory and still work correctly.

◆ SetName()

void D3D12MA::Allocation::SetName ( LPCWSTR Name)

Associates a name with the allocation object. This name is for use in debug diagnostics and tools.

Internal copy of the string is made, so the memory pointed by the argument can be changed of freed immediately after this call.

Name can be null.

◆ SetPrivateData()

void D3D12MA::Allocation::SetPrivateData ( void * pPrivateData)
inline

Changes custom pointer for an allocation to a new value.

◆ SetResource()

void D3D12MA::Allocation::SetResource ( ID3D12Resource * pResource)

Releases the resource currently pointed by the allocation (if any), sets it to new one, incrementing its reference counter (if not null).

Member Data Documentation

◆ allocHandle

AllocHandle D3D12MA::Allocation::allocHandle

◆ block

NormalBlock* D3D12MA::Allocation::block

◆ heap

ID3D12Heap* D3D12MA::Allocation::heap

◆ list

CommittedAllocationList* D3D12MA::Allocation::list

◆ [struct]

struct { ... } D3D12MA::Allocation::m_Committed

◆ [struct]

struct { ... } D3D12MA::Allocation::m_Heap

◆ [struct]

struct { ... } D3D12MA::Allocation::m_Placed

◆ next

Allocation* D3D12MA::Allocation::next

◆ prev

Allocation* D3D12MA::Allocation::prev

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