r.ShaderCompiler.DebugDumpWorkerInputs

r.ShaderCompiler.DebugDumpWorkerInputs

#Overview

name: r.ShaderCompiler.DebugDumpWorkerInputs

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.ShaderCompiler.DebugDumpWorkerInputs is to enable debugging functionality for the shader compiler system in Unreal Engine 5. It allows developers to save worker input files for individual compile jobs alongside other debug data.

This setting variable is primarily used by the shader compilation subsystem within the Unreal Engine’s rendering module. Based on the callsites, it’s implemented in the ShaderCompiler.cpp file, which is part of the Engine’s runtime.

The value of this variable is set through a console variable (CVar) system. It’s initialized as a static TAutoConsoleVariable with a default value of false. This means it can be changed at runtime through console commands or configuration files.

The associated variable CVarDebugDumpWorkerInputs directly interacts with r.ShaderCompiler.DebugDumpWorkerInputs. They share the same value and purpose.

Developers must be aware that this variable is marked as ECVF_ReadOnly, which means its value should not be changed during runtime. Additionally, for this variable to function, another debug setting (r.DumpShaderDebugInfo) must also be enabled.

Best practices when using this variable include:

  1. Only enable it when necessary for debugging shader compilation issues.
  2. Ensure r.DumpShaderDebugInfo is also enabled for full functionality.
  3. Be prepared for increased disk usage and potentially slower shader compilation times when enabled.
  4. Use it in conjunction with other shader debugging tools for comprehensive analysis.

Regarding the associated variable CVarDebugDumpWorkerInputs:

The purpose of CVarDebugDumpWorkerInputs is identical to r.ShaderCompiler.DebugDumpWorkerInputs. It’s the actual C++ variable that controls the behavior specified by the console variable.

This variable is used directly in the shader compiler code. As seen in the DumpWorkerInputs function, it’s checked to determine whether to dump the worker inputs for each shader compile job.

The value of CVarDebugDumpWorkerInputs is set and accessed through the TAutoConsoleVariable system, which allows it to be controlled via console commands or configuration files.

CVarDebugDumpWorkerInputs interacts directly with the shader compilation process. When enabled, it triggers the dumping of worker input files for each compile job.

Developers should be aware that accessing this variable should be done using the GetValueOnAnyThread() method, as shown in the code example. This ensures thread-safe access to the variable’s value.

Best practices for using CVarDebugDumpWorkerInputs include:

  1. Use it for debugging purposes only, as it can impact performance and disk usage.
  2. Always check its value before performing debug dumps to avoid unnecessary work.
  3. Consider the potential performance impact when enabling this in production or on lower-end hardware.
  4. Use it in conjunction with other shader debugging tools and variables for a complete debugging picture.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:160

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarDebugDumpWorkerInputs(
	TEXT("r.ShaderCompiler.DebugDumpWorkerInputs"),
	false,
	TEXT("If true, worker input files will be saved for each individual compile job alongside other debug data (note that r.DumpShaderDebugInfo must also be enabled for this to function)"),
	ECVF_ReadOnly);

static TAutoConsoleVariable<bool> CVarDebugDumpJobInputHashes(
	TEXT("r.ShaderCompiler.DebugDumpJobInputHashes"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:159

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

static TAutoConsoleVariable<bool> CVarDebugDumpWorkerInputs(
	TEXT("r.ShaderCompiler.DebugDumpWorkerInputs"),
	false,
	TEXT("If true, worker input files will be saved for each individual compile job alongside other debug data (note that r.DumpShaderDebugInfo must also be enabled for this to function)"),
	ECVF_ReadOnly);

static TAutoConsoleVariable<bool> CVarDebugDumpJobInputHashes(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:2792

Scope (from outer to inner):

file
function     static void DumpWorkerInputs

Source code excerpt:

static void DumpWorkerInputs(TConstArrayView<FShaderCommonCompileJobPtr> QueuedJobs)
{
	if (CVarDebugDumpWorkerInputs.GetValueOnAnyThread())
	{
		for (const FShaderCommonCompileJobPtr& CommonJob : QueuedJobs)
		{
			FShaderPipelineCompileJob* PipelineJob = CommonJob->GetShaderPipelineJob();
			FString DebugWorkerInputFilePath;
			if (PipelineJob)