r.OverrideShaderDebugDir

r.OverrideShaderDebugDir

#Overview

name: r.OverrideShaderDebugDir

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.OverrideShaderDebugDir is to override the output location of shader debug files in Unreal Engine 5.

This setting variable is primarily used by the shader compilation system within Unreal Engine. It allows developers to specify a custom directory for shader debug information, which can be useful for debugging and profiling shaders.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable in the ShaderCompiler.cpp file, which means it can be set via console commands or configuration files.

The associated variable CVarShaderOverrideDebugDir interacts directly with r.OverrideShaderDebugDir. They share the same value and purpose.

Developers should be aware that:

  1. This variable is marked as ECVF_ReadOnly, meaning it should not be changed during runtime.
  2. If left empty, the engine will use the default location (Saved\ShaderDebugInfo).
  3. The variable affects the AbsoluteShaderDebugInfoDirectory path used by the shader compiling manager.

Best practices when using this variable include:

  1. Set it early in the engine initialization process if a custom debug directory is needed.
  2. Ensure the specified directory exists and has appropriate write permissions.
  3. Use absolute paths to avoid any potential issues with relative path resolution.

Regarding the associated variable CVarShaderOverrideDebugDir:

Developers should treat CVarShaderOverrideDebugDir as the implementation detail of r.OverrideShaderDebugDir and generally interact with the latter through engine configuration or console commands.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<FString> CVarShaderOverrideDebugDir(
	TEXT("r.OverrideShaderDebugDir"),
	"",
	TEXT("Override output location of shader debug files\n")
	TEXT("Empty: use default location Saved\\ShaderDebugInfo.\n"),
	ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarShadersValidation(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<FString> CVarShaderOverrideDebugDir(
	TEXT("r.OverrideShaderDebugDir"),
	"",
	TEXT("Override output location of shader debug files\n")
	TEXT("Empty: use default location Saved\\ShaderDebugInfo.\n"),
	ECVF_ReadOnly);

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

Scope (from outer to inner):

file
function     FShaderCompilingManager::FShaderCompilingManager

Source code excerpt:


	FString AbsoluteDebugInfoDirectory = IFileManager::Get().ConvertToAbsolutePathForExternalAppForWrite(*(BaseDebugInfoPath / TEXT("ShaderDebugInfo")));
	const FString OverrideShaderDebugDir = CVarShaderOverrideDebugDir.GetValueOnAnyThread();
	if (!OverrideShaderDebugDir.IsEmpty())
	{
		AbsoluteDebugInfoDirectory = OverrideShaderDebugDir;
	}
	FPaths::NormalizeDirectoryName(AbsoluteDebugInfoDirectory);
	AbsoluteShaderDebugInfoDirectory = AbsoluteDebugInfoDirectory;