r.ShaderPipelineCache.PreCompileMask
r.ShaderPipelineCache.PreCompileMask
#Overview
name: r.ShaderPipelineCache.PreCompileMask
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Mask used to precompile the cache. Defaults to all PSOs (-1)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPipelineCache.PreCompileMask is to control which Pipeline State Objects (PSOs) are precompiled in the shader pipeline cache. This setting variable is primarily used in the rendering system of Unreal Engine 5, specifically for shader compilation and optimization.
This setting variable is relied upon by the RenderCore module, which is a core part of Unreal Engine’s rendering system. It’s used within the ShaderPipelineCache functionality, which manages the compilation and caching of shader pipelines.
The value of this variable is set through a console variable (CVarPSOFileCachePreCompileMask) in the C++ code. It defaults to -1, which means all PSOs are precompiled by default.
The associated variable CVarPSOFileCachePreCompileMask interacts directly with r.ShaderPipelineCache.PreCompileMask. They share the same value and purpose.
Developers must be aware that this variable can significantly impact shader compilation times and performance. Setting it to -1 (default) will precompile all PSOs, which can be time-consuming but may lead to better runtime performance. Setting it to a specific mask value will only precompile certain PSOs, which can speed up initial compilation but may lead to runtime shader compilation.
Best practices when using this variable include:
- Leave it at the default value (-1) for final builds to ensure all PSOs are precompiled.
- During development, you might want to set a specific mask to speed up compilation times, focusing only on the PSOs you’re currently working with.
- Be aware of the trade-off between compilation time and runtime performance when adjusting this value.
- Monitor the impact of changes to this variable on both compilation times and runtime performance.
Regarding the associated variable CVarPSOFileCachePreCompileMask:
The purpose of CVarPSOFileCachePreCompileMask is the same as r.ShaderPipelineCache.PreCompileMask. It’s the actual console variable that controls the precompilation mask for the shader pipeline cache.
This variable is used in the RenderCore module, specifically within the FShaderPipelineCache class.
The value of this variable is set when it’s declared, with a default of -1. It can be changed at runtime through the console or configuration files.
CVarPSOFileCachePreCompileMask directly interacts with the FPipelineFileCacheManager, setting the game usage mask for PSO precompilation.
Developers should be aware that this is a render thread safe variable, meaning it can be safely accessed from the render thread.
Best practices for using CVarPSOFileCachePreCompileMask are the same as those for r.ShaderPipelineCache.PreCompileMask, as they represent the same setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:108
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarPSOFileCachePreCompileMask(
TEXT("r.ShaderPipelineCache.PreCompileMask"),
-1,
TEXT("Mask used to precompile the cache. Defaults to all PSOs (-1)"),
ECVF_Default | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarPSOFileCacheAutoSaveTimeBoundPSO(
#Associated Variable and Callsites
This variable is associated with another variable named CVarPSOFileCachePreCompileMask
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:107
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarPSOFileCachePreCompileMask(
TEXT("r.ShaderPipelineCache.PreCompileMask"),
-1,
TEXT("Mask used to precompile the cache. Defaults to all PSOs (-1)"),
ECVF_Default | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:1598
Scope (from outer to inner):
file
function FShaderPipelineCache::FShaderPipelineCache
Source code excerpt:
}
uint64 PreCompileMask = (uint64)CVarPSOFileCachePreCompileMask.GetValueOnAnyThread();
FPipelineFileCacheManager::SetGameUsageMaskWithComparison(PreCompileMask, PreCompileMaskComparison);
FCoreDelegates::ApplicationWillDeactivateDelegate.AddStatic(&PipelineStateCacheOnAppDeactivate);
}
bool FShaderPipelineCache::ReadyForAutoSave() const