r.FastVRam.DistanceFieldAOHistory

r.FastVRam.DistanceFieldAOHistory

#Overview

name: r.FastVRam.DistanceFieldAOHistory

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

It is referenced in 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.FastVRam.DistanceFieldAOHistory is to control the texture creation flags for the Distance Field Ambient Occlusion (DFAO) history buffer in Unreal Engine 5’s rendering system. This setting is part of the Fast VRAM configuration, which allows developers to optimize memory usage and performance for specific rendering features.

Developers should be aware of the following when using this variable:

  1. Changing this setting can affect memory usage and performance, especially on platforms with limited or shared video memory.
  2. The impact of this setting may vary depending on the hardware and the specific use case of Distance Field Ambient Occlusion in the project.
  3. Adjusting this setting might require balancing with other Fast VRAM settings to achieve optimal performance.

Best practices when using this variable include:

  1. Profiling the application’s performance and memory usage with different values for this setting.
  2. Considering the target hardware specifications when adjusting this setting.
  3. Testing the visual quality of DFAO with different Fast VRAM configurations to ensure no significant degradation occurs.
  4. Coordinating changes to this setting with other Distance Field-related settings for consistent performance and quality.

The associated variable DistanceFieldAOHistory is used in various parts of the rendering code, particularly in the UpdateHistory function and when allocating render targets for DFAO. It determines the texture creation flags for the DFAO history buffer, which can affect how the texture is stored and accessed in memory.

When using DistanceFieldAOHistory, developers should:

  1. Understand that it directly affects the memory allocation and possibly the performance of the DFAO feature.
  2. Be aware that changes to this variable may require adjustments to related Distance Field settings for optimal results.
  3. Consider the implications on different hardware, especially those with limited or shared video memory.
  4. Test thoroughly after making changes to ensure that DFAO quality and performance meet the project’s requirements.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:483

Scope: file

Source code excerpt:

FASTVRAM_CVAR(Upscale, 1);
FASTVRAM_CVAR(DistanceFieldNormal, 1);
FASTVRAM_CVAR(DistanceFieldAOHistory, 1);
FASTVRAM_CVAR(DistanceFieldAODownsampledBentNormal, 1); 
FASTVRAM_CVAR(DistanceFieldAOBentNormal, 0); 
FASTVRAM_CVAR(DistanceFieldIrradiance, 0); 
FASTVRAM_CVAR(DistanceFieldShadows, 1);
FASTVRAM_CVAR(Distortion, 1);
FASTVRAM_CVAR(ScreenSpaceShadowMask, 1);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldLightingPost.cpp:335

Scope (from outer to inner):

file
function     void UpdateHistory

Source code excerpt:

			FRDGTextureRef BentNormalHistoryTexture = GraphBuilder.RegisterExternalTexture(*BentNormalHistoryState);

			ETextureCreateFlags HistoryPassOutputFlags = ETextureCreateFlags(UseAOHistoryStabilityPass() ? GFastVRamConfig.DistanceFieldAOHistory : TexCreate_None);
			// Reuse a render target from the pool with a consistent name, for vis purposes
			FRDGTextureRef NewBentNormalHistory = nullptr;
			AllocateOrReuseAORenderTarget(GraphBuilder, View, NewBentNormalHistory, BentNormalHistoryRTName, PF_FloatRGBA, HistoryPassOutputFlags);

			{
				FIntRect PrevHistoryViewRect = *DistanceFieldAOHistoryViewRect;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldLightingPost.cpp:504

Scope (from outer to inner):

file
function     void UpdateHistory

Source code excerpt:

			// Use the current frame's upscaled mask for next frame's history
			FRDGTextureRef DistanceFieldAOBentNormal = nullptr;
			AllocateOrReuseAORenderTarget(GraphBuilder, View, DistanceFieldAOBentNormal, TEXT("PerViewDistanceFieldBentNormalAO"), PF_FloatRGBA, GFastVRamConfig.DistanceFieldAOHistory);

			GeometryAwareUpsample(GraphBuilder, View, DistanceFieldAOBentNormal, DistanceFieldNormal, BentNormalInterpolation, Parameters);

			GraphBuilder.QueueTextureExtraction(DistanceFieldAOBentNormal, BentNormalHistoryState);
			BentNormalHistoryOutput = DistanceFieldAOBentNormal;
		}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldLightingPost.cpp:519

