r.VT.AVT.AgeToFree

r.VT.AVT.AgeToFree

#Overview

name: r.VT.AVT.AgeToFree

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.AVT.AgeToFree is to control the number of frames an allocation in the Adaptive Virtual Texture (AVT) system can remain unused before it becomes eligible for freeing. 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: “Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp”.

The value of this variable is set as a console variable with a default value of 60 frames. It can be modified at runtime through the console or configuration files.

This variable interacts with another variable named CVarAVTAgeToFree, which is the actual TAutoConsoleVariable object that stores and manages the value. They share the same value and purpose.

Developers must be aware that this variable directly impacts memory management in the Adaptive Virtual Texture system. A lower value will cause unused allocations to be freed more quickly, potentially saving memory but possibly increasing the frequency of reallocations. A higher value will keep allocations in memory longer, which may improve performance in scenarios where textures are frequently reused but at the cost of higher memory usage.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project and target hardware capabilities.
  2. Monitoring memory usage and texture streaming performance when modifying this value.
  3. Considering the trade-off between memory usage and potential performance impacts from frequent deallocations and reallocations.

Regarding the associated variable CVarAVTAgeToFree: The purpose of CVarAVTAgeToFree is to provide a programmatic interface for the r.VT.AVT.AgeToFree console variable. It allows the engine to access and modify the value at runtime.

This variable is used within the FAdaptiveVirtualTexture::UpdateAllocations function to determine which allocations should be freed. The value is retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access in the render thread.

Developers should be aware that modifying CVarAVTAgeToFree directly in code will have the same effect as changing r.VT.AVT.AgeToFree through the console. They should use this variable when they need to programmatically adjust the age-to-free value in their game code or engine modifications.

Best practices for using CVarAVTAgeToFree include:

  1. Accessing it only from the render thread to avoid potential race conditions.
  2. Considering performance implications when frequently changing its value during runtime.
  3. Using it in conjunction with other AVT-related variables to fine-tune the Virtual Texturing system’s behavior.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarAVTAgeToFree(
	TEXT("r.VT.AVT.AgeToFree"),
	60,
	TEXT("Number of frames for an allocation to be unused before it is considered for free"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarAVTLevelIncrement(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp:30

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarAVTAgeToFree(
	TEXT("r.VT.AVT.AgeToFree"),
	60,
	TEXT("Number of frames for an allocation to be unused before it is considered for free"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/AdaptiveVirtualTexture.cpp:677

Scope (from outer to inner):

file
function     void FAdaptiveVirtualTexture::UpdateAllocations

Source code excerpt:

	{
		// Free old unused pages if there is no other work to do.
		const uint32 FrameAgeToFree = CVarAVTAgeToFree.GetValueOnRenderThread();
		const int32 NumToFree = FMath::Min(NumAllocated, CVarAVTMaxFreePerFrame.GetValueOnRenderThread());

		bool bFreeSuccess = true;
		for (int32 FreeCount = 0; bFreeSuccess && FreeCount < NumToFree; FreeCount++)
		{
			bFreeSuccess = FreeLRU(RHICmdList, InSystem, InFrame, FrameAgeToFree);