r.FastVRam.ShadowPointLight

r.FastVRam.ShadowPointLight

#Overview

name: r.FastVRam.ShadowPointLight

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.FastVRam.ShadowPointLight is to control the texture creation flags for point light shadow maps in Unreal Engine 5’s rendering system. This setting variable is used to optimize memory allocation and usage for point light shadows.

The Unreal Engine subsystem that primarily relies on this setting variable is the rendering system, specifically the shadow rendering and scene rendering modules.

The value of this variable is set using the FASTVRAM_CVAR macro in the SceneRendering.cpp file. It is initialized with a default value of 0.

This variable interacts with other shadow-related variables like ShadowPerObject and ShadowCSM, which are part of the FFastVramConfig struct. It is also associated with the ShadowPointLight variable in the same struct.

Developers must be aware that modifying this variable can affect the performance and memory usage of point light shadows in the engine. It’s important to consider the trade-offs between faster VRAM access and potentially increased memory consumption.

Best practices when using this variable include:

  1. Testing the performance impact of enabling or disabling fast VRAM for point light shadows in your specific use case.
  2. Considering the target hardware capabilities when adjusting this setting.
  3. Balancing the use of fast VRAM across different shadow types (point light, per-object, cascaded shadow maps) based on your project’s needs.

Regarding the associated variable ShadowPointLight:

The purpose of ShadowPointLight is to store the texture creation flags for point light shadow maps within the FFastVramConfig struct. It directly corresponds to the r.FastVRam.ShadowPointLight console variable.

This variable is used in the rendering system to apply the appropriate texture creation flags when allocating memory for point light shadow maps. It is accessed in various parts of the rendering code, such as in the FShadowDepthPassMeshProcessor and FSceneRenderer classes.

The value of ShadowPointLight is updated in the FFastVramConfig::Update() function, which reads the value from the corresponding console variable (r.FastVRam.ShadowPointLight).

Developers should be aware that changes to ShadowPointLight will affect how point light shadow textures are created and potentially impact rendering performance and memory usage.

Best practices for using ShadowPointLight include:

  1. Ensuring that any modifications to r.FastVRam.ShadowPointLight are reflected in ShadowPointLight through the update mechanism.
  2. Considering the impact on other shadow types and overall rendering performance when adjusting this variable.
  3. Profiling the application to determine the optimal settings for your specific use case and target hardware.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


FASTVRAM_CVAR(CustomDepth, 0);
FASTVRAM_CVAR(ShadowPointLight, 0);
FASTVRAM_CVAR(ShadowPerObject, 0);
FASTVRAM_CVAR(ShadowCSM, 0);

FASTVRAM_CVAR(DistanceFieldCulledObjectBuffers, 1);
FASTVRAM_CVAR(DistanceFieldTileIntersectionResources, 1);
FASTVRAM_CVAR(DistanceFieldAOScreenGridResources, 1);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


FASTVRAM_CVAR(CustomDepth, 0);
FASTVRAM_CVAR(ShadowPointLight, 0);
FASTVRAM_CVAR(ShadowPerObject, 0);
FASTVRAM_CVAR(ShadowCSM, 0);

FASTVRAM_CVAR(DistanceFieldCulledObjectBuffers, 1);
FASTVRAM_CVAR(DistanceFieldTileIntersectionResources, 1);
FASTVRAM_CVAR(DistanceFieldAOScreenGridResources, 1);

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

Scope (from outer to inner):

file
function     void FFastVramConfig::Update

Source code excerpt:

	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DOFPostfilter, DOFPostfilter);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_CustomDepth, CustomDepth);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ShadowPointLight, ShadowPointLight);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ShadowPerObject, ShadowPerObject);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ShadowCSM, ShadowCSM);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_PostProcessMaterial, PostProcessMaterial);

	bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_DistanceFieldCulledObjectBuffers, DistanceFieldCulledObjectBuffers);
	bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_DistanceFieldTileIntersectionResources, DistanceFieldTileIntersectionResources);

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

Scope: file

Source code excerpt:


	ETextureCreateFlags CustomDepth;
	ETextureCreateFlags ShadowPointLight;
	ETextureCreateFlags ShadowPerObject;
	ETextureCreateFlags ShadowCSM;

	// Buffers
	EBufferUsageFlags DistanceFieldCulledObjectBuffers;
	EBufferUsageFlags DistanceFieldTileIntersectionResources;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:2034

Scope (from outer to inner):

file
function     void FShadowDepthPassMeshProcessor::CollectPSOInitializersInternal

Source code excerpt:

	{
		ETextureCreateFlags ShadowMapCreateFlags = TexCreate_DepthStencilTargetable | TexCreate_ShaderResource;
		ShadowMapCreateFlags |= GFastVRamConfig.ShadowPointLight;
		if (InShadowDepthType.bOnePassPointLightShadow)
		{
			ShadowMapCreateFlags |= TexCreate_NoFastClear;
		}

		RenderTargetsInfo.NumSamples = 1;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:5939

Scope (from outer to inner):

file
function     void FSceneRenderer::AllocateOnePassPointLightDepthTargets

Source code excerpt:


				FPooledRenderTargetDesc Desc(FPooledRenderTargetDesc::CreateCubemapDesc(ProjectedShadowInfo->ResolutionX, PF_ShadowDepth, FClearValueBinding::DepthFar, TexCreate_None, TexCreate_DepthStencilTargetable | TexCreate_NoFastClear | TexCreate_ShaderResource, false, 1, 1, false));
				Desc.Flags |= GFastVRamConfig.ShadowPointLight;
				GRenderTargetPool.FindFreeElement(RHICmdList, Desc, ShadowMapCubemap.RenderTargets.DepthTarget, TEXT("CubeShadowDepthZ") );

				if (ProjectedShadowInfo->CacheMode == SDCM_StaticPrimitivesOnly)
				{
					FCachedShadowMapData& CachedShadowMapData = Scene->GetCachedShadowMapDataRef(ProjectedShadowInfo->GetLightSceneInfo().Id);
					CachedShadowMapData.ShadowMap = ShadowMapCubemap.RenderTargets;