r.ShaderCompiler.PrintIndividualProcessStats

r.ShaderCompiler.PrintIndividualProcessStats

#Overview

name: r.ShaderCompiler.PrintIndividualProcessStats

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 r.ShaderCompiler.PrintIndividualProcessStats is to control the printing of shader compilation statistics for individual processes during a multiprocess cook in Unreal Engine 5. This setting is specifically related to the shader compilation and cooking system.

This setting variable is primarily used in the UnrealEd module, specifically within the shader statistics collection and reporting system. It’s defined and used in the ShaderStatsCollector.cpp file, which is part of the Editor subsystem.

The value of this variable is set through a console variable (CVar) system. It’s initialized as a boolean value with a default of false, meaning individual process stats are not printed by default.

This variable interacts closely with its associated variable CVarShaderCompilerPrintIndividualProcessStats. They share the same value and are used interchangeably in the code.

Developers must be aware that enabling this variable will result in additional output during multiprocess cooking operations. This can be useful for debugging and performance analysis but may increase the verbosity of the output.

Best practices when using this variable include:

  1. Enable it only when detailed shader compilation statistics are needed for each process.
  2. Use it in conjunction with other shader compilation and cooking-related settings for comprehensive analysis.
  3. Be prepared to handle and analyze the additional output when this setting is enabled.

Regarding the associated variable CVarShaderCompilerPrintIndividualProcessStats:

This is the actual console variable that controls the behavior. It’s defined using the TAutoConsoleVariable template, which allows it to be changed at runtime through console commands.

The purpose of CVarShaderCompilerPrintIndividualProcessStats is identical to r.ShaderCompiler.PrintIndividualProcessStats. It’s used in the FShaderStatsReporter class to determine whether to print individual process stats and whether the reporter is tickable.

Developers should be aware that this variable can be accessed using the GetValueOnAnyThread() method, which suggests it’s designed to be thread-safe for retrieval.

When working with this variable, developers should:

  1. Use the GetValueOnAnyThread() method to safely retrieve its value in multithreaded contexts.
  2. Consider the performance implications of frequently checking this value in performance-critical code paths.
  3. Be aware that changes to this variable will affect the behavior of the shader statistics reporting system in real-time.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/ShaderStatsCollector.cpp:13

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarShaderCompilerPrintIndividualProcessStats(
	TEXT("r.ShaderCompiler.PrintIndividualProcessStats"),
	false,
	TEXT("If true, in a multiprocess cook, stats will be printed for each individual process (as well as aggregated across all)."),
	ECVF_Default
);

class FShaderStatsReporter : public FTickableEditorObject, FTickableCookObject

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/ShaderStatsCollector.cpp:12

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarShaderCompilerPrintIndividualProcessStats(
	TEXT("r.ShaderCompiler.PrintIndividualProcessStats"),
	false,
	TEXT("If true, in a multiprocess cook, stats will be printed for each individual process (as well as aggregated across all)."),
	ECVF_Default
);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/ShaderStatsCollector.cpp:102

Scope (from outer to inner):

file
function     bool FShaderStatsReporter::IsTickable

Source code excerpt:

	// a multiprocess cook, running a single process cook/editor, or if the "print individual process stats" cvar is enabled.
	// the Aggregator will have Mode==Director the first case, and be unset in the second.
	return !Aggregator || (Aggregator->Mode == FShaderStatsAggregator::EMode::Director) || CVarShaderCompilerPrintIndividualProcessStats.GetValueOnAnyThread();
}

TStatId FShaderStatsReporter::GetStatId() const
{
	RETURN_QUICK_DECLARE_CYCLE_STAT(FShaderStatsReporter, STATGROUP_Tickables);
}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/ShaderStatsCollector.cpp:116

Scope (from outer to inner):

file
function     void FShaderStatsReporter::LogStats

Source code excerpt:

	GShaderCompilingManager->GetLocalStats(LocalStats);

	if (Aggregator && Aggregator->Mode == FShaderStatsAggregator::EMode::Director && CVarShaderCompilerPrintIndividualProcessStats.GetValueOnAnyThread())
	{
		// if we're the director in a MP cook, and the "individual process stats" are requested, print them before aggregating and printing the aggregated results
		LocalStats.WriteStatSummary();
	}
	
	AggregateStats(LocalStats);