r.TSR.AsyncCompute

r.TSR.AsyncCompute

#Overview

name: r.TSR.AsyncCompute

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.AsyncCompute is to control how Temporal Super Resolution (TSR) runs on async compute in Unreal Engine 5. It is primarily used for the rendering system, specifically for managing the execution of TSR passes on different compute queues.

This setting variable is utilized by the Renderer module of Unreal Engine 5, particularly in the Temporal Super Resolution subsystem. It’s directly referenced in the PostProcess/TemporalSuperResolution.cpp file, which is part of the runtime renderer.

The value of this variable is set through a console variable (CVarTSRAsyncCompute) with a default value of 2. It can be changed at runtime using console commands or through project settings.

The r.TSR.AsyncCompute variable interacts closely with the GSupportsEfficientAsyncCompute variable, which determines if the system supports efficient async compute.

Developers must be aware that this variable has four possible values (0-3), each representing a different level of async compute utilization for TSR passes: 0: Disables async compute for TSR 1: Runs only completely independent passes on async compute 2: Runs independent passes and those dependent on depth and velocity buffer on async compute (default) 3: Runs all TSR passes on async compute

Best practices when using this variable include:

  1. Consider the hardware capabilities of the target platforms, as not all systems support efficient async compute.
  2. Use the default value (2) unless there’s a specific reason to change it, as it provides a balance between performance and compatibility.
  3. Profile the application’s performance with different settings to find the optimal configuration for your specific use case.
  4. Be cautious when setting it to 3, as running all passes on async compute might not always yield the best performance or visual results.

Regarding the associated variable CVarTSRAsyncCompute:

The purpose of CVarTSRAsyncCompute is to provide a console-variable interface for the r.TSR.AsyncCompute setting. It allows for runtime modification of the async compute behavior for TSR.

This variable is used in the same Renderer module and TemporalSuperResolution subsystem as r.TSR.AsyncCompute. It’s defined and used in the TemporalSuperResolution.cpp file.

The value of CVarTSRAsyncCompute is set when the console variable is initialized, with a default value of 2. It can be changed at runtime through console commands.

CVarTSRAsyncCompute interacts directly with the GSupportsEfficientAsyncCompute variable to determine the final async compute behavior.

Developers should be aware that changes to CVarTSRAsyncCompute will immediately affect the TSR async compute behavior. They should also note that the actual behavior depends on hardware support for efficient async compute.

Best practices for using CVarTSRAsyncCompute include:

  1. Use it for debugging and performance tuning during development.
  2. Consider exposing it as a user-configurable setting in shipping builds if different hardware configurations benefit from different settings.
  3. Always check the GSupportsEfficientAsyncCompute flag before applying the CVarTSRAsyncCompute value to ensure compatibility with the current hardware.

#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:253

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<int32> CVarTSRAsyncCompute(
	TEXT("r.TSR.AsyncCompute"), 2,
	TEXT("Controls how TSR run on async compute. Some TSR passes can overlap with previous passes.\n")
	TEXT(" 0: Disabled;\n")
	TEXT(" 1: Run on async compute only passes that are completly independent from any intermediary resource of this frame, namely ClearPrevTextures and ForwardScatterDepth passes;\n")
	TEXT(" 2: Run on async compute only passes that are completly independent or only dependent on the depth and velocity buffer which can overlap for instance with translucency or DOF. Any passes on critical path remains on the graphics queue (default);\n")
	TEXT(" 3: Run all passes on async compute;"),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarTSRAsyncCompute(
	TEXT("r.TSR.AsyncCompute"), 2,
	TEXT("Controls how TSR run on async compute. Some TSR passes can overlap with previous passes.\n")
	TEXT(" 0: Disabled;\n")
	TEXT(" 1: Run on async compute only passes that are completly independent from any intermediary resource of this frame, namely ClearPrevTextures and ForwardScatterDepth passes;\n")
	TEXT(" 2: Run on async compute only passes that are completly independent or only dependent on the depth and velocity buffer which can overlap for instance with translucency or DOF. Any passes on critical path remains on the graphics queue (default);\n")
	TEXT(" 3: Run all passes on async compute;"),

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

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses

Source code excerpt:


	// whether TSR passes can run on async compute.
	int32 AsyncComputePasses = GSupportsEfficientAsyncCompute ? CVarTSRAsyncCompute.GetValueOnRenderThread() : 0;

	// period at which history changes is considered too distracting.
	const float FlickeringFramePeriod = CVarTSRFlickeringEnable.GetValueOnRenderThread() ? (CVarTSRFlickeringPeriod.GetValueOnRenderThread() / FMath::Max(RefreshRateToFrameRateCap, 1.0f)) : 0.0f;

	ETSRHistoryFormatBits HistoryFormatBits = ETSRHistoryFormatBits::None;
	{