r.DynamicRes.FrameWeightExponent

r.DynamicRes.FrameWeightExponent

#Overview

name: r.DynamicRes.FrameWeightExponent

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.FrameWeightExponent is to control the recursive weight of frame N-1 against frame N in the dynamic resolution system of Unreal Engine 5. This setting variable is part of the rendering system, specifically the dynamic resolution feature.

The Unreal Engine subsystem that relies on this setting variable is the dynamic resolution system, which is part of the rendering module. This can be inferred from the file location (DynamicResolution.cpp) and the variable’s name.

The value of this variable is set as a console variable with a default value of 0.9f. It can be modified at runtime through the console or programmatically.

This variable interacts with other variables in the dynamic resolution system, such as CVarFrameChangePeriod and CVarMaxConsecutiveOverBudgetGPUFrameCount, as seen in the RefreshCurrentFrameResolutionFraction_RenderThread() function.

Developers must be aware that this variable affects the smoothness of resolution changes in the dynamic resolution system. A higher value will result in slower adaptation to performance changes, while a lower value will make the system more responsive but potentially less stable.

Best practices when using this variable include:

  1. Keep the value between 0 and 1.
  2. Use higher values for more stable but slower-adapting resolution changes.
  3. Use lower values for quicker adaptation, but be cautious of potential instability.
  4. Test thoroughly with different values to find the best balance for your specific game requirements.

Regarding the associated variable CVarFrameWeightExponent:

The purpose of CVarFrameWeightExponent is to store and provide access to the r.DynamicRes.FrameWeightExponent value within the C++ code. It is an instance of TAutoConsoleVariable, which allows for easy access and modification of the console variable.

This variable is used in the dynamic resolution system to retrieve the current value of the frame weight exponent. It’s accessed using the GetValueOnRenderThread() method, ensuring thread-safe access in render thread contexts.

Developers should be aware that modifying CVarFrameWeightExponent directly will affect the behavior of the dynamic resolution system. It’s generally better to modify the console variable r.DynamicRes.FrameWeightExponent instead of changing CVarFrameWeightExponent directly in code.

Best practices for using CVarFrameWeightExponent include:

  1. Use GetValueOnRenderThread() when accessing the value in render thread contexts.
  2. Avoid modifying this variable directly; instead, modify the console variable it represents.
  3. Consider caching the value if it’s used frequently in performance-critical code sections to avoid repeated calls to GetValueOnRenderThread().

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarFrameWeightExponent(
	TEXT("r.DynamicRes.FrameWeightExponent"),
	0.9f,
	TEXT("Recursive weight of frame N-1 against frame N."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarFrameChangePeriod(
	TEXT("r.DynamicRes.MinResolutionChangePeriod"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarFrameWeightExponent(
	TEXT("r.DynamicRes.FrameWeightExponent"),
	0.9f,
	TEXT("Recursive weight of frame N-1 against frame N."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarFrameChangePeriod(

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

Scope (from outer to inner):

file
function     void FDynamicResolutionHeuristicProxy::RefreshCurrentFrameResolutionFraction_RenderThread

Source code excerpt:

{
	// Global constants.
	const float FrameWeightExponent = CVarFrameWeightExponent.GetValueOnRenderThread();
	const int32 MaxConsecutiveOverBudgetGPUFrameCount = FMath::Max(CVarMaxConsecutiveOverBudgetGPUFrameCount.GetValueOnRenderThread(), 2);

	const bool bCanChangeResolution = NumberOfFramesSinceScreenPercentageChange >= CVarFrameChangePeriod.GetValueOnRenderThread();

#if COMPILE_DYNAMIC_FRAME_TIME
	float MinGlobalFrameTime = 0.0f;