NaniteStats
NaniteStats
#Overview
name: NaniteStats
This variable is created as a Console Variable (cvar).
- type:
Exec
- help:
Sorry: Exec commands have no help
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of NaniteStats is to provide statistical information about Nanite, Unreal Engine 5’s virtualized geometry system. It is used for performance monitoring, debugging, and optimization of the Nanite rendering pipeline.
This setting variable is primarily used by the Renderer subsystem of Unreal Engine 5, as evidenced by its references in the Renderer.cpp and VirtualShadowMapArray.cpp files. It is also utilized in the Virtual Shadow Map system, which is part of the rendering pipeline.
The value of this variable is not directly set in the provided code snippets. Instead, it appears to be accessed and used through various functions and buffers. For example, in VirtualShadowMapArray.cpp, it’s used to create a Shader Resource View (SRV) for passing Nanite statistics to shader code.
NaniteStats interacts with other variables and systems, such as:
- The Virtual Shadow Map system, as seen in VirtualShadowMapCacheManager.cpp
- GPU messaging system (GPUMessageParams)
- Structured buffers for storing and accessing the statistics data
Developers should be aware of the following when using this variable:
- It’s part of a debugging and profiling system, so it may impact performance when enabled.
- The statistics gathering can be filtered, as seen in the “NaniteStats VirtualShadowMaps” command.
- It’s closely tied to the Virtual Shadow Map system, which is an advanced rendering feature.
Best practices for using NaniteStats include:
- Only enable it when necessary for debugging or performance analysis, as it may have a performance cost.
- Use appropriate filters (e.g., “VirtualShadowMaps”) to focus on specific areas of interest.
- Combine its use with other profiling tools and metrics for a comprehensive understanding of Nanite’s performance.
- Be familiar with the Nanite system and its integration with other rendering features like Virtual Shadow Maps to interpret the statistics correctly.
- Consider using it in development and testing environments rather than in production builds to avoid any potential performance impact on end-users.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Renderer.cpp:632
Scope (from outer to inner):
file
function static bool RendererExec
Source code excerpt:
return true;
}
else if (FParse::Command(&Cmd, TEXT("NaniteStats")))
{
NaniteStatsFilterExec(Cmd, Ar);
return true;
}
else if(FParse::Command(&Cmd, TEXT("r.RHI.Name")))
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapArray.cpp:1932
Scope (from outer to inner):
file
function void FVirtualShadowMapArray::LogStats
Source code excerpt:
if (bBindNaniteStatsBuffer)
{
PassParameters->NaniteStats = GraphBuilder.CreateSRV(StatsNaniteBufferRDG);
}
else
{
PassParameters->NaniteStats = GraphBuilder.CreateSRV(GSystemTextures.GetDefaultStructuredBuffer(GraphBuilder, sizeof(FNaniteStats)));
}
PassParameters->GPUMessageParams = GPUMessage::GetShaderParameters(GraphBuilder);
auto ComputeShader = View.ShaderMap->GetShader<FVirtualSmLogStatsCS>();
FComputeShaderUtils::AddPass(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapCacheManager.cpp:1053
Scope (from outer to inner):
file
function void FVirtualShadowMapArrayCacheManager::ExtractStats
Source code excerpt:
// Optionally pull in some nanite stats too
// NOTE: This only works if nanite is set to gather stats from the VSM pass!
// i.e. run "NaniteStats VirtualShadowMaps" before starting accumulation
if (Nanite::IsStatFilterActive(TEXT("VirtualShadowMaps")))
{
TRefCountPtr<FRDGPooledBuffer> NaniteStatsBuffer = Nanite::GGlobalResources.GetStatsBufferRef();
if (NaniteStatsBuffer)
{
PassParameters->NaniteStatsBuffer = GraphBuilder.CreateSRV(GraphBuilder.RegisterExternalBuffer(NaniteStatsBuffer));