r.VT.CodecNumThreshold

r.VT.CodecNumThreshold

#Overview

name: r.VT.CodecNumThreshold

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.VT.CodecNumThreshold is to control the management of Virtual Texture (VT) codecs in Unreal Engine’s rendering system. It sets a threshold for the maximum number of VT codecs that can be active before the engine attempts to retire older, less frequently used codecs.

This setting variable is primarily used in the rendering system, specifically in the Virtual Texturing subsystem of Unreal Engine. Based on the callsites, it’s evident that this variable is utilized in the Engine module, particularly in the VT (Virtual Texturing) component.

The value of this variable is set using a TAutoConsoleVariable, which means it can be modified at runtime through console commands. Its default value is set to 100.

The associated variable CVarVTCodecNumThreshold interacts directly with r.VT.CodecNumThreshold. They share the same value and purpose.

Developers must be aware that this variable affects the performance and memory usage 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 excessive memory usage.

Best practices when using this variable include:

  1. Monitor the number of active VT codecs in your project.
  2. Adjust the value based on your project’s specific needs and available resources.
  3. Consider the trade-off between memory usage and potential performance impacts from codec retirement.

Regarding the associated variable CVarVTCodecNumThreshold:

The purpose of CVarVTCodecNumThreshold is the same as r.VT.CodecNumThreshold. It’s the internal representation of the console variable within the engine’s code.

This variable is used directly in the RetireOldCodecs() function of the FVirtualTextureCodec class. It determines when the codec retirement process should begin.

The value of CVarVTCodecNumThreshold is set and accessed using the GetValueOnRenderThread() method, ensuring thread-safe access in the render thread.

Developers should be aware that modifying r.VT.CodecNumThreshold will directly affect the behavior controlled by CVarVTCodecNumThreshold.

Best practices for CVarVTCodecNumThreshold align with those for r.VT.CodecNumThreshold, as they are essentially the same variable represented in different contexts within the engine code.

#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:21

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVTCodecNumThreshold(
	TEXT("r.VT.CodecNumThreshold"),
	100,
	TEXT("Once number of VT codecs exceeds this number, attempt to retire codecs that haven't been recently used"),
	ECVF_RenderThreadSafe);

int32 GVirtualTextureIOPriority_NormalPagePri = (int32)AIOP_Low;
static FAutoConsoleVariableRef CVarVirtualTextureIOPriority_NormalPagePri(

#Associated Variable and Callsites

This variable is associated with another variable named CVarVTCodecNumThreshold. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/UploadingVirtualTexture.cpp:20

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarVTCodecNumThreshold(
	TEXT("r.VT.CodecNumThreshold"),
	100,
	TEXT("Once number of VT codecs exceeds this number, attempt to retire codecs that haven't been recently used"),
	ECVF_RenderThreadSafe);

int32 GVirtualTextureIOPriority_NormalPagePri = (int32)AIOP_Low;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/UploadingVirtualTexture.cpp:157

Scope (from outer to inner):

file
function     void FVirtualTextureCodec::RetireOldCodecs

Source code excerpt:

{
	const uint32 AgeThreshold = CVarVTCodecAgeThreshold.GetValueOnRenderThread();
	const uint32 NumThreshold = CVarVTCodecNumThreshold.GetValueOnRenderThread();
	const uint32 CurrentFrame = GFrameNumberRenderThread;

	FVirtualTextureCodec::TIterator It(ListHead);
	while (It && NumCodecs > NumThreshold)
	{
		FVirtualTextureCodec& Codec = *It;