r.DynamicRes.UpperBoundQuantization

r.DynamicRes.UpperBoundQuantization

#Overview

name: r.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.DynamicRes.UpperBoundQuantization is to control the quantization step count for the upper bound screen percentage in Unreal Engine’s dynamic resolution system. This setting is part of the rendering system, specifically the dynamic resolution feature, which allows the engine to adjust the rendering resolution in real-time to maintain performance.

This setting is primarily used in the DynamicResolution subsystem of Unreal Engine. It’s implemented in the Engine module, as evidenced by its location in the DynamicResolution.cpp file.

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 CVarUpperBoundQuantization directly interacts with r.DynamicRes.UpperBoundQuantization. They share the same value and purpose.

Developers must be aware that this variable affects how the dynamic resolution system quantizes the upper bound of the screen percentage. If set to a non-zero value, it will cause render targets to be resized based on the dynamic resolution fraction, which can save GPU time during clears and resolves.

Best practices for using this variable include:

  1. Only use non-zero values when using the transient allocator on supported platforms.
  2. Ensure a large transient texture cache is set up (e.g., RHI.TransientAllocator.TextureCacheSize=512) when using non-zero values.
  3. Be cautious when adjusting this value, as it can impact both performance and visual quality.
  4. Test thoroughly across different hardware configurations to ensure optimal settings.

Regarding the associated variable CVarUpperBoundQuantization:

The purpose of CVarUpperBoundQuantization is to provide a programmatic interface to the r.DynamicRes.UpperBoundQuantization setting. It’s used internally by the engine to access and modify the setting value.

This variable is used in the GetPrimaryDynamicResolutionSettings function to populate the UpperBoundQuantization field of the FHeuristicSettings struct, which is used to configure the dynamic resolution system.

The value of CVarUpperBoundQuantization is typically not set directly but is instead modified through the r.DynamicRes.UpperBoundQuantization console variable.

Developers should be aware that changes to CVarUpperBoundQuantization will directly affect the behavior of the dynamic resolution system. It’s generally better to modify the r.DynamicRes.UpperBoundQuantization console variable rather than CVarUpperBoundQuantization directly, to ensure consistency across the engine.

Best practices for CVarUpperBoundQuantization align with those of r.DynamicRes.UpperBoundQuantization, as they represent the same setting.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:135

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarUpperBoundQuantization(
	TEXT("r.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 CVarUpperBoundQuantization. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:134

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarUpperBoundQuantization(
	TEXT("r.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/Engine/Private/DynamicResolution.cpp:151

Scope (from outer to inner):

file
function     DynamicRenderScaling::FHeuristicSettings GetPrimaryDynamicResolutionSettings

Source code excerpt:

	BudgetSetting.MaxResolutionFraction      = DynamicRenderScaling::GetPercentageCVarToFraction(CVarDynamicResMaxSP);
	BudgetSetting.ThrottlingMaxResolutionFraction = DynamicRenderScaling::GetPercentageCVarToFraction(CVarDynamicResThrottlingMaxSP);
	BudgetSetting.UpperBoundQuantization     = CVarUpperBoundQuantization.GetValueOnAnyThread();
	BudgetSetting.BudgetMs                   = CVarFrameTimeBudget.GetValueOnAnyThread() * (1.0f - DynamicRenderScaling::GetPercentageCVarToFraction(CVarOverBudgetGPUHeadRoomPercentage));
	BudgetSetting.ChangeThreshold            = DynamicRenderScaling::GetPercentageCVarToFraction(CVarChangeThreshold);
	BudgetSetting.TargetedHeadRoom           = DynamicRenderScaling::GetPercentageCVarToFraction(CVarTargetedGPUHeadRoomPercentage);
	BudgetSetting.IncreaseAmortizationFactor = CVarIncreaseAmortizationFactor.GetValueOnAnyThread();
	return BudgetSetting;
}