r.VT.AVT.LevelIncrement
r.VT.AVT.LevelIncrement
#Overview
name: r.VT.AVT.LevelIncrement
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Number of levels to increment each time we grow an allocated virtual texture
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VT.AVT.LevelIncrement is to control the number of levels to increment each time the system grows an allocated virtual texture in the Adaptive Virtual Texture (AVT) system. This setting is part of Unreal Engine’s rendering system, specifically the virtual texturing subsystem.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the Adaptive Virtual Texture component. This can be seen from the file path where the variable is defined and used: “Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp”.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 3, but can be changed at runtime through console commands or configuration files.
This variable interacts directly with its associated variable CVarAVTLevelIncrement. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the growth rate of allocated virtual textures. A higher value will result in larger increments when growing textures, which could lead to more memory usage but potentially fewer allocation operations. Conversely, a lower value will result in smaller, more gradual growth, which might be more memory-efficient but could require more frequent allocations.
Best practices when using this variable include:
- Consider the balance between memory usage and allocation frequency when adjusting this value.
- Monitor performance and memory usage when changing this value to ensure it doesn’t negatively impact your game’s performance.
- Be cautious when setting very high values, as it could lead to excessive memory allocation.
- Consider the specific needs of your project – games with many large textures might benefit from a higher value, while those with smaller or fewer textures might prefer a lower value.
Regarding the associated variable CVarAVTLevelIncrement:
The purpose of CVarAVTLevelIncrement is identical to r.VT.AVT.LevelIncrement. It’s the actual console variable object that stores and provides access to the value set by r.VT.AVT.LevelIncrement.
This variable is used directly in the FAdaptiveVirtualTexture::Allocate function to determine the new level when growing an allocated virtual texture. It’s retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access to the value.
The same considerations and best practices apply to CVarAVTLevelIncrement as to r.VT.AVT.LevelIncrement. Developers should be aware that changing one effectively changes the other, and they should use whichever is more appropriate for their specific use case (console commands would use r.VT.AVT.LevelIncrement, while C++ code would typically use CVarAVTLevelIncrement).
#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:38
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarAVTLevelIncrement(
TEXT("r.VT.AVT.LevelIncrement"),
3,
TEXT("Number of levels to increment each time we grow an allocated virtual texture"),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarAVTLevelIncrement
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp:37
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarAVTLevelIncrement(
TEXT("r.VT.AVT.LevelIncrement"),
3,
TEXT("Number of levels to increment each time we grow an allocated virtual texture"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp:529
Scope (from outer to inner):
file
function void FAdaptiveVirtualTexture::Allocate
Source code excerpt:
FAllocatedVirtualTexture* OldAllocatedVT = bIsAllocated ? AllocationSlots[AllocationIndex].AllocatedVT : nullptr;
const uint32 CurrentLevel = bIsAllocated ? OldAllocatedVT->GetMaxLevel() : 0;
const uint32 LevelIncrement = CVarAVTLevelIncrement.GetValueOnRenderThread();
const uint32 NewLevel = FMath::Min(CurrentLevel + LevelIncrement, AdaptiveDesc.MaxAdaptiveLevel);
check(NewLevel > CurrentLevel);
// Check if we have space in the page table to allocate. If not then hopefully we can allocate next frame.
FVirtualTextureSpace* Space = InSystem->GetSpace(GetSpaceID());
if (!Space->GetAllocator().TryAlloc(NewLevel))