r.VT.Residency.MaxMipMapBias

r.VT.Residency.MaxMipMapBias

#Overview

name: r.VT.Residency.MaxMipMapBias

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.Residency.MaxMipMapBias is to control the maximum mip bias applied to prevent Virtual Texture pool residency over-subscription in Unreal Engine’s rendering system.

This setting variable is primarily used by the Virtual Texturing system, which is part of Unreal Engine’s rendering module. Specifically, it’s utilized in the VirtualTexturePhysicalSpace component of the renderer.

The value of this variable is set as a console variable with a default value of 4. It can be modified at runtime through the console or programmatically.

The associated variable CVarVTResidencyMaxMipMapBias directly interacts with r.VT.Residency.MaxMipMapBias. They share the same value and purpose.

Developers must be aware that this variable affects the performance and visual quality of virtual textures. A higher value may reduce memory usage but could potentially decrease texture quality, while a lower value might improve texture quality at the cost of increased memory usage.

Best practices when using this variable include:

  1. Monitor performance and visual quality when adjusting this value.
  2. Consider the target hardware capabilities when setting this value.
  3. Test thoroughly with different scenes and texture-heavy environments to ensure optimal settings.

Regarding the associated variable CVarVTResidencyMaxMipMapBias:

This is an internal representation of the r.VT.Residency.MaxMipMapBias console variable. It’s used within the C++ code to access the current value of the setting.

The purpose of CVarVTResidencyMaxMipMapBias is the same as r.VT.Residency.MaxMipMapBias - to control the maximum mip bias for Virtual Texture pool residency.

It’s used in the UpdateResidencyTracking function of the FVirtualTexturePhysicalSpace class, which is part of the Virtual Texturing system in the renderer module.

The value is retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access to the current setting.

Developers should be aware that changes to r.VT.Residency.MaxMipMapBias will be reflected in CVarVTResidencyMaxMipMapBias, and vice versa.

Best practices include using this variable consistently throughout the codebase when referencing the maximum mip bias for Virtual Texture residency, rather than hardcoding values or using different variables for the same purpose.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/VirtualTexturePhysicalSpace.cpp:19

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarVTResidencyMaxMipMapBias(
	TEXT("r.VT.Residency.MaxMipMapBias"),
	4,
	TEXT("Maximum mip bias to apply to prevent Virtual Texture pool residency over-subscription.\n")
	TEXT("Default 4"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarVTResidencyUpperBound(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

CSV_DECLARE_CATEGORY_EXTERN(VirtualTexturing);

static TAutoConsoleVariable<float> CVarVTResidencyMaxMipMapBias(
	TEXT("r.VT.Residency.MaxMipMapBias"),
	4,
	TEXT("Maximum mip bias to apply to prevent Virtual Texture pool residency over-subscription.\n")
	TEXT("Default 4"),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/VirtualTexturePhysicalSpace.cpp:220

Scope (from outer to inner):

file
function     void FVirtualTexturePhysicalSpace::UpdateResidencyTracking

Source code excerpt:

	float UpperBound = CVarVTResidencyUpperBound.GetValueOnRenderThread();
	float AdjustmentRate = CVarVTResidencyAdjustmentRate.GetValueOnRenderThread();
	float MaxMipMapBias = CVarVTResidencyMaxMipMapBias.GetValueOnRenderThread();

	const uint32 NumPages = Pool.GetNumPages();
	const uint32 NumLockedPages = Pool.GetNumLockedPages();
	const float LockedPageResidency = (float)NumLockedPages / (float)NumPages;

	const uint32 PageFreeThreshold = FMath::Max(VirtualTextureScalability::GetPageFreeThreshold(), 0u);