r.ShaderPipelineCache.GlobalShadersOnlyWhenPSOPrecaching
r.ShaderPipelineCache.GlobalShadersOnlyWhenPSOPrecaching
#Overview
name: r.ShaderPipelineCache.GlobalShadersOnlyWhenPSOPrecaching
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Only compile PSOs from the GlobalShader cache when runtime PSOPrecaching is enabled (default disabled)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPipelineCache.GlobalShadersOnlyWhenPSOPrecaching is to control the compilation of Pipeline State Objects (PSOs) from the GlobalShader cache. It is primarily used in the rendering system, specifically for shader pipeline caching and optimization.
This setting variable is utilized by the RenderCore module of Unreal Engine 5, particularly within the ShaderPipelineCache system. It directly affects the behavior of shader compilation and PSO caching.
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 0 (disabled) and can be changed at runtime.
This variable interacts closely with its associated variable CVarPSOGlobalShadersOnlyWhenPSOPrecaching. They share the same value and purpose, with CVarPSOGlobalShadersOnlyWhenPSOPrecaching being the actual CVar used in the code.
Developers must be aware that enabling this variable (setting it to a value greater than 0) will restrict PSO compilation from the GlobalShader cache to only occur when runtime PSO precaching is enabled. This can potentially impact shader compilation performance and behavior.
Best practices when using this variable include:
- Only enable it if you specifically need to limit GlobalShader PSO compilation to PSO precaching scenarios.
- Monitor performance impacts when enabling this feature, especially during development and testing phases.
- Consider the implications on shader compilation times and overall rendering performance.
Regarding the associated variable CVarPSOGlobalShadersOnlyWhenPSOPrecaching:
Its purpose is identical to r.ShaderPipelineCache.GlobalShadersOnlyWhenPSOPrecaching, serving as the actual console variable implementation.
It is used within the RenderCore module, specifically in the ShaderPipelineCache system.
The value is set through the CVar system and can be accessed using GetValueOnAnyThread() method.
It interacts directly with the PSOPrecaching system, influencing the behavior of shader code compilation based on its value.
Developers should be aware that this variable is checked during the shader precompilation process, potentially affecting which shaders are compiled and when.
Best practices include:
- Use GetValueOnAnyThread() to safely access its value from any thread.
- Consider the performance implications when modifying this value, especially in production environments.
- Coordinate any changes to this variable with overall PSO caching and shader compilation strategies.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:157
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarPSOGlobalShadersOnlyWhenPSOPrecaching(
TEXT("r.ShaderPipelineCache.GlobalShadersOnlyWhenPSOPrecaching"),
(int32)0,
TEXT("Only compile PSOs from the GlobalShader cache when runtime PSOPrecaching is enabled (default disabled)"),
ECVF_Default | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarPSOFileCacheOnlyOpenUserCache(
#Associated Variable and Callsites
This variable is associated with another variable named CVarPSOGlobalShadersOnlyWhenPSOPrecaching
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:156
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarPSOGlobalShadersOnlyWhenPSOPrecaching(
TEXT("r.ShaderPipelineCache.GlobalShadersOnlyWhenPSOPrecaching"),
(int32)0,
TEXT("Only compile PSOs from the GlobalShader cache when runtime PSOPrecaching is enabled (default disabled)"),
ECVF_Default | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:2080
Scope (from outer to inner):
file
function void FShaderPipelineCacheTask::BeginPrecompilingPipelineCache
lambda-function
Source code excerpt:
for (FSHAHash const& Hash : Task.Shaders)
{
if (PipelineStateCache::IsPSOPrecachingEnabled() && CVarPSOGlobalShadersOnlyWhenPSOPrecaching.GetValueOnAnyThread() > 0)
{
bHasShaders &= FShaderCodeLibrary::ContainsShaderCode(Hash, LibraryName);
}
else
{
bHasShaders &= FShaderCodeLibrary::ContainsShaderCode(Hash);