r.VT.PoolSizeScale

r.VT.PoolSizeScale

#Overview

name: r.VT.PoolSizeScale

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.PoolSizeScale is to control the scale factor for the virtual texture physical pool size in Unreal Engine’s rendering system. This setting variable is primarily used in the virtual texturing subsystem, which is a part of the engine’s rendering module.

Based on the callsites, this variable is utilized within the VirtualTexturePoolConfig.cpp file, which suggests it’s an integral part of the virtual texture pool configuration system. The virtual texture pool is responsible for managing the physical memory allocated for virtual textures.

The value of this variable is set through a console variable (CVar) system, initialized with a default value of 1.0f. It can be modified at runtime through console commands or programmatically.

The associated variable CVarVTPoolSizeScale interacts directly with r.VT.PoolSizeScale, as they share the same value. This variable is used to retrieve the current pool size scale value, as seen in the GetPoolSizeScale() function.

Developers must be aware that this variable affects the memory allocation for virtual textures. Increasing the value will allocate more memory for the virtual texture pool, potentially improving performance at the cost of higher memory usage. Conversely, decreasing the value will reduce memory usage but might impact rendering quality or performance.

Best practices when using this variable include:

  1. Carefully balancing memory usage and rendering quality based on target hardware specifications.
  2. Profiling the application to determine the optimal pool size for specific use cases.
  3. Considering dynamic adjustment of the pool size based on the current scene complexity or available system resources.

Regarding the associated variable CVarVTPoolSizeScale:

The purpose of CVarVTPoolSizeScale is to provide a programmatic interface to access and modify the r.VT.PoolSizeScale value. It’s defined as a TAutoConsoleVariable, which allows it to be easily accessible and modifiable through the Unreal Engine console system.

This variable is used within the VirtualTexturePool class to retrieve the current pool size scale value. The GetPoolSizeScale() function uses CVarVTPoolSizeScale.GetValueOnAnyThread() to fetch the current value, ensuring that the most up-to-date scale factor is always used when managing the virtual texture pool.

Developers should be aware that changes to CVarVTPoolSizeScale will directly affect the behavior of the virtual texture system. It’s thread-safe and can be accessed from any thread, as indicated by the ECVF_RenderThreadSafe flag in its declaration.

Best practices for using CVarVTPoolSizeScale include:

  1. Using it to dynamically adjust the virtual texture pool size based on runtime conditions.
  2. Implementing proper synchronization when modifying the value, especially if done from multiple threads.
  3. Considering the performance implications of frequently accessing or modifying this value, particularly in performance-critical code paths.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTexturePoolConfig.cpp:18

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarVTPoolSizeScale(
	TEXT("r.VT.PoolSizeScale"),
	1.0f,
	TEXT("Scale factor for virtual texture physical pool size.\n"),
	ECVF_RenderThreadSafe | ECVF_Scalability | ECVF_ExcludeFromPreview
);

static TAutoConsoleVariable<bool> CVarVTPoolAutoGrow(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTexturePoolConfig.cpp:17

Scope: file

Source code excerpt:

#define LOCTEXT_NAMESPACE "VirtualTexturePool"

static TAutoConsoleVariable<float> CVarVTPoolSizeScale(
	TEXT("r.VT.PoolSizeScale"),
	1.0f,
	TEXT("Scale factor for virtual texture physical pool size.\n"),
	ECVF_RenderThreadSafe | ECVF_Scalability | ECVF_ExcludeFromPreview
);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTexturePoolConfig.cpp:278

Scope (from outer to inner):

file
function     float VirtualTexturePool::GetPoolSizeScale

Source code excerpt:

float VirtualTexturePool::GetPoolSizeScale()
{
	return CVarVTPoolSizeScale.GetValueOnAnyThread();
}

bool VirtualTexturePool::GetPoolAutoGrow()
{
#if WITH_EDITOR
	UVirtualTexturePoolConfig const* PoolConfig = GetDefault<UVirtualTexturePoolConfig>();