r.VT.AVT.MaxAllocPerFrame
r.VT.AVT.MaxAllocPerFrame
#Overview
name: r.VT.AVT.MaxAllocPerFrame
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Max number of allocated VT for adaptive VT to alloc per frame
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VT.AVT.MaxAllocPerFrame is to control the maximum number of Virtual Textures (VT) that can be allocated per frame for the Adaptive Virtual Texture (AVT) system in Unreal Engine 5’s rendering pipeline.
This setting variable is primarily used by the rendering system, specifically the Adaptive Virtual Texture subsystem within Unreal Engine 5. Based on the callsites, it’s clear that this variable is utilized in the Renderer module, particularly in the VT (Virtual Texturing) component.
The value of this variable is set as a console variable using the TAutoConsoleVariable template. It’s initialized with a default value of 1, meaning by default, only one Virtual Texture can be allocated per frame for the Adaptive Virtual Texture system.
The associated variable CVarAVTMaxAllocPerFrame directly interacts with r.VT.AVT.MaxAllocPerFrame. They share the same value and purpose.
Developers must be aware that this variable affects the performance and memory usage of the Adaptive Virtual Texture system. Setting a higher value allows more Virtual Textures to be allocated per frame, which can improve texture quality but may impact performance. Conversely, a lower value might improve performance but could result in lower texture quality or slower texture loading.
Best practices when using this variable include:
- Adjusting it based on the specific needs of the project and target hardware capabilities.
- Monitoring performance metrics when changing this value to find the optimal balance between texture quality and performance.
- Consider using different values for different quality settings in the game.
Regarding the associated variable CVarAVTMaxAllocPerFrame:
The purpose of CVarAVTMaxAllocPerFrame is identical to r.VT.AVT.MaxAllocPerFrame. It’s an internal representation of the console variable within the C++ code.
This variable is used directly in the FAdaptiveVirtualTexture::UpdateAllocations function to determine how many allocation requests to process per frame. It’s retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access to the current value.
Developers should be aware that changes to r.VT.AVT.MaxAllocPerFrame will be reflected in CVarAVTMaxAllocPerFrame, and vice versa. When debugging or profiling, they may encounter either name referring to the same concept.
Best practices for CVarAVTMaxAllocPerFrame include:
- Using GetValueOnRenderThread() when accessing the value, as shown in the code, to ensure thread-safety.
- Being cautious about changing this value at runtime, as it could have immediate impacts on performance and memory usage.
- Consider exposing this setting to artists or technical artists through a user-friendly interface for easier tuning during development.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp:10
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarAVTMaxAllocPerFrame(
TEXT("r.VT.AVT.MaxAllocPerFrame"),
1,
TEXT("Max number of allocated VT for adaptive VT to alloc per frame"),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarAVTMaxFreePerFrame(
#Associated Variable and Callsites
This variable is associated with another variable named CVarAVTMaxAllocPerFrame
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp:9
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarAVTMaxAllocPerFrame(
TEXT("r.VT.AVT.MaxAllocPerFrame"),
1,
TEXT("Max number of allocated VT for adaptive VT to alloc per frame"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp:703
Scope (from outer to inner):
file
function void FAdaptiveVirtualTexture::UpdateAllocations
Source code excerpt:
// Process allocation requests.
const int32 NumToAlloc = CVarAVTMaxAllocPerFrame.GetValueOnRenderThread();
for (int32 AllocCount = 0; AllocCount < NumToAlloc && RequestsToMap.Num(); AllocCount++)
{
// Randomize request order to prevent feedback from top of the view being prioritized.
int32 RequestIndex = FMath::Rand() % RequestsToMap.Num();
uint32 PackedRequest = RequestsToMap[RequestIndex];