r.SkyAtmosphereASyncCompute

r.SkyAtmosphereASyncCompute

#Overview

name: r.SkyAtmosphereASyncCompute

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SkyAtmosphereASyncCompute is to control whether the Sky Atmosphere computation should run on the async compute pipeline in Unreal Engine 5. This setting is specifically related to the rendering system, particularly the Sky Atmosphere rendering feature.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the Sky Atmosphere rendering component. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with a default value of 0 (false), meaning async compute is disabled by default.

This variable interacts with an associated variable named CVarSkyAtmosphereASyncCompute. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the rendering pipeline and performance. When enabled (set to 1), the Sky Atmosphere LUT (Look-Up Table) generation will overlap with the occlusion pass, potentially improving performance. There’s also a value of 2, which changes the pass location to before the pre-pass.

Best practices when using this variable include:

  1. Testing performance with and without async compute enabled to determine the best setting for your specific use case.
  2. Being aware that enabling async compute may affect the rendering order and could potentially introduce visual artifacts if not properly managed.
  3. Considering the target hardware, as async compute performance can vary significantly between different GPU architectures.

Regarding the associated variable CVarSkyAtmosphereASyncCompute:

The purpose of CVarSkyAtmosphereASyncCompute is the same as r.SkyAtmosphereASyncCompute. It’s the actual console variable that controls the async compute setting for Sky Atmosphere rendering.

This variable is used in the Renderer module, specifically in the Sky Atmosphere rendering component.

The value is set when the engine initializes the console variables, and it can be changed at runtime through console commands.

It interacts directly with the r.SkyAtmosphereASyncCompute setting, as they represent the same value.

Developers should be aware that this variable is used to determine the pass location for Sky Atmosphere rendering in the GetSkyAtmospherePassLocation() function. It also affects the ERDGPassFlags used when setting up the rendering passes.

Best practices include using this variable for fine-tuning rendering performance and understanding its impact on the rendering pipeline, especially when optimizing for different hardware configurations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:218

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSkyAtmosphereASyncCompute(
	TEXT("r.SkyAtmosphereASyncCompute"), 0,
	TEXT("SkyAtmosphere on async compute (default: false). When running on the async pipe, SkyAtmosphere lut generation will overlap with the occlusion pass.\n"),
	ECVF_RenderThreadSafe);


DECLARE_GPU_STAT(SkyAtmosphereLUTs);
DECLARE_GPU_STAT(SkyAtmosphere);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:217

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarSkyAtmosphereASyncCompute(
	TEXT("r.SkyAtmosphereASyncCompute"), 0,
	TEXT("SkyAtmosphere on async compute (default: false). When running on the async pipe, SkyAtmosphere lut generation will overlap with the occlusion pass.\n"),
	ECVF_RenderThreadSafe);


DECLARE_GPU_STAT(SkyAtmosphereLUTs);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:284

Scope (from outer to inner):

file
function     ESkyAtmospherePassLocation GetSkyAtmospherePassLocation

Source code excerpt:

ESkyAtmospherePassLocation GetSkyAtmospherePassLocation()
{
	if (CVarSkyAtmosphereASyncCompute.GetValueOnAnyThread() == 1)
	{
		// When SkyAtmLUT is running on async compute, try to kick it before occlusion pass to have better wave occupancy
		return ESkyAtmospherePassLocation::BeforeOcclusion;
	}
	else if (CVarSkyAtmosphereASyncCompute.GetValueOnAnyThread() == 2)
	{
		return ESkyAtmospherePassLocation::BeforePrePass;
	}
	// When SkyAtmLUT is running on graphics pipe, kickbefore BasePass to have a better overlap when DistanceFieldShadows is running async
	return ESkyAtmospherePassLocation::BeforeBasePass;
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:1326

Scope (from outer to inner):

file
function     void FSceneRenderer::RenderSkyAtmosphereLookUpTables

Source code excerpt:

	FRDGTextureUAVRef MultiScatteredLuminanceLutUAV = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(MultiScatteredLuminanceLut, 0));

	ERDGPassFlags PassFlag = CVarSkyAtmosphereASyncCompute.GetValueOnAnyThread() ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute;

	// Transmittance LUT
	FGlobalShaderMap* GlobalShaderMap = GetGlobalShaderMap(FeatureLevel);
	if (CVarSkyAtmosphereTransmittanceLUT.GetValueOnRenderThread() > 0)
	{
		TShaderMapRef<FRenderTransmittanceLutCS> ComputeShader(GlobalShaderMap);