r.DynamicRes.MaxConsecutiveOverBudgetGPUFrameCount

r.DynamicRes.MaxConsecutiveOverBudgetGPUFrameCount

#Overview

name: r.DynamicRes.MaxConsecutiveOverBudgetGPUFrameCount

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.MaxConsecutiveOverBudgetGPUFrameCount is to control the dynamic resolution system in Unreal Engine 5. Specifically, it sets the maximum number of consecutive frames that are allowed to exceed the GPU budget before the engine takes action to adjust the resolution.

This setting variable is primarily used by the dynamic resolution system, which is part of Unreal Engine’s rendering subsystem. Based on the callsites, it’s implemented in the DynamicResolution.cpp file, which is part of the Engine module.

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

This variable interacts closely with other dynamic resolution settings, particularly those related to GPU timing and frame budgets. It’s used in conjunction with CVarFrameWeightExponent and CVarFrameChangePeriod to determine when and how to adjust the resolution.

Developers should be aware that this variable directly impacts the responsiveness and stability of the dynamic resolution system. Setting it too low might cause frequent resolution changes, while setting it too high might result in prolonged periods of suboptimal performance.

Best practices when using this variable include:

  1. Balancing it with other dynamic resolution settings for smooth transitions.
  2. Testing different values to find the right balance between performance and visual stability for your specific game.
  3. Considering the target platform and typical frame rates when setting this value.

Regarding the associated variable CVarMaxConsecutiveOverBudgetGPUFrameCount:

This is the actual console variable that stores the value of r.DynamicRes.MaxConsecutiveOverBudgetGPUFrameCount. It’s defined as a TAutoConsoleVariable, which means it’s an integer value that can be changed at runtime.

The purpose of this variable is the same as r.DynamicRes.MaxConsecutiveOverBudgetGPUFrameCount - it controls the maximum number of consecutive frames that can exceed the GPU budget before triggering a resolution change.

This variable is used directly in the RefreshCurrentFrameResolutionFraction_RenderThread() function of the FDynamicResolutionHeuristicProxy class. Here, it’s retrieved using GetValueOnRenderThread() and used to determine when to adjust the resolution.

Developers should be aware that this variable is marked as ECVF_RenderThreadSafe, meaning it’s safe to access from the render thread. However, changes to this value might not take effect immediately due to the nature of threaded rendering.

Best practices for using this variable include:

  1. Using the console command system to adjust it during runtime for testing.
  2. Considering exposing it as a user-configurable setting if fine-tuning is necessary for different hardware configurations.
  3. Documenting any changes to its default value in your project settings.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMaxConsecutiveOverBudgetGPUFrameCount(
	TEXT("r.DynamicRes.MaxConsecutiveOverBudgetGPUFrameCount"),
	2,
	TEXT("Maximum number of consecutive frames tolerated over GPU budget."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarTimingMeasureModel(
	TEXT("r.DynamicRes.GPUTimingMeasureMethod"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarMaxConsecutiveOverBudgetGPUFrameCount(
	TEXT("r.DynamicRes.MaxConsecutiveOverBudgetGPUFrameCount"),
	2,
	TEXT("Maximum number of consecutive frames tolerated over GPU budget."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarTimingMeasureModel(

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

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;
	if (CVarDynamicFrameTimeEnable.GetValueOnRenderThread())