r.AmbientOcclusion.AsyncComputeBudget

r.AmbientOcclusion.AsyncComputeBudget

#Overview

name: r.AmbientOcclusion.AsyncComputeBudget

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.AmbientOcclusion.AsyncComputeBudget is to control the balance of AsyncCompute work against Graphics work for the Ambient Occlusion (AO) computation in Unreal Engine’s rendering system. This setting is specifically used for the Screen Space Ambient Occlusion (SSAO) feature when it’s implemented using compute shaders.

This setting variable is primarily used by the rendering subsystem of Unreal Engine, specifically in the Ambient Occlusion post-processing module.

The value of this variable is set through a console variable (CVar) system. It can be changed at runtime using console commands or through configuration files.

The associated variable CVarAmbientOcclusionAsyncComputeBudget directly interacts with r.AmbientOcclusion.AsyncComputeBudget. They share the same value and purpose.

Developers must be aware that:

  1. This setting only matters if the compute shader version of SSAO is active, which requires compute shader support, is enabled by a separate CVar, uses a single pass, and doesn’t use normals.
  2. It’s a low-level developer tweak intended for performance optimization on hardware that supports AsyncCompute.
  3. The value ranges from 0 (least AsyncCompute) to 4 (most AsyncCompute), with 1 being the default.

Best practices when using this variable include:

  1. Only adjust this if you’re experiencing performance issues related to SSAO computation.
  2. Test thoroughly on target hardware, as the optimal setting may vary depending on the specific GPU capabilities.
  3. Consider the trade-offs between graphics and compute workloads when adjusting this value.

Regarding the associated variable CVarAmbientOcclusionAsyncComputeBudget:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:69

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarAmbientOcclusionAsyncComputeBudget(
	TEXT("r.AmbientOcclusion.AsyncComputeBudget"),
	1,
	TEXT("Defines which level of EAsyncComputeBudget to use for balancing AsyncCompute work against Gfx work.\n")
	TEXT("Only matters if the compute version of SSAO is active (requires CS support, enabled by cvar, single pass, no normals)\n")
	TEXT("This is a low level developer tweak to get best performance on hardware that supports AsyncCompute.\n")
	TEXT(" 0: least AsyncCompute\n")
	TEXT(" 1: .. (default)\n")

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:68

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarAmbientOcclusionAsyncComputeBudget(
	TEXT("r.AmbientOcclusion.AsyncComputeBudget"),
	1,
	TEXT("Defines which level of EAsyncComputeBudget to use for balancing AsyncCompute work against Gfx work.\n")
	TEXT("Only matters if the compute version of SSAO is active (requires CS support, enabled by cvar, single pass, no normals)\n")
	TEXT("This is a low level developer tweak to get best performance on hardware that supports AsyncCompute.\n")
	TEXT(" 0: least AsyncCompute\n")

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:196

Scope (from outer to inner):

file
function     EAsyncComputeBudget FSSAOHelper::GetAmbientOcclusionAsyncComputeBudget

Source code excerpt:

EAsyncComputeBudget FSSAOHelper::GetAmbientOcclusionAsyncComputeBudget()
{
	int32 RawBudget = CVarAmbientOcclusionAsyncComputeBudget.GetValueOnRenderThread();

	return (EAsyncComputeBudget)FMath::Clamp(RawBudget, (int32)EAsyncComputeBudget::ELeast_0, (int32)EAsyncComputeBudget::EAll_4);
}

bool FSSAOHelper::IsBasePassAmbientOcclusionRequired(const FViewInfo& View)
{