D3D12.PSO.DiskCache
D3D12.PSO.DiskCache
#Overview
name: D3D12.PSO.DiskCache
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables a disk cache for Pipeline State Objects (PSOs).\nPSO descs are cached to disk so subsequent runs can create PSOs at load-time instead of at run-time.\nThis cache contains data that is independent of hardware, driver, or machine that it was created on. It can be distributed with shipping content.\n0 to disable the pipeline state disk cache\n1 to enable the pipeline state disk cache (default)\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of D3D12.PSO.DiskCache is to enable or disable a disk cache for Pipeline State Objects (PSOs) in the Direct3D 12 rendering system of Unreal Engine 5. This setting variable is primarily used in the D3D12RHI (Direct3D 12 Rendering Hardware Interface) module of Unreal Engine.
The D3D12RHI subsystem relies on this setting variable to determine whether to use a disk cache for PSOs. However, based on the comment in the code, it appears that the D3D12RHI PSO file cache is no longer functional, and the system now uses FPipelineFileCacheManager instead.
The value of this variable is set through a console variable (CVarPipelineStateDiskCache) with a default value of 0, which means the disk cache is disabled by default. Developers can change this value at runtime or through configuration files.
This variable interacts with another variable named CVarPipelineStateDiskCache, which is the actual TAutoConsoleVariable that stores and manages the setting value.
Developers should be aware that:
- The PSO disk cache functionality for D3D12RHI appears to be deprecated, as indicated by the comment.
- The system now uses FPipelineFileCacheManager instead of this disk cache.
- Even though the variable exists, setting it to 1 may not have the intended effect due to the deprecation.
Best practices when using this variable:
- Consider using FPipelineFileCacheManager for PSO caching instead of relying on this setting.
- Keep the default value (0) unless there’s a specific reason to enable it, given its deprecated status.
- Be aware of potential performance implications if enabling or disabling this cache.
Regarding the associated variable CVarPipelineStateDiskCache:
This is the actual console variable that controls the D3D12.PSO.DiskCache setting. It’s an integer variable that can be set to 0 (disable) or 1 (enable). The variable is used in the FD3D12PipelineStateCache::Init function to determine whether to use the general pipeline state disk cache.
Developers should note that:
- This variable is checked at runtime using GetValueOnAnyThread(), allowing for dynamic configuration.
- The value of this variable is logged for debugging purposes.
- Even if enabled, the functionality may not be active due to the deprecation mentioned earlier.
Best practices for CVarPipelineStateDiskCache:
- Use console commands or configuration files to modify this value if needed.
- Monitor performance impacts when changing this value, especially in shipping builds.
- Consider removing or updating references to this variable if implementing a new PSO caching system using FPipelineFileCacheManager.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12PipelineState.cpp:27
Scope: file
Source code excerpt:
// D3D12RHI PSO file cache doesn't work anymore. Use FPipelineFileCacheManager instead
static TAutoConsoleVariable<int32> CVarPipelineStateDiskCache(
TEXT("D3D12.PSO.DiskCache"),
0,
TEXT("Enables a disk cache for Pipeline State Objects (PSOs).\n")
TEXT("PSO descs are cached to disk so subsequent runs can create PSOs at load-time instead of at run-time.\n")
TEXT("This cache contains data that is independent of hardware, driver, or machine that it was created on. It can be distributed with shipping content.\n")
TEXT("0 to disable the pipeline state disk cache\n")
TEXT("1 to enable the pipeline state disk cache (default)\n"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarPipelineStateDiskCache
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12PipelineState.cpp:26
Scope: file
Source code excerpt:
// D3D12RHI PSO file cache doesn't work anymore. Use FPipelineFileCacheManager instead
static TAutoConsoleVariable<int32> CVarPipelineStateDiskCache(
TEXT("D3D12.PSO.DiskCache"),
0,
TEXT("Enables a disk cache for Pipeline State Objects (PSOs).\n")
TEXT("PSO descs are cached to disk so subsequent runs can create PSOs at load-time instead of at run-time.\n")
TEXT("This cache contains data that is independent of hardware, driver, or machine that it was created on. It can be distributed with shipping content.\n")
TEXT("0 to disable the pipeline state disk cache\n")
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12PipelineState.cpp:503
Scope (from outer to inner):
file
function void FD3D12PipelineStateCache::Init
Source code excerpt:
FRWScopeLock Lock(DiskCachesCS, SLT_Write);
const bool bEnableGeneralPipelineStateDiskCaches = CVarPipelineStateDiskCache.GetValueOnAnyThread() != 0;
UE_CLOG(!bEnableGeneralPipelineStateDiskCaches, LogD3D12RHI, Display, TEXT("Not using pipeline state disk cache per r.D3D12.PSO.DiskCache=0"));
const bool bEnableDriverOptimizedPipelineStateDiskCaches = CVarDriverOptimizedPipelineStateDiskCache.GetValueOnAnyThread() != 0;
UE_CLOG(!bEnableDriverOptimizedPipelineStateDiskCaches, LogD3D12RHI, Display, TEXT("Not using driver-optimized pipeline state disk cache per r.D3D12.PSO.DriverOptimizedDiskCache=0"));
bUseAPILibaries = bEnableDriverOptimizedPipelineStateDiskCaches;