r.DynamicRes.DynamicFrameTime

r.DynamicRes.DynamicFrameTime

#Overview

name: r.DynamicRes.DynamicFrameTime

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.DynamicFrameTime is to control whether the dynamic resolution system should automatically adjust the frame time budget when the frame rate is limited by CPU performance. This setting is part of Unreal Engine’s dynamic resolution system, which is a rendering optimization technique.

The Unreal Engine subsystem that relies on this setting variable is the dynamic resolution system, which is part of the rendering pipeline. It’s implemented in the Engine module, specifically in the DynamicResolution.cpp file.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with a default value of 1 (enabled). Developers can change this value at runtime using console commands or through configuration files.

This variable interacts with other variables in the dynamic resolution system, particularly r.DynamicRes.FrameTimeBudget. When enabled, it allows the frame time budget to automatically increase when the CPU is the limiting factor for frame rate.

Developers must be aware that enabling this feature may result in dynamic changes to the resolution and frame time budget during gameplay. This can affect visual quality and performance characteristics of the game.

Best practices when using this variable include:

  1. Testing the game thoroughly with this feature both enabled and disabled to understand its impact on performance and visual quality.
  2. Monitoring CPU and GPU performance to ensure the automatic adjustments are beneficial for your specific game.
  3. Considering the target platforms and their typical CPU/GPU balance when deciding whether to use this feature.

Regarding the associated variable CVarDynamicFrameTimeEnable:

The purpose of CVarDynamicFrameTimeEnable is to serve as the actual storage and access point for the r.DynamicRes.DynamicFrameTime setting. It’s an implementation detail of how the console variable system works in Unreal Engine.

This variable is used directly in the engine code to check whether the dynamic frame time feature is enabled. For example, in the RefreshCurrentFrameResolutionFraction_RenderThread function, it’s used to determine whether to apply the dynamic frame time logic.

The value of this variable is set when the r.DynamicRes.DynamicFrameTime console command is used.

Developers should be aware that this is the actual variable checked in the code, so any runtime changes to r.DynamicRes.DynamicFrameTime will affect this variable.

Best practices for this variable are the same as for r.DynamicRes.DynamicFrameTime, as they represent the same setting. Developers should use the r.DynamicRes.DynamicFrameTime console command to modify this setting, rather than trying to change CVarDynamicFrameTimeEnable directly.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDynamicFrameTimeEnable(
	TEXT("r.DynamicRes.DynamicFrameTime"), 1,
	TEXT("Whether the r.DynamicRes.FrameTimeBudget should automatically increases when frame rate is bound by CPU."),
	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."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

#if COMPILE_DYNAMIC_FRAME_TIME

static TAutoConsoleVariable<int32> CVarDynamicFrameTimeEnable(
	TEXT("r.DynamicRes.DynamicFrameTime"), 1,
	TEXT("Whether the r.DynamicRes.FrameTimeBudget should automatically increases when frame rate is bound by CPU."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarDynamicFrameTimeErrorMarginPercent(
	TEXT("r.DynamicRes.DynamicFrameTime.ErrorMarginPercent"), 10.0f,

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

Scope (from outer to inner):

file
function     void FDynamicResolutionHeuristicProxy::RefreshCurrentFrameResolutionFraction_RenderThread

Source code excerpt:

#if COMPILE_DYNAMIC_FRAME_TIME
	float MinGlobalFrameTime = 0.0f;
	if (CVarDynamicFrameTimeEnable.GetValueOnRenderThread())
	{
		static const IConsoleVariable* VSyncCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VSync"));
		check(VSyncCVar);

		const int32 FrameTimeTrack = CVarDynamicFrameTimeTrack.GetValueOnRenderThread();