Scope (from outer to inner):

file
function     void UpdateHistory

Source code excerpt:

		// Temporal reprojection is disabled or there is no view state - just upscale
		FRDGTextureRef DistanceFieldAOBentNormal = nullptr;
		AllocateOrReuseAORenderTarget(GraphBuilder, View, DistanceFieldAOBentNormal, TEXT("PerViewDistanceFieldBentNormalAO"), PF_FloatRGBA, GFastVRamConfig.DistanceFieldAOHistory);

		GeometryAwareUpsample(GraphBuilder, View, DistanceFieldAOBentNormal, DistanceFieldNormal, BentNormalInterpolation, Parameters);

		BentNormalHistoryOutput = DistanceFieldAOBentNormal;
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldScreenGridLighting.cpp:277

Scope (from outer to inner):

file
function     void PostProcessBentNormalAOScreenGrid

Source code excerpt:

		GraphBuilder,
		View,
		TEXT("DistanceFieldAOHistory"),
		SceneTexturesUniformBuffer,
		VelocityTexture,
		DistanceFieldNormal,
		BentNormalInterpolation,
		DistanceFieldAOHistoryViewRect,
		BentNormalHistoryState,
		BentNormalOutput,
		Parameters);
}

void FDeferredShadingSceneRenderer::RenderDistanceFieldAOScreenGrid(
	FRDGBuilder& GraphBuilder,
	const FSceneTextures& SceneTextures,
	const FViewInfo& View,
	const FDistanceFieldCulledObjectBufferParameters& CulledObjectBufferParameters,
	FRDGBufferRef ObjectTilesIndirectArguments,
	const FTileIntersectionParameters& TileIntersectionParameters,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:483

Scope: file

Source code excerpt:

FASTVRAM_CVAR(Upscale, 1);
FASTVRAM_CVAR(DistanceFieldNormal, 1);
FASTVRAM_CVAR(DistanceFieldAOHistory, 1);
FASTVRAM_CVAR(DistanceFieldAODownsampledBentNormal, 1); 
FASTVRAM_CVAR(DistanceFieldAOBentNormal, 0); 
FASTVRAM_CVAR(DistanceFieldIrradiance, 0); 
FASTVRAM_CVAR(DistanceFieldShadows, 1);
FASTVRAM_CVAR(Distortion, 1);
FASTVRAM_CVAR(ScreenSpaceShadowMask, 1);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:683

Scope (from outer to inner):

file
function     void FFastVramConfig::Update

Source code excerpt:

	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_Upscale, Upscale);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldNormal, DistanceFieldNormal);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldAOHistory, DistanceFieldAOHistory);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldAODownsampledBentNormal, DistanceFieldAODownsampledBentNormal);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldAOBentNormal, DistanceFieldAOBentNormal);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldIrradiance, DistanceFieldIrradiance);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldShadows, DistanceFieldShadows);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_Distortion, Distortion);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ScreenSpaceShadowMask, ScreenSpaceShadowMask);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2832

Scope: file

Source code excerpt:

	ETextureCreateFlags Upscale;
	ETextureCreateFlags DistanceFieldNormal;
	ETextureCreateFlags DistanceFieldAOHistory;
	ETextureCreateFlags DistanceFieldAOBentNormal;
	ETextureCreateFlags DistanceFieldAODownsampledBentNormal;
	ETextureCreateFlags DistanceFieldShadows;
	ETextureCreateFlags DistanceFieldIrradiance;
	ETextureCreateFlags DistanceFieldAOConfidence;
	ETextureCreateFlags Distortion;