r.MeshDrawCommands.LogMeshDrawCommandMemoryStats

r.MeshDrawCommands.LogMeshDrawCommandMemoryStats

#Overview

name: r.MeshDrawCommands.LogMeshDrawCommandMemoryStats

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.LogMeshDrawCommandMemoryStats is to control the logging of mesh draw command memory statistics in the Unreal Engine rendering system. This setting variable is used to enable or disable the logging of memory usage related to mesh draw commands for the next frame.

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

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

The associated variable GDumpMeshDrawCommandMemoryStats directly interacts with r.MeshDrawCommands.LogMeshDrawCommandMemoryStats. They share the same value, and GDumpMeshDrawCommandMemoryStats is used in the actual code logic to determine whether to log the memory stats.

Developers must be aware that this variable is intended for debugging and profiling purposes. It should not be enabled in production builds as it may impact performance. The logging occurs on the next frame after the variable is set, so developers should set it right before the frame they want to analyze.

Best practices when using this variable include:

  1. Use it only when necessary for debugging or profiling mesh draw command memory usage.
  2. Remember to disable it after use to avoid performance overhead.
  3. Use in conjunction with other profiling tools to get a comprehensive view of rendering performance.

Regarding the associated variable GDumpMeshDrawCommandMemoryStats:

The purpose of GDumpMeshDrawCommandMemoryStats is to serve as the actual flag that controls the logging of mesh draw command memory statistics in the code.

This variable is used directly in the Renderer module, specifically in the FSceneRenderer::OnRenderFinish function.

The value of GDumpMeshDrawCommandMemoryStats is set through the r.MeshDrawCommands.LogMeshDrawCommandMemoryStats console variable.

When GDumpMeshDrawCommandMemoryStats is set to a non-zero value, it triggers the logging of mesh draw command memory stats on the next frame. After the logging is done, it automatically resets to 0 to prevent continuous logging.

Developers should be aware that this variable is automatically reset after use, so it doesn’t need to be manually disabled.

Best practices for using GDumpMeshDrawCommandMemoryStats include:

  1. Use it in conjunction with profiling tools to analyze the memory usage of mesh draw commands.
  2. Be prepared to capture and analyze the logged data immediately after setting the variable, as it only logs for one frame.
  3. Consider the potential performance impact when using this in development builds, and avoid use in production environments.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

int32 GDumpMeshDrawCommandMemoryStats = 0;
FAutoConsoleVariableRef CVarDumpMeshDrawCommandMemoryStats(
	TEXT("r.MeshDrawCommands.LogMeshDrawCommandMemoryStats"),
	GDumpMeshDrawCommandMemoryStats,
	TEXT("Whether to log mesh draw command memory stats on the next frame"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

static TAutoConsoleVariable<float> CVarDemosaicVposOffset(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	);

int32 GDumpMeshDrawCommandMemoryStats = 0;
FAutoConsoleVariableRef CVarDumpMeshDrawCommandMemoryStats(
	TEXT("r.MeshDrawCommands.LogMeshDrawCommandMemoryStats"),
	GDumpMeshDrawCommandMemoryStats,
	TEXT("Whether to log mesh draw command memory stats on the next frame"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

static TAutoConsoleVariable<float> CVarDemosaicVposOffset(
	TEXT("r.DemosaicVposOffset"),

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

Scope (from outer to inner):

file
function     void FSceneRenderer::OnRenderFinish
lambda-function

Source code excerpt:

		InRHICmdList.EndScene();

		if (GDumpMeshDrawCommandMemoryStats)
		{
			GDumpMeshDrawCommandMemoryStats = 0;
			Scene->DumpMeshDrawCommandMemoryStats();
		}
	});
}

void FSceneRenderer::DrawGPUSkinCacheVisualizationInfoText()