r.DynamicRes.DynamicFrameTime.ErrorMarginPercent
r.DynamicRes.DynamicFrameTime.ErrorMarginPercent
#Overview
name: r.DynamicRes.DynamicFrameTime.ErrorMarginPercent
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
How much headroom should be left between CPU and GPU.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DynamicRes.DynamicFrameTime.ErrorMarginPercent is to control the headroom between CPU and GPU performance in the dynamic resolution system of Unreal Engine 5. This setting is part of the engine’s dynamic resolution feature, which adjusts the rendering resolution in real-time to maintain a target frame rate.
This setting variable is primarily used by the dynamic resolution subsystem, which is part of Unreal Engine’s rendering module. Based on the callsites, it’s implemented in the DynamicResolution.cpp file, which is located in the Engine’s runtime.
The value of this variable is set as a console variable (CVar) with a default value of 10.0f. It can be modified at runtime through console commands or programmatically.
The associated variable CVarDynamicFrameTimeErrorMarginPercent directly interacts with r.DynamicRes.DynamicFrameTime.ErrorMarginPercent. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable is used to calculate the target frame time in the dynamic resolution system. It determines the percentage of headroom left between the actual frame time and the target frame time. A higher value will result in more conservative resolution scaling, potentially improving performance stability at the cost of visual quality.
Best practices when using this variable include:
- Adjust it based on the specific needs of your project. A lower value might improve visual quality but could lead to more frequent frame rate drops.
- Test thoroughly with different values to find the right balance between performance and visual quality for your specific use case.
- Consider exposing this setting to end-users for fine-tuning, especially in PC games where hardware varies significantly.
Regarding the associated variable CVarDynamicFrameTimeErrorMarginPercent:
The purpose of CVarDynamicFrameTimeErrorMarginPercent is identical to r.DynamicRes.DynamicFrameTime.ErrorMarginPercent. It’s the internal representation of the console variable within the engine’s code.
This variable is used directly in the FDynamicResolutionHeuristicProxy::RefreshCurrentFrameResolutionFraction_RenderThread function to calculate the target frame time for dynamic resolution adjustments.
The value of CVarDynamicFrameTimeErrorMarginPercent is set when the console variable r.DynamicRes.DynamicFrameTime.ErrorMarginPercent is initialized or modified.
Developers should be aware that modifying r.DynamicRes.DynamicFrameTime.ErrorMarginPercent will directly affect CVarDynamicFrameTimeErrorMarginPercent, and vice versa.
Best practices for CVarDynamicFrameTimeErrorMarginPercent are the same as for r.DynamicRes.DynamicFrameTime.ErrorMarginPercent, as they represent the same setting. When working with the engine’s source code, developers should use CVarDynamicFrameTimeErrorMarginPercent.GetValueOnRenderThread() to access this setting’s current value in render thread operations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:52
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarDynamicFrameTimeErrorMarginPercent(
TEXT("r.DynamicRes.DynamicFrameTime.ErrorMarginPercent"), 10.0f,
TEXT("How much headroom should be left between CPU and GPU."),
ECVF_RenderThreadSafe | ECVF_Default);
static TAutoConsoleVariable<int32> CVarDynamicFrameTimeTrack(
TEXT("r.DynamicRes.DynamicFrameTime.Track"), 1,
TEXT("What to track to control the budget\n")
#Associated Variable and Callsites
This variable is associated with another variable named CVarDynamicFrameTimeErrorMarginPercent
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:51
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Default);
static TAutoConsoleVariable<float> CVarDynamicFrameTimeErrorMarginPercent(
TEXT("r.DynamicRes.DynamicFrameTime.ErrorMarginPercent"), 10.0f,
TEXT("How much headroom should be left between CPU and GPU."),
ECVF_RenderThreadSafe | ECVF_Default);
static TAutoConsoleVariable<int32> CVarDynamicFrameTimeTrack(
TEXT("r.DynamicRes.DynamicFrameTime.Track"), 1,
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:360
Scope (from outer to inner):
file
function void FDynamicResolutionHeuristicProxy::RefreshCurrentFrameResolutionFraction_RenderThread
Source code excerpt:
}
const float MaxWithFrameFraction = (CVarDynamicFrameTimeErrorMarginPercent.GetValueOnRenderThread() / 100.0f);
float TargetFrameTime = MedianFrameTime * (1.0f - MaxWithFrameFraction);
DynamicFrameTimeBudgetMs = FMath::Lerp(TargetFrameTime, DynamicFrameTimeBudgetMs, FrameWeightExponent);
MinGlobalFrameTime = DynamicFrameTimeBudgetMs;
}