r.OverrideShaderDebugDir
r.OverrideShaderDebugDir
#Overview
name: r.OverrideShaderDebugDir
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Override output location of shader debug files\nEmpty: use default location Saved\\ShaderDebugInfo.\n
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
The associated variable CVarShaderOverrideDebugDir interacts directly with r.OverrideShaderDebugDir. They share the same value and purpose.
Developers should be aware that:
- This variable is marked as ECVF_ReadOnly, meaning it should not be changed during runtime.
- If left empty, the engine will use the default location (Saved\ShaderDebugInfo).
- The variable affects the AbsoluteShaderDebugInfoDirectory path used by the shader compiling manager.
Best practices when using this variable include:
- Set it early in the engine initialization process if a custom debug directory is needed.
- Ensure the specified directory exists and has appropriate write permissions.
- Use absolute paths to avoid any potential issues with relative path resolution.
Regarding the associated variable CVarShaderOverrideDebugDir:
- It’s the actual console variable that stores the r.OverrideShaderDebugDir value.
- It’s used in the FShaderCompilingManager constructor to determine the final AbsoluteShaderDebugInfoDirectory.
- If set, it overrides the default shader debug info directory.
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;