r.DynamicRes.FrameTimeBudget
r.DynamicRes.FrameTimeBudget
#Overview
name: r.DynamicRes.FrameTimeBudget
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Frame\'s time budget in milliseconds.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DynamicRes.FrameTimeBudget is to set the frame’s time budget in milliseconds for dynamic resolution scaling. This setting is crucial for the dynamic resolution system in Unreal Engine 5, which adjusts the rendering resolution to maintain a target frame rate.
This setting variable is primarily used by the dynamic resolution subsystem within Unreal Engine’s rendering module. It’s referenced in the DynamicResolution.cpp file, which is part of the Engine’s runtime.
The value of this variable is initially set to 33.3f milliseconds (which corresponds to about 30 FPS) in the Engine’s source code. However, it can be modified at runtime through the console or programmatically, as seen in the LyraSettingsLocal.cpp file.
The r.DynamicRes.FrameTimeBudget variable interacts closely with other dynamic resolution settings, such as CVarDynamicResThrottlingMaxSP, CVarUpperBoundQuantization, and CVarOverBudgetGPUHeadRoomPercentage. These variables collectively determine how the dynamic resolution system behaves.
Developers must be aware that this variable directly impacts the game’s performance and visual quality. Setting it too low might result in unnecessarily reduced resolution, while setting it too high might not achieve the desired frame rate.
Best practices when using this variable include:
- Adjusting it based on the target frame rate for your game.
- Testing thoroughly across different hardware configurations.
- Considering player preferences and providing options to adjust this setting in-game.
Regarding the associated variable CVarFrameTimeBudget:
The purpose of CVarFrameTimeBudget is the same as r.DynamicRes.FrameTimeBudget. It’s an internal representation of the console variable within the engine’s code.
This variable is used directly in the engine’s DynamicResolution.cpp file to retrieve the current frame time budget value. It’s part of the core engine implementation of the dynamic resolution system.
The value of CVarFrameTimeBudget is set when r.DynamicRes.FrameTimeBudget is set, as they represent the same setting.
CVarFrameTimeBudget interacts with other internal variables in the GetPrimaryDynamicResolutionSettings function to calculate various parameters for the dynamic resolution system.
Developers should be aware that modifying CVarFrameTimeBudget directly in code will have the same effect as changing r.DynamicRes.FrameTimeBudget through the console.
Best practices for CVarFrameTimeBudget are the same as for r.DynamicRes.FrameTimeBudget, as they are effectively 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:39
Scope: file
Source code excerpt:
// TODO: Seriously need a centralized engine perf manager.
static TAutoConsoleVariable<float> CVarFrameTimeBudget(
TEXT("r.DynamicRes.FrameTimeBudget"),
33.3f,
TEXT("Frame's time budget in milliseconds."),
ECVF_RenderThreadSafe | ECVF_Default);
#if COMPILE_DYNAMIC_FRAME_TIME
#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/Settings/LyraSettingsLocal.cpp:1760
Scope (from outer to inner):
file
function void ULyraSettingsLocal::UpdateDynamicResFrameTime
Source code excerpt:
void ULyraSettingsLocal::UpdateDynamicResFrameTime(float TargetFPS)
{
static IConsoleVariable* CVarDyResFrameTimeBudget = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DynamicRes.FrameTimeBudget"));
if (CVarDyResFrameTimeBudget)
{
if (ensure(TargetFPS > 0.0f))
{
const float DyResFrameTimeBudget = 1000.0f / TargetFPS;
CVarDyResFrameTimeBudget->Set(DyResFrameTimeBudget, ECVF_SetByGameSetting);
#Associated Variable and Callsites
This variable is associated with another variable named CVarFrameTimeBudget
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:38
Scope: file
Source code excerpt:
// TODO: Seriously need a centralized engine perf manager.
static TAutoConsoleVariable<float> CVarFrameTimeBudget(
TEXT("r.DynamicRes.FrameTimeBudget"),
33.3f,
TEXT("Frame's time budget in milliseconds."),
ECVF_RenderThreadSafe | ECVF_Default);
#if COMPILE_DYNAMIC_FRAME_TIME
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:152
Scope (from outer to inner):
file
function DynamicRenderScaling::FHeuristicSettings GetPrimaryDynamicResolutionSettings
Source code excerpt:
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;
}