r.VT.CodecAgeThreshold
r.VT.CodecAgeThreshold
#Overview
name: r.VT.CodecAgeThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Mininum number of frames VT codec must be unused before possibly being retired
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VT.CodecAgeThreshold is to control the retirement of Virtual Texture (VT) codecs in Unreal Engine’s rendering system. Specifically, it sets the minimum number of frames a VT codec must be unused before it becomes eligible for retirement.
This setting variable is primarily used by the Virtual Texturing system, which is part of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is utilized in the UploadingVirtualTexture.cpp file, which is part of the Engine’s runtime.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 120 frames, but can be changed at runtime through console commands or configuration files.
The associated variable CVarVTCodecAgeThreshold directly interacts with r.VT.CodecAgeThreshold. They share the same value and purpose. This associated variable is used in the C++ code to access the current value of the setting.
Developers should be aware that this variable affects the memory management and performance of the Virtual Texturing system. Setting it too low might cause frequent retirement and recreation of codecs, while setting it too high might lead to unnecessary memory usage.
Best practices when using this variable include:
- Monitor the performance and memory usage of your Virtual Texturing system.
- Adjust the value based on your specific use case and hardware capabilities.
- Consider the trade-off between memory usage and potential performance impact of codec retirement and recreation.
Regarding the associated variable CVarVTCodecAgeThreshold:
The purpose of CVarVTCodecAgeThreshold is to provide a programmatic way to access and modify the r.VT.CodecAgeThreshold setting within the C++ code.
This variable is used directly in the Engine’s Virtual Texturing system, specifically in the FVirtualTextureCodec::RetireOldCodecs function.
The value of CVarVTCodecAgeThreshold is set automatically by the CVar system when r.VT.CodecAgeThreshold is modified.
It interacts closely with another variable, CVarVTCodecNumThreshold, which sets a threshold for the total number of codecs.
Developers should be aware that changes to CVarVTCodecAgeThreshold will immediately affect the behavior of the codec retirement system.
Best practices for using CVarVTCodecAgeThreshold include:
- Use GetValueOnRenderThread() to access its value in render thread code.
- Consider the impact on both performance and memory when modifying this value.
- Coordinate changes to this variable with CVarVTCodecNumThreshold for optimal codec management.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/UploadingVirtualTexture.cpp:15
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarVTCodecAgeThreshold(
TEXT("r.VT.CodecAgeThreshold"),
120,
TEXT("Mininum number of frames VT codec must be unused before possibly being retired"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarVTCodecNumThreshold(
TEXT("r.VT.CodecNumThreshold"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarVTCodecAgeThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/UploadingVirtualTexture.cpp:14
Scope: file
Source code excerpt:
DECLARE_FLOAT_COUNTER_STAT(TEXT("IO Requests Completed (MB)"), STAT_IORequestsComplete, STATGROUP_VirtualTexturing);
static TAutoConsoleVariable<int32> CVarVTCodecAgeThreshold(
TEXT("r.VT.CodecAgeThreshold"),
120,
TEXT("Mininum number of frames VT codec must be unused before possibly being retired"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarVTCodecNumThreshold(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/UploadingVirtualTexture.cpp:156
Scope (from outer to inner):
file
function void FVirtualTextureCodec::RetireOldCodecs
Source code excerpt:
void FVirtualTextureCodec::RetireOldCodecs()
{
const uint32 AgeThreshold = CVarVTCodecAgeThreshold.GetValueOnRenderThread();
const uint32 NumThreshold = CVarVTCodecNumThreshold.GetValueOnRenderThread();
const uint32 CurrentFrame = GFrameNumberRenderThread;
FVirtualTextureCodec::TIterator It(ListHead);
while (It && NumCodecs > NumThreshold)
{