r.PSOPrecaching
r.PSOPrecaching
#Overview
name: r.PSOPrecaching
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0 to Disable PSOs precaching\n1 to Enable PSO precaching\n
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PSOPrecaching is to control the precaching of Pipeline State Objects (PSOs) in Unreal Engine’s rendering system. It is primarily used to enable or disable PSO precaching across various graphics APIs supported by Unreal Engine.
This setting variable is relied upon by multiple Unreal Engine subsystems and modules, including:
- The core RHI (Rendering Hardware Interface) module
- D3D12RHI (DirectX 12 Rendering Hardware Interface)
- OpenGLDrv (OpenGL Driver)
- VulkanRHI (Vulkan Rendering Hardware Interface)
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1 (enabled) in the RHI module, but can be changed at runtime or through configuration files.
This variable interacts with several other variables and systems:
- In the OpenGL driver, it interacts with CVarAllowPSOPrecaching and CVarEnablePSOFileCacheWhenPrecachingActive.
- In the Vulkan implementation, it works alongside CVarChunkedPSOCache, CVarNumRemoteProgramCompileServices, and CVarVulkanPSOPrecaching.
Developers should be aware that:
- This variable affects performance and startup times. Enabling precaching can improve runtime performance but may increase initial load times.
- Its behavior may vary slightly between different graphics APIs.
- It may have different implications on different platforms (e.g., mobile vs. desktop).
Best practices when using this variable include:
- Generally, leave it enabled (default value of 1) for better runtime performance.
- If experiencing long load times, consider disabling it temporarily for development builds.
- Test thoroughly with both enabled and disabled states to ensure your game performs well in both scenarios.
- Be aware of how it interacts with other graphics settings, especially when working with multiple graphics APIs.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/Windows/WindowsEngine.ini:4, section: [ConsoleVariables]
- INI Section:
ConsoleVariables
- Raw value:
1
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineStateCache.cpp:167
Scope: file
Source code excerpt:
int32 GPSOPrecaching = 1;
static FAutoConsoleVariableRef CVarPSOPrecaching(
TEXT("r.PSOPrecaching"),
GPSOPrecaching,
TEXT("0 to Disable PSOs precaching\n")
TEXT("1 to Enable PSO precaching\n"),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Pipelinestate.cpp:300
Scope (from outer to inner):
file
function bool FD3D12PipelineState::UsePSORefCounting
Source code excerpt:
return false;
#else
static const auto CVarPSOPrecaching = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PSOPrecaching"));
return CVarPSOPrecaching && (CVarPSOPrecaching->GetInt() != 0);
#endif
}
ID3D12PipelineState* FD3D12PipelineState::InternalGetPipelineState()
{
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLDevice.cpp:1286
Scope (from outer to inner):
file
function static void InitRHICapabilitiesForGL
Source code excerpt:
GRHINeedsUnatlasedCSMDepthsWorkaround = true;
static const auto CVarPSOPrecaching = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PSOPrecaching"));
if (CVarPSOPrecaching && CVarPSOPrecaching->GetInt() != 0 && CVarAllowPSOPrecaching.GetValueOnAnyThread())
{
GRHISupportsPSOPrecaching = true;
}
GRHISupportsPipelineFileCache = !GRHISupportsPSOPrecaching || CVarEnablePSOFileCacheWhenPrecachingActive.GetValueOnAnyThread();
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLShaders.cpp:285
Scope (from outer to inner):
file
function bool IsPrecachingEnabled
Source code excerpt:
bool IsPrecachingEnabled()
{
static const auto CVarPSOPrecaching = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PSOPrecaching"));
return CVarPSOPrecaching && (CVarPSOPrecaching->GetInt() != 0);
}
static bool ShouldCacheAllProgramBinaries()
{
return IsPrecachingEnabled() && GCacheAllProgramBinaries;
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/Android/VulkanAndroidPlatform.cpp:1638
Scope (from outer to inner):
file
function void FVulkanAndroidPlatform::PostInitGPU
Source code excerpt:
static const auto CVarChunkedPSOCache = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Vulkan.UseChunkedPSOCache"));
static const auto CVarNumRemoteProgramCompileServices = IConsoleManager::Get().FindConsoleVariable(TEXT("Android.Vulkan.NumRemoteProgramCompileServices"));
static const auto CVarPSOPrecaching = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PSOPrecaching"));
static const auto CVarVulkanPSOPrecaching = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Vulkan.AllowPSOPrecaching"));
if (CVarNumRemoteProgramCompileServices->GetInt() && CVarChunkedPSOCache->GetInt() && CVarPSOPrecaching->GetInt() && CVarVulkanPSOPrecaching->GetInt())
{
FVulkanAndroidPlatform::StartAndWaitForRemoteCompileServices(CVarNumRemoteProgramCompileServices->GetInt());
}
}
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:515
Scope (from outer to inner):
file
function FVulkanDynamicRHI::FVulkanDynamicRHI
Source code excerpt:
GRHIGlobals.SupportsBarycentricsSemantic = true;
static const auto CVarPSOPrecaching = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PSOPrecaching"));
GRHISupportsPSOPrecaching = FVulkanChunkedPipelineCacheManager::IsEnabled() && (CVarPSOPrecaching && CVarPSOPrecaching->GetInt() != 0) && CVarAllowVulkanPSOPrecache.GetValueOnAnyThread();
GRHISupportsPipelineFileCache = !GRHISupportsPSOPrecaching || CVarEnableVulkanPSOFileCacheWhenPrecachingActive.GetValueOnAnyThread();
UE_LOG(LogVulkanRHI, Log, TEXT("Vulkan PSO Precaching = %d, PipelineFileCache = %d"), GRHISupportsPSOPrecaching, GRHISupportsPipelineFileCache);
// Copy source requires its own image layout.