d3d12.ReservedResourceHeapSizeMB
d3d12.ReservedResourceHeapSizeMB
#Overview
name: d3d12.ReservedResourceHeapSizeMB
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Size of the backing heaps for reserved resources in megabytes (default 16MB).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of d3d12.ReservedResourceHeapSizeMB is to control the size of the backing heaps for reserved resources in the Direct3D 12 rendering system. This setting variable is crucial for memory management in the D3D12 RHI (Runtime Hardware Interface) module of Unreal Engine 5.
This setting variable is primarily used by the D3D12 RHI subsystem, which is responsible for interfacing with the DirectX 12 API for rendering. It’s specifically used in the resource management part of this subsystem.
The value of this variable is set through a console variable (CVar) system. It’s defined with a default value of 16 (megabytes) and is marked as read-only, meaning it cannot be changed at runtime.
The associated variable CVarD3D12ReservedResourceHeapSizeMB directly interacts with d3d12.ReservedResourceHeapSizeMB. This CVar is used to access the value of the setting in the C++ code.
Developers must be aware that this variable affects the memory allocation for reserved resources in DirectX 12. A larger value may provide more flexibility for large resources but could potentially waste memory if not fully utilized. Conversely, a smaller value might require more frequent allocations but could be more memory-efficient for smaller resources.
Best practices when using this variable include:
- Carefully consider the size of resources your application typically uses.
- Monitor memory usage to ensure this setting is appropriate for your application’s needs.
- Be cautious about changing this value, as it’s marked as read-only and likely impacts performance and stability.
Regarding the associated variable CVarD3D12ReservedResourceHeapSizeMB:
The purpose of CVarD3D12ReservedResourceHeapSizeMB is to provide programmatic access to the d3d12.ReservedResourceHeapSizeMB setting within the C++ code of the D3D12 RHI module.
This variable is used in the FD3D12Resource::CommitReservedResource function to calculate the number and size of backing heaps for reserved resources. It directly influences how memory is allocated and managed for these resources.
The value of this variable is set when the d3d12.ReservedResourceHeapSizeMB console variable is initialized.
Developers should be aware that changes to this variable will affect memory allocation patterns for reserved resources in DirectX 12. It’s crucial to understand the implications of modifying this value on overall performance and memory usage.
Best practices include using this variable consistently throughout the codebase when dealing with reserved resource allocation, and ensuring that any changes to its value are thoroughly tested for performance and stability impacts.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Resources.cpp:12
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarD3D12ReservedResourceHeapSizeMB(
TEXT("d3d12.ReservedResourceHeapSizeMB"),
16,
TEXT("Size of the backing heaps for reserved resources in megabytes (default 16MB)."),
ECVF_ReadOnly
);
/////////////////////////////////////////////////////////////////////
#Associated Variable and Callsites
This variable is associated with another variable named CVarD3D12ReservedResourceHeapSizeMB
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Resources.cpp:11
Scope: file
Source code excerpt:
#include "ProfilingDebugging/AssetMetadataTrace.h"
static TAutoConsoleVariable<int32> CVarD3D12ReservedResourceHeapSizeMB(
TEXT("d3d12.ReservedResourceHeapSizeMB"),
16,
TEXT("Size of the backing heaps for reserved resources in megabytes (default 16MB)."),
ECVF_ReadOnly
);
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Resources.cpp:220
Scope (from outer to inner):
file
function void FD3D12Resource::CommitReservedResource
Source code excerpt:
RequiredCommitSizeInBytes = AlignArbitrary(RequiredCommitSizeInBytes, TileSizeInBytes);
const uint64 MaxHeapSize = uint64(CVarD3D12ReservedResourceHeapSizeMB.GetValueOnAnyThread()) * 1024 * 1024;
const uint64 NumHeaps = FMath::DivideAndRoundUp(TotalSize, MaxHeapSize);
ReservedResourceData->BackingHeaps.Reserve(NumHeaps);
const uint32 MaxTilesPerHeap = uint32(MaxHeapSize / TileSizeInBytes);