r.ShaderCompiler.JobCacheDDC

r.ShaderCompiler.JobCacheDDC

#Overview

name: r.ShaderCompiler.JobCacheDDC

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.JobCacheDDC is to control the behavior of shader compilation in Unreal Engine 5, specifically to optimize the compilation process by skipping compilation of all shaders during Material and Material Instance PostLoad and relying on on-demand shader compilation for what is needed.

This setting variable is primarily used by the shader compilation system within Unreal Engine’s rendering module. Based on the callsites, it’s evident that this variable is utilized in the ShaderCompiler.cpp file, which is part of the Engine’s runtime.

The value of this variable is set as a console variable using TAutoConsoleVariable, with a default value of true. It’s defined as read-only (ECVF_ReadOnly), meaning it can’t be changed at runtime.

The associated variable CVarJobCacheDDC interacts directly with r.ShaderCompiler.JobCacheDDC, as they share the same value and purpose. This variable is used in the IsShaderJobCacheDDCEnabled() function to determine if the shader job cache DDC (Derived Data Cache) is enabled.

Developers must be aware that enabling this variable can significantly impact shader compilation behavior. It shifts the compilation strategy from compiling all shaders upfront to an on-demand approach. This can potentially improve load times and reduce initial memory usage, but may lead to brief pauses during gameplay when new shaders need to be compiled.

Best practices when using this variable include:

  1. Ensuring that the on-demand compilation doesn’t negatively impact performance during critical gameplay moments.
  2. Thoroughly testing the game with this setting enabled to catch any potential issues with shader availability.
  3. Considering the trade-offs between upfront compilation time and potential runtime compilation delays.
  4. Using this in conjunction with other shader optimization techniques for best results.

Regarding the associated variable CVarJobCacheDDC:

The purpose of CVarJobCacheDDC is identical to r.ShaderCompiler.JobCacheDDC, as they are essentially the same variable. It’s used to control the shader job caching behavior in the Derived Data Cache.

This variable is used within the shader compilation system of Unreal Engine’s rendering module, specifically in the ShaderCompiler.cpp file.

The value is set using TAutoConsoleVariable, with a default value of true and marked as read-only.

CVarJobCacheDDC interacts directly with the GShaderCompilerJobCache global variable in the IsShaderJobCacheDDCEnabled() function. Both must be true for the shader job cache DDC to be enabled.

Developers should be aware that this variable directly affects the shader compilation strategy and can impact both load times and runtime performance.

Best practices for using CVarJobCacheDDC align with those of r.ShaderCompiler.JobCacheDDC, focusing on performance testing, balancing compile-time and runtime trade-offs, and integrating with overall shader optimization strategies.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarJobCacheDDC(
	TEXT("r.ShaderCompiler.JobCacheDDC"),
	true,
	TEXT("Skips compilation of all shaders on Material and Material Instance PostLoad and relies on on-demand shader compilation to compile what is needed."),
	ECVF_ReadOnly);

static TAutoConsoleVariable<bool> CVarJobCacheDDCPolicy(
	TEXT("r.ShaderCompiler.JobCacheDDCEnableRemotePolicy"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarJobCacheDDC(
	TEXT("r.ShaderCompiler.JobCacheDDC"),
	true,
	TEXT("Skips compilation of all shaders on Material and Material Instance PostLoad and relies on on-demand shader compilation to compile what is needed."),
	ECVF_ReadOnly);

static TAutoConsoleVariable<bool> CVarJobCacheDDCPolicy(

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

Scope (from outer to inner):

file
function     bool IsShaderJobCacheDDCEnabled

Source code excerpt:

	{
		// job cache itself must be enabled first
		return GShaderCompilerJobCache && CVarJobCacheDDC.GetValueOnAnyThread();
	}

	return false;
}

bool IsMaterialMapDDCEnabled()