r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy
r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy
#Overview
name: r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true, individual shader jobs will be cached to remote/shared DDC instances in all cook commandlet only; if false they will only cache to DDC instances on the local machine.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy is to control the caching behavior of individual shader jobs during the cooking process in Unreal Engine 5. Specifically, it determines whether shader jobs should be cached to remote/shared DDC (Derived Data Cache) instances or only to local DDC instances when running a cook commandlet.
This setting variable is primarily used by the shader compilation system within Unreal Engine. It’s part of the engine’s rendering subsystem, particularly the shader compiler module.
The value of this variable is set through a console variable (CVar) declaration in the ShaderCompiler.cpp file. It’s initialized to false by default, meaning that shader jobs will only be cached to local DDC instances unless explicitly changed.
This variable interacts with another variable named CVarJobCacheDDCCookPolicy. They are used together in the IsShaderJobCacheDDCRemotePolicyEnabled() function to determine the final caching policy.
Developers must be aware that this variable only affects the behavior during cook commandlet operations. It won’t impact regular development or runtime shader compilation.
Best practices when using this variable include:
- Only enable remote caching if you have a reliable and fast connection to your remote/shared DDC.
- Consider the trade-offs between network overhead and potential benefits of shared caching across multiple machines.
- Monitor performance impacts when enabling this option, especially for large projects with many shaders.
Regarding the associated variable CVarJobCacheDDCCookPolicy:
The purpose of CVarJobCacheDDCCookPolicy is to serve as a programmatic handle for the r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy console variable. It allows C++ code to easily access and check the current value of this setting.
This variable is used within the shader compiler subsystem of Unreal Engine, specifically in the IsShaderJobCacheDDCRemotePolicyEnabled() function.
The value of CVarJobCacheDDCCookPolicy is set automatically by the engine when the r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy console variable is set.
CVarJobCacheDDCCookPolicy interacts directly with the IsShaderJobCacheDDCRemotePolicyEnabled() function, which also considers whether the engine is running a cook commandlet.
Developers should be aware that changing CVarJobCacheDDCCookPolicy directly in code won’t have an effect; they should use the console variable instead.
Best practices include using CVarJobCacheDDCCookPolicy.GetValueOnAnyThread() to safely read the current value from any thread, as demonstrated in the IsShaderJobCacheDDCRemotePolicyEnabled() function.
#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:154
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarJobCacheDDCCookPolicy(
TEXT("r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy"),
false,
TEXT("If true, individual shader jobs will be cached to remote/shared DDC instances in all cook commandlet only; if false they will only cache to DDC instances on the local machine.\n"),
ECVF_ReadOnly);
static TAutoConsoleVariable<bool> CVarDebugDumpWorkerInputs(
TEXT("r.ShaderCompiler.DebugDumpWorkerInputs"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarJobCacheDDCCookPolicy
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:153
Scope: file
Source code excerpt:
ECVF_ReadOnly);
static TAutoConsoleVariable<bool> CVarJobCacheDDCCookPolicy(
TEXT("r.ShaderCompiler.JobCacheDDCCookEnableRemotePolicy"),
false,
TEXT("If true, individual shader jobs will be cached to remote/shared DDC instances in all cook commandlet only; if false they will only cache to DDC instances on the local machine.\n"),
ECVF_ReadOnly);
static TAutoConsoleVariable<bool> CVarDebugDumpWorkerInputs(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:235
Scope (from outer to inner):
file
function static bool IsShaderJobCacheDDCRemotePolicyEnabled
Source code excerpt:
static bool IsShaderJobCacheDDCRemotePolicyEnabled()
{
return CVarJobCacheDDCPolicy.GetValueOnAnyThread() || (IsRunningCookCommandlet() && CVarJobCacheDDCCookPolicy.GetValueOnAnyThread());
}
bool IsShaderJobCacheDDCEnabled()
{
#if WITH_EDITOR