r.MeshDrawCommands.LogDynamicInstancingStats

r.MeshDrawCommands.LogDynamicInstancingStats

#Overview

name: r.MeshDrawCommands.LogDynamicInstancingStats

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.MeshDrawCommands.LogDynamicInstancingStats is to control the logging of dynamic instancing statistics in the rendering system of Unreal Engine 5. This setting variable is used to enable or disable the logging of these statistics for the next frame.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically in the scene rendering subsystem. It is referenced in the SceneRendering.cpp file, which is a core part of the rendering pipeline.

The value of this variable is set through the console variable system in Unreal Engine. It is defined as an FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands or configuration files.

The r.MeshDrawCommands.LogDynamicInstancingStats variable interacts directly with the GDumpInstancingStats variable. They share the same value, with GDumpInstancingStats being the actual integer variable used in the code, while r.MeshDrawCommands.LogDynamicInstancingStats is the console variable name used to set its value.

Developers should be aware that this variable is intended for debugging and profiling purposes. It’s not meant to be used in production builds, as logging these statistics can have a performance impact. The variable is also marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it affects scalability and is safe to modify from the render thread.

Best practices when using this variable include:

  1. Only enable it when necessary for debugging or profiling.
  2. Remember to disable it after use, as it resets to 0 after each frame.
  3. Use it in conjunction with other profiling tools to get a comprehensive view of rendering performance.

Regarding the associated variable GDumpInstancingStats:

The purpose of GDumpInstancingStats is to serve as the actual integer variable that stores the state of whether to log dynamic instancing stats. It is directly linked to the r.MeshDrawCommands.LogDynamicInstancingStats console variable.

This variable is used in the Renderer module, specifically in the scene rendering system. It’s referenced in the FSceneRenderer constructor, where its value is checked and then reset to 0.

The value of GDumpInstancingStats is set indirectly through the r.MeshDrawCommands.LogDynamicInstancingStats console variable. It’s important to note that after its value is read in the FSceneRenderer constructor, it’s immediately reset to 0, indicating that this logging is intended to be a one-time operation per request.

GDumpInstancingStats interacts with the bDumpMeshDrawCommandInstancingStats member variable of the FSceneRenderer class. The value of GDumpInstancingStats is used to set bDumpMeshDrawCommandInstancingStats in the FSceneRenderer constructor.

Developers should be aware that this variable is transient - its value is only valid for one frame after it’s set. This behavior ensures that the instancing stats are only logged for a single frame, preventing continuous logging that could impact performance.

Best practices for using GDumpInstancingStats include:

  1. Don’t modify it directly; instead, use the r.MeshDrawCommands.LogDynamicInstancingStats console variable.
  2. Be aware of its one-frame lifespan when interpreting logged data.
  3. Use it in controlled environments (e.g., development or testing) rather than in production builds.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

int32 GDumpInstancingStats = 0;
FAutoConsoleVariableRef CVarDumpInstancingStats(
	TEXT("r.MeshDrawCommands.LogDynamicInstancingStats"),
	GDumpInstancingStats,
	TEXT("Whether to log dynamic instancing stats on the next frame"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

int32 GDumpMeshDrawCommandMemoryStats = 0;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

PRAGMA_ENABLE_DEPRECATION_WARNINGS

int32 GDumpInstancingStats = 0;
FAutoConsoleVariableRef CVarDumpInstancingStats(
	TEXT("r.MeshDrawCommands.LogDynamicInstancingStats"),
	GDumpInstancingStats,
	TEXT("Whether to log dynamic instancing stats on the next frame"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

int32 GDumpMeshDrawCommandMemoryStats = 0;
FAutoConsoleVariableRef CVarDumpMeshDrawCommandMemoryStats(

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

Scope (from outer to inner):

file
function     FSceneRenderer::FSceneRenderer

Source code excerpt:

	ShaderPlatform = Scene->GetShaderPlatform();

	bDumpMeshDrawCommandInstancingStats = !!GDumpInstancingStats;
	GDumpInstancingStats = 0;

	// Initialize scene renderer extensions here, after the rest of the renderer has been initialized
	InitSceneExtensionsRenderers();
}

// static