DumpShaderPipelineStats

DumpShaderPipelineStats

#Overview

name: DumpShaderPipelineStats

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of DumpShaderPipelineStats is to provide a diagnostic tool for analyzing shader pipeline statistics in Unreal Engine 5. It allows developers to dump information about shader pipelines for a specific platform or all platforms, which can be useful for performance analysis and optimization.

This setting variable is primarily used by the rendering system within Unreal Engine. Based on the callsites, it is part of the Engine and RenderCore modules.

The value of this variable is not directly set, but rather it’s a function that is called to perform the dumping of shader pipeline stats. It can be triggered through a console command “DumpShaderPipelineStats” as seen in the UnrealEngine.cpp file.

DumpShaderPipelineStats interacts with the EShaderPlatform enum, which is used to specify the platform for which to dump the shader pipeline stats.

Developers should be aware that:

  1. This function is primarily for debugging and performance analysis purposes.
  2. It’s only available when ALLOW_DEBUG_FILES is defined, which is typically in development builds.
  3. The output is written to a temporary file with a name like “ShaderPipelineStats”.

Best practices when using this variable include:

  1. Use it in development environments, not in production builds.
  2. Be cautious about performance impact when using this in large projects with many shaders.
  3. Use it in conjunction with other profiling tools to get a comprehensive view of shader performance.
  4. Remember to analyze the output file after calling the function to gain insights into shader pipeline statistics.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:1148

Scope (from outer to inner):

file
function     static bool HandleDumpShaderPipelineStatsCommand

Source code excerpt:

	Ar.Logf(TEXT("Dumping shader pipeline stats for platform %s"), *LegacyShaderPlatformToShaderFormat(Platform).ToString());

	DumpShaderPipelineStats(Platform);
	return true;
}

namespace
{
	/**

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:5050

Scope: file

Source code excerpt:

		return HandleDumpMaterialStatsCommand( Cmd, Ar );	
	}
	else if (FParse::Command(&Cmd, TEXT("DumpShaderPipelineStats")))
	{
		return HandleDumpShaderPipelineStatsCommand(Cmd, Ar);
	}
	else if (FParse::Command(&Cmd, TEXT("visrt")))
	{
		extern bool HandleVisualizeRT();

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1365

Scope (from outer to inner):

file
function     void DumpShaderPipelineStats

Source code excerpt:

}

void DumpShaderPipelineStats(EShaderPlatform Platform)
{
#if ALLOW_DEBUG_FILES
	FDiagnosticTableViewer ShaderTypeViewer(*FDiagnosticTableViewer::GetUniqueTemporaryFilePath(TEXT("ShaderPipelineStats")));

	int32 TotalNumPipelines = 0;
	int32 TotalSize = 0;

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Public/Shader.h:2482

Scope: file

Source code excerpt:

 * @param Platform  - Platform to dump shader info for, use SP_NumPlatforms for all
 */
extern RENDERCORE_API void DumpShaderPipelineStats(EShaderPlatform Platform);

/**
 * Finds the shader type with a given name.
 * @param ShaderTypeName - The name of the shader type to find.
 * @return The shader type, or NULL if none matched.
 */