r.DynamicRes.MaxScreenPercentage
r.DynamicRes.MaxScreenPercentage
#Overview
name: r.DynamicRes.MaxScreenPercentage
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximal primary screen percentage. Importantly this setting controls the preallocated video memory needed by the renderer to render.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DynamicRes.MaxScreenPercentage is to control the maximum primary screen percentage for dynamic resolution scaling in Unreal Engine 5. This setting is crucial for the rendering system, specifically for dynamic resolution functionality.
This setting variable is primarily used in the Engine module, particularly within the dynamic resolution subsystem. It’s referenced in the DynamicResolution.cpp file, which suggests it’s a core part of the engine’s dynamic resolution scaling feature.
The value of this variable is set through a console variable (CVar) named CVarDynamicResMaxSP. It’s initialized with a default value derived from DynamicRenderScaling::FHeuristicSettings::kDefaultMaxResolutionFraction, converted to a percentage.
This variable interacts closely with other dynamic resolution settings, such as r.DynamicRes.MinScreenPercentage and r.DynamicRes.ThrottlingMaxScreenPercentage. It’s used in conjunction with these to define the range and behavior of dynamic resolution scaling.
Developers must be aware that this setting directly impacts the amount of video memory preallocated by the renderer. Setting this value too high could lead to excessive memory usage, while setting it too low might limit the maximum resolution achievable through dynamic scaling.
Best practices when using this variable include:
- Setting it to a value that balances between desired maximum resolution and available video memory.
- Considering the target hardware specifications when adjusting this value.
- Testing thoroughly across different scenarios to ensure optimal performance and visual quality.
Regarding the associated variable CVarDynamicResMaxSP:
The purpose of CVarDynamicResMaxSP is to serve as the actual console variable that stores and provides access to the r.DynamicRes.MaxScreenPercentage value within the engine’s code.
This variable is used in the Engine module, specifically in the dynamic resolution system. It’s defined and used in the DynamicResolution.cpp file.
The value of CVarDynamicResMaxSP is set when the engine initializes the console variables, and it can be modified at runtime through console commands.
CVarDynamicResMaxSP interacts directly with the r.DynamicRes.MaxScreenPercentage setting, essentially serving as its in-code representation. It’s used in calculations for determining the maximum resolution fraction in the dynamic resolution heuristics.
Developers should be aware that modifying CVarDynamicResMaxSP directly in code will affect the r.DynamicRes.MaxScreenPercentage setting. It’s generally preferable to modify the setting through the console variable system rather than changing the CVarDynamicResMaxSP variable directly.
Best practices for using CVarDynamicResMaxSP include:
- Accessing its value using the provided console variable interface rather than directly.
- Being cautious when modifying its value at runtime, as it affects memory allocation for rendering.
- Considering its impact on performance and visual quality when adjusting its value programmatically.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:24
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarDynamicResMaxSP(
TEXT("r.DynamicRes.MaxScreenPercentage"),
DynamicRenderScaling::FractionToPercentage(DynamicRenderScaling::FHeuristicSettings::kDefaultMaxResolutionFraction),
TEXT("Maximal primary screen percentage. Importantly this setting controls the preallocated video memory needed by the renderer to render."),
ECVF_Default);
static TAutoConsoleVariable<float> CVarDynamicResThrottlingMaxSP(
TEXT("r.DynamicRes.ThrottlingMaxScreenPercentage"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarDynamicResMaxSP
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:23
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Default);
static TAutoConsoleVariable<float> CVarDynamicResMaxSP(
TEXT("r.DynamicRes.MaxScreenPercentage"),
DynamicRenderScaling::FractionToPercentage(DynamicRenderScaling::FHeuristicSettings::kDefaultMaxResolutionFraction),
TEXT("Maximal primary screen percentage. Importantly this setting controls the preallocated video memory needed by the renderer to render."),
ECVF_Default);
static TAutoConsoleVariable<float> CVarDynamicResThrottlingMaxSP(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:149
Scope (from outer to inner):
file
function DynamicRenderScaling::FHeuristicSettings GetPrimaryDynamicResolutionSettings
Source code excerpt:
BudgetSetting.Model = DynamicRenderScaling::EHeuristicModel::Quadratic;
BudgetSetting.MinResolutionFraction = DynamicRenderScaling::GetPercentageCVarToFraction(CVarDynamicResMinSP);
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();