r.Vulkan.AllowPSOPrecaching
r.Vulkan.AllowPSOPrecaching
#Overview
name: r.Vulkan.AllowPSOPrecaching
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
true: if r.PSOPrecaching=1 Vulkan RHI will use precaching.\nfalse: Vulkan RHI will disable precaching (even if r.PSOPrecaching=1). (default)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Vulkan.AllowPSOPrecaching is to control whether the Vulkan RHI (Rendering Hardware Interface) will use PSO (Pipeline State Object) precaching when the general PSO precaching is enabled.
This setting variable is primarily used in the Vulkan RHI subsystem of Unreal Engine 5. It interacts with the rendering system, specifically the pipeline state management for Vulkan-based rendering.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a boolean value, defaulting to false, which means PSO precaching is disabled by default for Vulkan even if general PSO precaching is enabled.
This variable interacts closely with other PSO-related variables, particularly:
- r.PSOPrecaching: The general PSO precaching setting.
- Android.Vulkan.NumRemoteProgramCompileServices: Used in Android-specific Vulkan implementations.
- r.ChunkedPSOCache: Related to chunked PSO caching.
Developers must be aware that:
- This setting is render thread safe and read-only once set.
- It only takes effect if r.PSOPrecaching is also enabled.
- When precaching is active, the file cache might not be needed.
Best practices when using this variable include:
- Only enable it if you’re specifically targeting Vulkan and want to optimize pipeline state creation.
- Consider the trade-offs between precaching and file caching, especially on mobile platforms.
- Test performance with and without this setting enabled to determine the best configuration for your specific use case.
Regarding the associated variable CVarAllowVulkanPSOPrecache: This is the actual ConsoleVariable object that represents r.Vulkan.AllowPSOPrecaching in the code. It’s used to query the current value of the setting and to define the variable’s properties (default value, description, flags). The purpose and usage considerations are the same as for r.Vulkan.AllowPSOPrecaching. Developers interacting directly with the engine code might use this variable to programmatically check or modify the PSO precaching behavior for Vulkan.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:101
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarAllowVulkanPSOPrecache(
TEXT("r.Vulkan.AllowPSOPrecaching"),
false,
TEXT("true: if r.PSOPrecaching=1 Vulkan RHI will use precaching.\n")
TEXT("false: Vulkan RHI will disable precaching (even if r.PSOPrecaching=1). (default)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly);
// If precaching is active we should not need the file cache.
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/Android/VulkanAndroidPlatform.cpp:1639
Scope (from outer to inner):
file
function void FVulkanAndroidPlatform::PostInitGPU
Source code excerpt:
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());
}
}
#Associated Variable and Callsites
This variable is associated with another variable named CVarAllowVulkanPSOPrecache
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:100
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<bool> CVarAllowVulkanPSOPrecache(
TEXT("r.Vulkan.AllowPSOPrecaching"),
false,
TEXT("true: if r.PSOPrecaching=1 Vulkan RHI will use precaching.\n")
TEXT("false: Vulkan RHI will disable precaching (even if r.PSOPrecaching=1). (default)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly);
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:517
Scope (from outer to inner):
file
function FVulkanDynamicRHI::FVulkanDynamicRHI
Source code excerpt:
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.
EnumRemoveFlags(GRHIMergeableAccessMask, ERHIAccess::CopySrc);