r.ShaderPipelineCache.ClearOSCache
r.ShaderPipelineCache.ClearOSCache
#Overview
name: r.ShaderPipelineCache.ClearOSCache
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
1 Enables the OS level clear after install, 0 disables it.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPipelineCache.ClearOSCache is to control whether the OS-level shader pipeline cache is cleared after installation. This setting is part of Unreal Engine’s rendering system, specifically the shader pipeline caching mechanism.
This variable is primarily used in the RHI (Rendering Hardware Interface) module of Unreal Engine. The RHI module is responsible for abstracting the low-level graphics API calls, making it easier for the engine to work across different platforms and graphics APIs.
The value of this variable is set through a console variable (CVarClearOSPSOFileCache) in the PipelineFileCache.cpp file. It’s initialized with a default value of 0, which means the OS-level cache clearing is disabled by default.
The associated variable CVarClearOSPSOFileCache interacts directly with this setting. They share the same value and purpose.
Developers must be aware that:
- This setting affects performance, especially during the first run after installation.
- Clearing the OS cache can lead to longer initial load times as shaders need to be recompiled.
- This setting can be overridden via command line with the “skippsoclear” parameter.
Best practices when using this variable include:
- Leave it disabled (0) for most development scenarios to avoid unnecessary shader recompilation.
- Enable it (1) when you want to ensure a clean state, such as after significant shader or pipeline changes.
- Consider the target platform’s behavior with shader caching when deciding to use this setting.
- Be cautious when enabling this in a shipping build, as it might negatively impact the initial user experience.
Regarding the associated variable CVarClearOSPSOFileCache: The purpose of CVarClearOSPSOFileCache is identical to r.ShaderPipelineCache.ClearOSCache. It’s the internal representation of the console variable in the C++ code.
This variable is used directly in the FPipelineFileCacheManager::ClearOSPipelineCache() function to determine whether to clear the OS pipeline cache. It’s checked against the command line parameter “skippsoclear” to allow for runtime overrides.
The best practices and considerations for CVarClearOSPSOFileCache are the same as those for r.ShaderPipelineCache.ClearOSCache, as they represent the same setting in different contexts within the engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineFileCache.cpp:160
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarClearOSPSOFileCache(
TEXT("r.ShaderPipelineCache.ClearOSCache"),
0,
TEXT("1 Enables the OS level clear after install, 0 disables it."),
ECVF_Default | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarAlwaysGeneratePOSSOFileCache(
#Associated Variable and Callsites
This variable is associated with another variable named CVarClearOSPSOFileCache
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineFileCache.cpp:159
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarClearOSPSOFileCache(
TEXT("r.ShaderPipelineCache.ClearOSCache"),
0,
TEXT("1 Enables the OS level clear after install, 0 disables it."),
ECVF_Default | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineFileCache.cpp:3154
Scope (from outer to inner):
file
function void FPipelineFileCacheManager::ClearOSPipelineCache
Source code excerpt:
bool bCmdLineSkip = FParse::Param(FCommandLine::Get(), TEXT("skippsoclear"));
if (CVarClearOSPSOFileCache.GetValueOnAnyThread() > 0 && !bCmdLineSkip)
{
// clear the PSO cache on IOS if the executable is newer
#if PLATFORM_IOS
SCOPED_AUTORELEASE_POOL;
static FString ExecutablePath = FString([[NSBundle mainBundle] bundlePath]) + TEXT("/") + FPlatformProcess::ExecutableName();