r.Vulkan.EnablePSOFileCacheWhenPrecachingActive
r.Vulkan.EnablePSOFileCacheWhenPrecachingActive
#Overview
name: r.Vulkan.EnablePSOFileCacheWhenPrecachingActive
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
false: If precaching is available (r.PSOPrecaching=1, r.Vulkan.UseChunkedPSOCache=1) then disable the PSO filecache. (default)\ntrue: Allow both PSO file cache and precaching.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Vulkan.EnablePSOFileCacheWhenPrecachingActive is to control whether the Pipeline State Object (PSO) file cache should be enabled when PSO precaching is active in the Vulkan rendering system.
This setting variable is primarily used by the Vulkan RHI (Rendering Hardware Interface) subsystem of Unreal Engine. It’s specifically related to the management of Pipeline State Objects, which are crucial for performance optimization in Vulkan rendering.
The value of this variable is set through a console variable (CVar) declaration in the VulkanRHI.cpp file. It’s initialized to false by default, meaning that if PSO precaching is available, the PSO file cache will be disabled.
This variable interacts closely with other PSO-related variables, particularly those controlling PSO precaching (r.PSOPrecaching and r.Vulkan.UseChunkedPSOCache). It’s used to determine whether GRHISupportsPipelineFileCache should be enabled or not.
Developers must be aware that this variable affects the caching strategy for Pipeline State Objects. When set to false (default), it prioritizes PSO precaching over file caching. When set to true, it allows both precaching and file caching to coexist.
Best practices when using this variable include:
- Carefully considering the performance implications of enabling both precaching and file caching.
- Testing the performance impact in your specific use case before changing the default value.
- Ensuring that your PSO precaching setup is correctly configured before modifying this setting.
Regarding the associated variable CVarEnableVulkanPSOFileCacheWhenPrecachingActive:
This is the actual console variable object that controls the r.Vulkan.EnablePSOFileCacheWhenPrecachingActive setting. It’s defined as a TAutoConsoleVariable
The purpose of this variable is the same as r.Vulkan.EnablePSOFileCacheWhenPrecachingActive - it determines whether the PSO file cache should be enabled when precaching is active.
This variable is used directly in the FVulkanDynamicRHI constructor to set the value of GRHISupportsPipelineFileCache. This global variable likely controls whether the engine will attempt to use a pipeline file cache throughout its operation.
Developers should be aware that this variable is marked as ECVF_RenderThreadSafe and ECVF_ReadOnly, meaning it’s safe to read from the render thread, but it cannot be changed after engine initialization.
Best practices for using this variable include:
- Accessing its value using the GetValueOnAnyThread() method when needed.
- Not attempting to modify its value after engine initialization, as it’s marked as read-only.
- Considering its impact on the entire Vulkan rendering pipeline when deciding whether to enable it or not.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:110
Scope: file
Source code excerpt:
// however, precaching and filecache are compatible with each other, there maybe some scenarios in which both could be used.
static TAutoConsoleVariable<bool> CVarEnableVulkanPSOFileCacheWhenPrecachingActive(
TEXT("r.Vulkan.EnablePSOFileCacheWhenPrecachingActive"),
false,
TEXT("false: If precaching is available (r.PSOPrecaching=1, r.Vulkan.UseChunkedPSOCache=1) then disable the PSO filecache. (default)\n")
TEXT("true: Allow both PSO file cache and precaching."),
ECVF_RenderThreadSafe | ECVF_ReadOnly);
bool GGPUCrashDebuggingEnabled = false;
#Associated Variable and Callsites
This variable is associated with another variable named CVarEnableVulkanPSOFileCacheWhenPrecachingActive
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:109
Scope: file
Source code excerpt:
// If precaching is active we should not need the file cache.
// however, precaching and filecache are compatible with each other, there maybe some scenarios in which both could be used.
static TAutoConsoleVariable<bool> CVarEnableVulkanPSOFileCacheWhenPrecachingActive(
TEXT("r.Vulkan.EnablePSOFileCacheWhenPrecachingActive"),
false,
TEXT("false: If precaching is available (r.PSOPrecaching=1, r.Vulkan.UseChunkedPSOCache=1) then disable the PSO filecache. (default)\n")
TEXT("true: Allow both PSO file cache and precaching."),
ECVF_RenderThreadSafe | ECVF_ReadOnly);
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:518
Scope (from outer to inner):
file
function FVulkanDynamicRHI::FVulkanDynamicRHI
Source code excerpt:
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);
// Setup the validation requests ready before we load dlls