r.Vulkan.PipelineLRUCacheEvictBinary

r.Vulkan.PipelineLRUCacheEvictBinary

#Overview

name: r.Vulkan.PipelineLRUCacheEvictBinary

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Vulkan.PipelineLRUCacheEvictBinary is to control the behavior of pipeline creation and eviction in the Vulkan rendering system of Unreal Engine 5. Specifically, it determines whether pipelines should be created from the binary PSO (Pipeline State Object) cache and binary shader cache, or if they should be immediately evicted.

This setting variable is primarily used by the Vulkan RHI (Rendering Hardware Interface) subsystem of Unreal Engine 5. It is part of the rendering system, particularly the pipeline management for Vulkan graphics API.

The value of this variable is set through a console variable (CVarPipelineLRUCacheEvictBinary) in the Vulkan pipeline management code. It can be changed at runtime through console commands or configuration files.

The associated variable CVarPipelineLRUCacheEvictBinary directly interacts with r.Vulkan.PipelineLRUCacheEvictBinary. They share the same value and purpose.

Developers must be aware that:

  1. Setting this variable to 0 (default) allows the creation of pipelines from the binary PSO cache and shader cache, evicting them only as the cache fills up.
  2. Setting it to 1 prevents pipeline creation and immediately evicts them, which could impact performance but may be useful for debugging or specific optimization scenarios.

Best practices when using this variable include:

  1. Leave it at the default value (0) for normal operation to benefit from pipeline caching.
  2. Use it for debugging pipeline-related issues or when investigating performance anomalies related to pipeline creation.
  3. Be cautious when setting it to 1 in production environments, as it may significantly impact rendering performance.

Regarding the associated variable CVarPipelineLRUCacheEvictBinary:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanPipeline.cpp:76

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarPipelineLRUCacheEvictBinary(
	TEXT("r.Vulkan.PipelineLRUCacheEvictBinary"),
	0,
	TEXT("0: create pipelines in from the binary PSO cache and binary shader cache and evict them only as it fills up.\n")
	TEXT("1: don't create pipelines....just immediately evict them"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanPipeline.cpp:75

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_ReadOnly);

TAutoConsoleVariable<int32> CVarPipelineLRUCacheEvictBinary(
	TEXT("r.Vulkan.PipelineLRUCacheEvictBinary"),
	0,
	TEXT("0: create pipelines in from the binary PSO cache and binary shader cache and evict them only as it fills up.\n")
	TEXT("1: don't create pipelines....just immediately evict them"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanPipeline.cpp:547

Scope (from outer to inner):

file
function     void FVulkanPipelineStateCacheManager::OnShaderPipelineCacheOpened

Source code excerpt:

			PlatformFile.MoveFile(*CompiledPSOCacheFolderName, *TempName);

			if (CVarPipelineLRUCacheEvictBinary.GetValueOnAnyThread())
			{
				bEvictImmediately = true;
			}
		}
		else
		{

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanPipeline.cpp:1537

Scope (from outer to inner):

file
function     VkResult FVulkanPipelineStateCacheManager::CreateVKPipeline

Source code excerpt:

#if PLATFORM_ANDROID
	if (bIsPrecompileJob && FVulkanAndroidPlatform::AreRemoteCompileServicesActive() /*&&
		CVarPipelineLRUCacheEvictBinary.GetValueOnAnyThread()*/)
	{
		FVulkanShader::FSpirvCode VS = PSO->GetPatchedSpirvCode(Shaders[ShaderStage::Vertex]);
		FVulkanShader::FSpirvCode PS = PSO->GetPatchedSpirvCode(Shaders[ShaderStage::Pixel]);
		TArrayView<uint32_t> VSCode = VS.GetCodeView();
		TArrayView<uint32_t> PSCode = PS.GetCodeView();
		size_t AfterSize = 0;