r.ShaderCompiler.DebugDumpDetailedShaderSource

r.ShaderCompiler.DebugDumpDetailedShaderSource

#Overview

name: r.ShaderCompiler.DebugDumpDetailedShaderSource

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.DebugDumpDetailedShaderSource is to control the debugging output of shader compilation processes in Unreal Engine 5. It is specifically designed for the shader compilation system to provide detailed information about the shader source code at different stages of compilation.

This setting variable is primarily used by the shader compiler subsystem within Unreal Engine 5. Based on the callsites, it’s evident that this variable is utilized in the ShaderCompiler module, which is part of the Engine’s runtime.

The value of this variable is set through a console variable (CVar) system. It’s defined as a boolean value, defaulting to false, and can be changed at runtime through console commands or configuration files.

The associated variable CVarDebugDumpDetailedShaderSource directly interacts with r.ShaderCompiler.DebugDumpDetailedShaderSource. They share the same value and purpose, with CVarDebugDumpDetailedShaderSource being the actual TAutoConsoleVariable instance used in the code.

Developers must be aware that enabling this variable can significantly impact performance and disk usage. It’s designed for debugging purposes and should be used judiciously. When enabled, it will generate multiple copies of shader source files at different stages of compilation, which can quickly consume disk space for projects with many shaders.

Best practices for using this variable include:

  1. Only enable it when actively debugging shader compilation issues.
  2. Be prepared for increased compilation times and disk usage when enabled.
  3. Remember to disable it after debugging to avoid unnecessary performance overhead and file generation.
  4. Use it in conjunction with other shader debugging tools and logs for a comprehensive view of the compilation process.

Regarding the associated variable CVarDebugDumpDetailedShaderSource:

#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:184

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarDebugDumpDetailedShaderSource(
	TEXT("r.ShaderCompiler.DebugDumpDetailedShaderSource"),
	false,
	TEXT("If true, and if the preprocessed job cache is enabled, this will dump multiple copies of the shader source for any job which has debug output enabled:\n")
	TEXT("\t1. The unmodified output of the preprocessing step as constructed by the PreprocessShader implementation of the IShaderFormat (Preprocessed_<shader>.usf\n")
	TEXT("\t2. The stripped version of the above (with comments, line directives, and whitespace-only lines removed), which is the version hashed for inclusion in the job input hash when the preprocessed job cache is enabled (Stripped_<shader>.usf)")
	TEXT("\t3. The final source as passed to the platform compiler (this will differ if the IShaderFormat compile function applies further modifications to the source after preprocessing; otherwise this will be the same as 2 above (<shader>.usf)\n")
	TEXT("If false, or the preprocessed job cache is disabled, this will simply dump whatever source is passed to the compiler (equivalent to either 1 or 3 depending on if the IShaderFormat implementation modifies the source in the compile step."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

static TAutoConsoleVariable<bool> CVarDebugDumpDetailedShaderSource(
	TEXT("r.ShaderCompiler.DebugDumpDetailedShaderSource"),
	false,
	TEXT("If true, and if the preprocessed job cache is enabled, this will dump multiple copies of the shader source for any job which has debug output enabled:\n")
	TEXT("\t1. The unmodified output of the preprocessing step as constructed by the PreprocessShader implementation of the IShaderFormat (Preprocessed_<shader>.usf\n")
	TEXT("\t2. The stripped version of the above (with comments, line directives, and whitespace-only lines removed), which is the version hashed for inclusion in the job input hash when the preprocessed job cache is enabled (Stripped_<shader>.usf)")
	TEXT("\t3. The final source as passed to the platform compiler (this will differ if the IShaderFormat compile function applies further modifications to the source after preprocessing; otherwise this will be the same as 2 above (<shader>.usf)\n")

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

Scope (from outer to inner):

file
function     EShaderDebugInfoFlags FShaderCompilingManager::GetDumpShaderDebugInfoFlags

Source code excerpt:

	}

	if (CVarDebugDumpDetailedShaderSource.GetValueOnAnyThread())
	{
		Flags |= EShaderDebugInfoFlags::DetailedSource;
	}

	return Flags;
}