D3D12.PSO.DriverOptimizedDiskCache

D3D12.PSO.DriverOptimizedDiskCache

#Overview

name: D3D12.PSO.DriverOptimizedDiskCache

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of D3D12.PSO.DriverOptimizedDiskCache is to enable or disable a disk cache for driver-optimized Pipeline State Objects (PSOs) in the Direct3D 12 rendering system of Unreal Engine 5.

This setting variable is primarily used by the D3D12RHI (Direct3D 12 Rendering Hardware Interface) module of Unreal Engine 5. It specifically affects the pipeline state caching system within the D3D12 renderer.

The value of this variable is set through a console variable (CVarDriverOptimizedPipelineStateDiskCache) defined in the WindowsD3D12PipelineState.cpp file. It can be set to 0 to disable the cache or 1 to enable it.

The associated variable CVarDriverOptimizedPipelineStateDiskCache directly interacts with D3D12.PSO.DriverOptimizedDiskCache. They share the same value and purpose.

Developers must be aware that this cache contains data specific to the hardware, driver, and machine on which it was created. This means the cache may not be portable across different systems or hardware configurations.

Best practices when using this variable include:

  1. Enable it (set to 1) to improve performance by creating PSOs at load-time instead of run-time in subsequent runs of the application.
  2. Be cautious when distributing cached data, as it may not be compatible across different systems.
  3. Consider disabling it (set to 0) during development or when frequently changing shaders to ensure the latest changes are always reflected.

Regarding the associated variable CVarDriverOptimizedPipelineStateDiskCache:

Developers should treat CVarDriverOptimizedPipelineStateDiskCache as the programmatic interface to control the D3D12.PSO.DriverOptimizedDiskCache setting within their code.

#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:37

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDriverOptimizedPipelineStateDiskCache(
	TEXT("D3D12.PSO.DriverOptimizedDiskCache"),
	0,
	TEXT("Enables a disk cache for driver-optimized 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 specific to the hardware, driver, and machine that it was created on.\n")
	TEXT("0 to disable the driver-optimized pipeline state disk cache\n")
	TEXT("1 to enable the driver-optimized pipeline state disk cache\n"),

#Associated Variable and Callsites

This variable is associated with another variable named CVarDriverOptimizedPipelineStateDiskCache. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12PipelineState.cpp:36

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarDriverOptimizedPipelineStateDiskCache(
	TEXT("D3D12.PSO.DriverOptimizedDiskCache"),
	0,
	TEXT("Enables a disk cache for driver-optimized 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 specific to the hardware, driver, and machine that it was created on.\n")
	TEXT("0 to disable the driver-optimized pipeline state disk cache\n")

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12PipelineState.cpp:506

Scope (from outer to inner):

file
function     void FD3D12PipelineStateCache::Init

Source code excerpt:

	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;

	DiskCaches[PSO_CACHE_GRAPHICS].Init(GraphicsCacheFileName, bEnableGeneralPipelineStateDiskCaches);
	DiskCaches[PSO_CACHE_COMPUTE].Init(ComputeCacheFileName, bEnableGeneralPipelineStateDiskCaches);
	DiskBinaryCache.Init(DriverBlobFileName, bEnableDriverOptimizedPipelineStateDiskCaches);