r.Shadow.Virtual.ShowStats
r.Shadow.Virtual.ShowStats
#Overview
name: r.Shadow.Virtual.ShowStats
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Show VSM statistics.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.ShowStats
is to display Virtual Shadow Map (VSM) statistics. This setting is used within the rendering system, specifically for virtual shadow mapping functionality.
The variable r.Shadow.Virtual.ShowStats
is primarily used in the Unreal Engine’s rendering subsystem, particularly in the Virtual Shadow Map module. It is referenced in the VirtualShadowMapArray.cpp
file, which is part of the Renderer module.
The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It is initialized with a default value of 0, meaning the VSM statistics are not shown by default.
This variable interacts with other parts of the VSM system, particularly the stats buffer creation and logging functionality. When enabled (set to a non-zero value), it triggers the creation of a stats buffer and enables the logging of VSM statistics.
Developers should be aware that enabling this variable may have performance implications, as it adds additional processing and memory usage for collecting and displaying statistics. It should primarily be used for debugging and performance analysis purposes.
Best practices when using this variable include:
- Only enable it when necessary for debugging or performance analysis.
- Be aware of the potential performance impact when enabled.
- Remember to disable it in release builds or when not actively debugging VSM issues.
The associated variable CVarShowStats
is directly linked to r.Shadow.Virtual.ShowStats
. It’s used in the C++ code to check the current value of the console variable and determine whether to show VSM statistics. This variable is used in various parts of the VSM system to conditionally execute stats-related code.
When working with CVarShowStats
, developers should:
- Use it to conditionally execute stats-related code.
- Be aware that it reflects the current value of
r.Shadow.Virtual.ShowStats
. - Consider the performance implications when this variable is set to a non-zero value.
#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:82
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarShowStats(
TEXT("r.Shadow.Virtual.ShowStats"),
0,
TEXT("Show VSM statistics."),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarPageDilationBorderSizeDirectional(
#Associated Variable and Callsites
This variable is associated with another variable named CVarShowStats
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:81
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarShowStats(
TEXT("r.Shadow.Virtual.ShowStats"),
0,
TEXT("Show VSM statistics."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:1328
Scope (from outer to inner):
file
function void FVirtualShadowMapArray::BuildPageAllocations
Source code excerpt:
#endif
if (CVarShowStats.GetValueOnRenderThread() || CacheManager->IsAccumulatingStats() || bRunPageAreaDiagnostics || bCsvLogEnabled)
{
StatsBufferRDG = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateStructuredDesc(sizeof(uint32), NumStats + MaxPageAreaDiagnosticSlots * 2), TEXT("Shadow.Virtual.StatsBuffer"));
AddClearUAVPass(GraphBuilder, GraphBuilder.CreateUAV(StatsBufferRDG), 0);
// For the rest of the frame we don't want the stats buffer adding additional barriers that are not otherwise present.
// Even though this is not a high performance path with stats enabled, we don't want to change behavior.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:1914
Scope (from outer to inner):
file
function void FVirtualShadowMapArray::LogStats
Source code excerpt:
ShaderPrint::SetEnabled(true);
int ShowStatsValue = CVarShowStats.GetValueOnRenderThread();
FVirtualSmLogStatsCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FVirtualSmLogStatsCS::FParameters>();
ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, PassParameters->ShaderPrintStruct);
PassParameters->InStatsBuffer = GraphBuilder.CreateSRV(StatsBufferRDG);
PassParameters->VirtualShadowMap = GetUncachedUniformBuffer(GraphBuilder);