r.TSR.ShadingRejection.Flickering.FrameRateCap

r.TSR.ShadingRejection.Flickering.FrameRateCap

#Overview

name: r.TSR.ShadingRejection.Flickering.FrameRateCap

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.TSR.ShadingRejection.Flickering.FrameRateCap is to set a framerate cap for the Temporal Super Resolution (TSR) system, specifically for the shading rejection mechanism that handles flickering artifacts. This setting is part of Unreal Engine’s rendering system, particularly the post-processing pipeline.

This setting variable is primarily used in the Renderer module, specifically within the Temporal Super Resolution subsystem. It’s referenced in the TemporalSuperResolution.cpp file, which is responsible for implementing the TSR algorithm.

The value of this variable is set as a console variable with a default value of 60 (Hz). It can be modified at runtime through the console or configuration files.

This variable interacts closely with other TSR-related variables, particularly r.TSR.ShadingRejection.Flickering.Period and r.TSR.ShadingRejection.Flickering.AdjustToFrameRate. It’s used to automatically adjust the flickering period when the rendering frame rate is lower than the specified cap.

Developers must be aware that this setting affects the performance and visual quality of the TSR system. Setting it too high might lead to unnecessary computations, while setting it too low might result in visible flickering artifacts.

Best practices when using this variable include:

  1. Adjusting it based on the target platform’s capabilities and the game’s performance requirements.
  2. Testing thoroughly at different frame rates to ensure optimal visual quality.
  3. Considering the interaction with other TSR settings for a balanced configuration.

Regarding the associated variable CVarTSRFlickeringFrameRateCap:

This is the actual C++ variable that stores the console variable. It’s used internally by the engine to access the value set by r.TSR.ShadingRejection.Flickering.FrameRateCap. The purpose and usage are the same as described above.

The value of CVarTSRFlickeringFrameRateCap is typically accessed using the GetValueOnRenderThread() method, which ensures thread-safe access to the variable’s value.

When working with CVarTSRFlickeringFrameRateCap, developers should be aware that it’s marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it’s a scalability setting and safe to access from the render thread.

Best practices for using CVarTSRFlickeringFrameRateCap include accessing it only from the render thread and considering its performance impact when frequently querying its value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:154

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarTSRFlickeringFrameRateCap(
	TEXT("r.TSR.ShadingRejection.Flickering.FrameRateCap"), 60,
	TEXT("Framerate cap in hertz at which point there is automatic adjustment of r.TSR.ShadingRejection.Flickering.Period when the rendering frame rate is lower. ")
	TEXT("Please read r.TSR.ShadingRejection.Flickering's help for further details. (Default to 60hz)"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarTSRFlickeringAdjustToFrameRate(
	TEXT("r.TSR.ShadingRejection.Flickering.AdjustToFrameRate"), 1,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:153

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarTSRFlickeringFrameRateCap(
	TEXT("r.TSR.ShadingRejection.Flickering.FrameRateCap"), 60,
	TEXT("Framerate cap in hertz at which point there is automatic adjustment of r.TSR.ShadingRejection.Flickering.Period when the rendering frame rate is lower. ")
	TEXT("Please read r.TSR.ShadingRejection.Flickering's help for further details. (Default to 60hz)"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarTSRFlickeringAdjustToFrameRate(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:1300

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses

Source code excerpt:


	const float RefreshRateToFrameRateCap = (View.Family->Time.GetDeltaRealTimeSeconds() > 0.0f && CVarTSRFlickeringAdjustToFrameRate.GetValueOnRenderThread())
		? View.Family->Time.GetDeltaRealTimeSeconds() * CVarTSRFlickeringFrameRateCap.GetValueOnRenderThread() : 1.0f;

	// Maximum number sample for each output pixel in the history
	const float MaxHistorySampleCount = FMath::Clamp(CVarTSRHistorySampleCount.GetValueOnRenderThread(), 8.0f, 32.0f);

	// Whether the view is orthographic view
	const bool bIsOrthoProjection = !View.IsPerspectiveProjection();