r.Shadow.Virtual.ShowClipmapStats

r.Shadow.Virtual.ShowClipmapStats

#Overview

name: r.Shadow.Virtual.ShowClipmapStats

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.Shadow.Virtual.ShowClipmapStats is to control the display of statistics for virtual shadow map clipmaps in Unreal Engine 5’s rendering system. This setting variable is used to debug and analyze the performance of virtual shadow maps.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the virtual shadow mapping subsystem. It is referenced in the VirtualShadowMapArray.cpp file, which is part of the engine’s rendering implementation.

The value of this variable is set through a console command. It is defined as a TAutoConsoleVariable with an initial value of -1, which means the feature is off by default. Users can change this value at runtime to enable the display of statistics for a specific clipmap.

The associated variable CVarShowClipmapStats interacts directly with r.Shadow.Virtual.ShowClipmapStats. They share the same value and purpose. CVarShowClipmapStats is used in the C++ code to access the current value of the setting.

Developers must be aware that:

  1. This variable is render thread safe, meaning it can be safely accessed from the render thread.
  2. Setting a value other than -1 will enable the display of statistics for the specified clipmap number.
  3. This feature is primarily for debugging and performance analysis, and should not be enabled in release builds.

Best practices when using this variable include:

  1. Use it sparingly and only when needed for debugging or performance optimization.
  2. Remember to disable it (set to -1) after debugging to avoid unnecessary performance overhead.
  3. Be cautious when using it in multiplayer or networked environments, as it may affect performance.

Regarding the associated variable CVarShowClipmapStats:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:163

Scope: file

Source code excerpt:

);
static TAutoConsoleVariable<int32> CVarShowClipmapStats(
	TEXT("r.Shadow.Virtual.ShowClipmapStats"),
	-1,
	TEXT("Set to the number of clipmap you want to show stats for (-1 == off)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarCullBackfacingPixels(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:162

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarShowClipmapStats(
	TEXT("r.Shadow.Virtual.ShowClipmapStats"),
	-1,
	TEXT("Set to the number of clipmap you want to show stats for (-1 == off)"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:3049

Scope (from outer to inner):

file
function     void FVirtualShadowMapArray::RenderVirtualShadowMapsNonNanite

Source code excerpt:


		//
		if (Index == CVarShowClipmapStats.GetValueOnRenderThread())
		{
			// The 'main' view the shadow was created with respect to
			const FViewInfo* ViewUsedToCreateShadow = ProjectedShadowInfo->DependentView;
			const FViewInfo& View = *ViewUsedToCreateShadow;

			FVirtualSmPrintClipmapStatsCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FVirtualSmPrintClipmapStatsCS::FParameters>();