r.DynamicRes.HistorySize

r.DynamicRes.HistorySize

#Overview

name: r.DynamicRes.HistorySize

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.HistorySize is to control the number of frames kept in the history for dynamic resolution calculations in Unreal Engine 5’s rendering system.

This setting variable is primarily used by the dynamic resolution subsystem within Unreal Engine’s rendering module. Based on the callsites, it’s evident that this variable is utilized in the DynamicResolution.cpp file, which is part of the Engine’s runtime.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 16 frames, but can be changed at runtime using console commands or through engine configuration files.

The variable interacts closely with its associated variable CVarHistorySize, which is a TAutoConsoleVariable that directly corresponds to the r.DynamicRes.HistorySize setting. This associated variable is used to retrieve the current value of the setting in the render thread.

Developers should be aware that changing this value affects the memory usage and responsiveness of the dynamic resolution system. A larger history size may provide more stable results but at the cost of increased memory usage and potentially slower response to sudden changes in performance.

Best practices when using this variable include:

  1. Keeping the value reasonably small (the default of 16 is a good starting point) to balance between stability and responsiveness.
  2. Adjusting it based on the specific needs of the game and target hardware capabilities.
  3. Testing thoroughly with different values to find the optimal setting for the specific use case.

Regarding the associated variable CVarHistorySize:

When working with CVarHistorySize, it’s important to remember that changes to this variable will directly affect the behavior of the dynamic resolution system, so it should be modified with caution and thorough testing.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHistorySize(
	TEXT("r.DynamicRes.HistorySize"),
	16,
	TEXT("Number of frames keept in the history."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarFrameWeightExponent(
	TEXT("r.DynamicRes.FrameWeightExponent"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarHistorySize(
	TEXT("r.DynamicRes.HistorySize"),
	16,
	TEXT("Number of frames keept in the history."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarFrameWeightExponent(

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

Scope (from outer to inner):

file
function     void FDynamicResolutionHeuristicProxy::ResizeHistoryIfNeeded

Source code excerpt:

void FDynamicResolutionHeuristicProxy::ResizeHistoryIfNeeded()
{
	uint32 DesiredHistorySize = FMath::Max(1, CVarHistorySize.GetValueOnRenderThread());

	if (History.Num() == DesiredHistorySize)
	{
		return;
	}