r.ShaderCompiler.PerShaderDDCCook
r.ShaderCompiler.PerShaderDDCCook
#Overview
name: r.ShaderCompiler.PerShaderDDCCook
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true, per-shader DDC caching will be enabled during cooks.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderCompiler.PerShaderDDCCook is to enable per-shader DDC (Derived Data Cache) caching during cook processes in Unreal Engine 5. This setting is primarily related to the shader compilation system and the cooking process.
This setting variable is primarily used in the shader compiler subsystem of Unreal Engine. It’s defined in the ShaderCompiler.cpp file, which is part of the Engine module.
The value of this variable is set through a console variable (CVar) system. It’s initialized as false by default, but can be changed at runtime or through configuration files.
The associated variable CVarShaderCompilerPerShaderDDCCook interacts directly with r.ShaderCompiler.PerShaderDDCCook. They share the same value and purpose.
Developers must be aware that this variable is only effective in certain contexts. It’s primarily used in the editor or when running the game, and not typically in commandlets like the cooker, unless forced.
Best practices when using this variable include:
- Only enable it when you need to optimize shader compilation during cooking.
- Be aware that enabling this might increase memory usage and initial cook times, but could speed up subsequent cooks.
- Test the performance impact in your specific project before enabling it for production use.
Regarding the associated variable CVarShaderCompilerPerShaderDDCCook:
The purpose of CVarShaderCompilerPerShaderDDCCook is identical to r.ShaderCompiler.PerShaderDDCCook. It’s an internal representation of the console variable in C++ code.
This variable is used in the IsShaderJobCacheDDCEnabled function to determine if shader job caching should be enabled. It’s part of the shader compilation system in the Engine module.
The value is set when the console variable is initialized and can be accessed using the GetValueOnAnyThread() method.
CVarShaderCompilerPerShaderDDCCook interacts directly with r.ShaderCompiler.PerShaderDDCCook, as they represent the same setting.
Developers should be aware that this variable is used in conditional compilation (#if WITH_EDITOR), indicating it’s primarily relevant in editor builds.
Best practices for using this variable include:
- Use GetValueOnAnyThread() to access its value in a thread-safe manner.
- Remember that changes to r.ShaderCompiler.PerShaderDDCCook will affect this variable.
- Consider the implications on shader compilation and cooking processes when modifying this variable.
#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:215
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarShaderCompilerPerShaderDDCCook(
TEXT("r.ShaderCompiler.PerShaderDDCCook"),
false,
TEXT("If true, per-shader DDC caching will be enabled during cooks."),
ECVF_Default
);
static TAutoConsoleVariable<bool> CVarAreShaderErrorsFatal(
#Associated Variable and Callsites
This variable is associated with another variable named CVarShaderCompilerPerShaderDDCCook
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:214
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<bool> CVarShaderCompilerPerShaderDDCCook(
TEXT("r.ShaderCompiler.PerShaderDDCCook"),
false,
TEXT("If true, per-shader DDC caching will be enabled during cooks."),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:243
Scope (from outer to inner):
file
function bool IsShaderJobCacheDDCEnabled
Source code excerpt:
#if WITH_EDITOR
static const bool bForceAllowShaderCompilerJobCache = FParse::Param(FCommandLine::Get(), TEXT("forceAllowShaderCompilerJobCache")) ||
CVarShaderCompilerPerShaderDDCCook.GetValueOnAnyThread();
#else
const bool bForceAllowShaderCompilerJobCache = false;
#endif
// For now we only support the editor and not commandlets like the cooker.
if ((GIsEditor || IsRunningGame()) && (!IsRunningCommandlet() || bForceAllowShaderCompilerJobCache))