r.Translucency.DynamicRes.UpperBoundQuantization

r.Translucency.DynamicRes.UpperBoundQuantization

#Overview

name: r.Translucency.DynamicRes.UpperBoundQuantization

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.Translucency.DynamicRes.UpperBoundQuantization is to control the quantization step count for the upper bound screen percentage in dynamic resolution scaling for translucency rendering. This setting is part of the rendering system, specifically for managing dynamic resolution in translucent rendering.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the translucent rendering subsystem. It’s referenced in the TranslucentRendering.cpp file, which handles various aspects of rendering translucent objects.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value from DynamicRenderScaling::FHeuristicSettings::kDefaultUpperBoundQuantization, but can be changed at runtime through console commands or game code.

The associated variable CVarTranslucencyUpperBoundQuantization directly interacts with r.Translucency.DynamicRes.UpperBoundQuantization. They essentially represent the same setting, with CVarTranslucencyUpperBoundQuantization being the actual CVar object used in the code.

Developers must be aware of several important aspects when using this variable:

  1. If set to a non-zero value, render targets will be resized based on the dynamic resolution fraction. This can save GPU time during clears and resolves.
  2. It’s recommended to use this setting with the transient allocator on supported platforms, particularly with a large transient texture cache (e.g., RHI.TransientAllocator.TextureCacheSize=512).
  3. Changes to this variable will affect the performance and visual quality of translucent objects in the scene.

Best practices for using this variable include:

  1. Carefully balancing between performance gains and visual quality. Higher quantization steps can improve performance but may reduce visual fidelity.
  2. Testing thoroughly on target hardware to ensure the chosen value provides the desired balance of performance and quality.
  3. Considering the interaction with other dynamic resolution and translucency settings.
  4. Using in conjunction with the transient allocator and appropriate texture cache size for optimal results.

Regarding the associated variable CVarTranslucencyUpperBoundQuantization:

This is the actual console variable object that represents r.Translucency.DynamicRes.UpperBoundQuantization in the code. It’s used to get and set the value of the setting. The variable is of type TAutoConsoleVariable, indicating that it stores an integer value.

When working with this variable, developers should:

  1. Use GetValueOnAnyThread() to safely retrieve the current value from any thread.
  2. Be aware that changes to this variable will immediately affect the dynamic resolution behavior for translucency.
  3. Consider exposing this setting in user-facing graphics options if fine-tuning of translucency performance is desired.

The CVarTranslucencyUpperBoundQuantization is used in the GetDynamicTranslucencyResolutionSettings function to populate the UpperBoundQuantization field of the DynamicRenderScaling::FHeuristicSettings struct, which is then used to control the dynamic resolution behavior for translucency rendering.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:80

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTranslucencyUpperBoundQuantization(
	TEXT("r.Translucency.DynamicRes.UpperBoundQuantization"),
	DynamicRenderScaling::FHeuristicSettings::kDefaultUpperBoundQuantization,
	TEXT("Quantization step count to use for upper bound screen percentage.\n")
	TEXT("If non-zero, rendertargets will be resized based on the dynamic resolution fraction, saving GPU time during clears and resolves.\n")
	TEXT("Only recommended for use with the transient allocator (on supported platforms) with a large transient texture cache (e.g RHI.TransientAllocator.TextureCacheSize=512)"),
	ECVF_RenderThreadSafe | ECVF_Default);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:79

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarTranslucencyUpperBoundQuantization(
	TEXT("r.Translucency.DynamicRes.UpperBoundQuantization"),
	DynamicRenderScaling::FHeuristicSettings::kDefaultUpperBoundQuantization,
	TEXT("Quantization step count to use for upper bound screen percentage.\n")
	TEXT("If non-zero, rendertargets will be resized based on the dynamic resolution fraction, saving GPU time during clears and resolves.\n")
	TEXT("Only recommended for use with the transient allocator (on supported platforms) with a large transient texture cache (e.g RHI.TransientAllocator.TextureCacheSize=512)"),
	ECVF_RenderThreadSafe | ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:121

Scope (from outer to inner):

file
function     DynamicRenderScaling::FHeuristicSettings GetDynamicTranslucencyResolutionSettings

Source code excerpt:

	BucketSetting.ChangeThreshold       = DynamicRenderScaling::GetPercentageCVarToFraction(CVarTranslucencyChangeThreshold);
	BucketSetting.TargetedHeadRoom      = DynamicRenderScaling::GetPercentageCVarToFraction(CVarTranslucencyTargetedHeadRoomPercentage);
	BucketSetting.UpperBoundQuantization = CVarTranslucencyUpperBoundQuantization.GetValueOnAnyThread();
	return BucketSetting;
}

DynamicRenderScaling::FBudget GDynamicTranslucencyResolution(TEXT("DynamicTranslucencyResolution"), &GetDynamicTranslucencyResolutionSettings);