r.ShaderPipelineCache.OnlyOpenUserCache
r.ShaderPipelineCache.OnlyOpenUserCache
#Overview
name: r.ShaderPipelineCache.OnlyOpenUserCache
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If > 0, only the user cache file will be opened, and the static file cache will not be opened. Defaults to 0.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPipelineCache.OnlyOpenUserCache is to control the behavior of shader pipeline caching in Unreal Engine 5. Specifically, it determines whether only the user cache file should be opened, or if both the user cache and static file cache should be used.
This setting variable is primarily used in the rendering system, specifically in the shader pipeline caching subsystem. It is part of the RenderCore module, which is a crucial component of Unreal Engine’s rendering infrastructure.
The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of 0, meaning by default, both user and static file caches are used.
This variable interacts closely with the shader pipeline cache system. It’s used in the FShaderPipelineCache class to determine whether to open the static pipeline file cache and how to handle shader library state changes.
Developers must be aware that setting this variable to a value greater than 0 will cause the engine to ignore the static file cache, which could potentially impact shader compilation performance and loading times. This setting is marked as ECVF_ReadOnly, meaning it should be set early in the engine’s initialization and not changed at runtime.
Best practices when using this variable include:
- Only enable it (set to > 0) if you specifically need to isolate user cache behavior.
- Be aware of potential performance implications when disabling the static file cache.
- Set this value early in the engine’s initialization process.
The associated variable CVarPSOFileCacheOnlyOpenUserCache is the actual console variable that stores and provides access to this setting. It’s used in the same way as r.ShaderPipelineCache.OnlyOpenUserCache, but it’s the internal representation of the console variable.
When working with CVarPSOFileCacheOnlyOpenUserCache, developers should:
- Use GetValueOnAnyThread() to safely access its value from any thread.
- Remember that changes to this variable will affect the entire shader pipeline caching system.
- Be cautious about changing its value during runtime, as it’s intended to be a read-only setting.
In summary, both r.ShaderPipelineCache.OnlyOpenUserCache and CVarPSOFileCacheOnlyOpenUserCache are important for controlling shader pipeline caching behavior, particularly in scenarios where isolating user cache behavior is necessary for debugging or performance analysis.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:164
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarPSOFileCacheOnlyOpenUserCache(
TEXT("r.ShaderPipelineCache.OnlyOpenUserCache"),
0,
TEXT("If > 0, only the user cache file will be opened, and the static file cache will not be opened. Defaults to 0."),
ECVF_ReadOnly
);
static bool GetShaderPipelineCacheSaveBoundPSOLog()
#Associated Variable and Callsites
This variable is associated with another variable named CVarPSOFileCacheOnlyOpenUserCache
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:163
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarPSOFileCacheOnlyOpenUserCache(
TEXT("r.ShaderPipelineCache.OnlyOpenUserCache"),
0,
TEXT("If > 0, only the user cache file will be opened, and the static file cache will not be opened. Defaults to 0."),
ECVF_ReadOnly
);
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:842
Scope (from outer to inner):
file
function bool FShaderPipelineCache::OpenPipelineFileCache
Source code excerpt:
bool FShaderPipelineCache::OpenPipelineFileCache(EShaderPlatform Platform)
{
if (CVarPSOFileCacheOnlyOpenUserCache.GetValueOnAnyThread())
{
UE_LOG(LogRHI, Log, TEXT("Ignoring request to open static pipeline file cache because r.ShaderPipelineCache.OnlyOpenUserCache is set."));
return false;
}
bool bFileOpen = false;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:955
Scope (from outer to inner):
file
function void FShaderPipelineCache::ShaderLibraryStateChanged
Source code excerpt:
FScopeLock Lock(&ShaderPipelineCache->Mutex);
if (!CVarPSOFileCacheOnlyOpenUserCache.GetValueOnAnyThread())
{
if (TUniquePtr<class FShaderPipelineCacheTask>* Found = ShaderPipelineCache->ShaderCacheTasks.Find(PSOCacheKey))
{
(*Found)->OnShaderLibraryStateChanged(State, Platform, PSOCacheName, ComponentID);
}
else