r.ShaderPipelineCache.PrecompileBatchTime

r.ShaderPipelineCache.PrecompileBatchTime

#Overview

name: r.ShaderPipelineCache.PrecompileBatchTime

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 r.ShaderPipelineCache.PrecompileBatchTime is to control the amount of time spent precompiling shaders for the Pipeline State Object (PSO) cache in Unreal Engine’s rendering system.

This setting variable is primarily used by the rendering subsystem, specifically the shader pipeline cache module. It’s part of Unreal Engine’s optimization strategy for shader compilation and loading.

The value of this variable is set through the console variable system (CVarPSOFileCachePrecompileBatchTime). It defaults to 0.0f, which means the feature is disabled by default.

This variable interacts closely with the batch size setting (CVarPSOFileCachePrecompileBatchSize). Together, these variables control the precompilation process for shaders.

Developers should be aware that:

  1. This variable is measured in milliseconds.
  2. When enabled (non-zero value), the engine will attempt to spend this amount of time each frame precompiling shaders.
  3. The actual batch size of shaders compiled will dynamically adjust based on how long compilation is taking, aiming to fill the specified time.

Best practices when using this variable include:

  1. Carefully balancing this value with performance needs. Higher values may improve shader loading times but could impact frame rates during compilation.
  2. Using in conjunction with CVarPSOFileCachePrecompileBatchSize for fine-tuned control.
  3. Monitoring performance impact when enabling or adjusting this setting.

Regarding the associated variable CVarPSOFileCachePrecompileBatchTime:

When working with CVarPSOFileCachePrecompileBatchTime, developers should remember that changes to this variable will directly affect the shader precompilation behavior, potentially impacting both load times and runtime performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:88

Scope: file

Source code excerpt:

														   );
static TAutoConsoleVariable<float> CVarPSOFileCachePrecompileBatchTime(
															 TEXT("r.ShaderPipelineCache.PrecompileBatchTime"),
															 0.0f,
															 TEXT("The target time (in ms) to spend precompiling each frame when cpre-optimizing or 0.0 to disable. When precompiling is faster the batch size will grow and when slower will shrink to attempt to occupy the full amount. Defaults to 10.0 (off)."),
															 ECVF_Default | ECVF_RenderThreadSafe
															 );
static TAutoConsoleVariable<int32> CVarPSOFileCacheSaveAfterPSOsLogged(
														   TEXT("r.ShaderPipelineCache.SaveAfterPSOsLogged"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:87

Scope: file

Source code excerpt:

														   ECVF_Default | ECVF_RenderThreadSafe
														   );
static TAutoConsoleVariable<float> CVarPSOFileCachePrecompileBatchTime(
															 TEXT("r.ShaderPipelineCache.PrecompileBatchTime"),
															 0.0f,
															 TEXT("The target time (in ms) to spend precompiling each frame when cpre-optimizing or 0.0 to disable. When precompiling is faster the batch size will grow and when slower will shrink to attempt to occupy the full amount. Defaults to 10.0 (off)."),
															 ECVF_Default | ECVF_RenderThreadSafe
															 );
static TAutoConsoleVariable<int32> CVarPSOFileCacheSaveAfterPSOsLogged(

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:775

Scope (from outer to inner):

file
function     void FShaderPipelineCache::SetBatchMode

Source code excerpt:

			{
				ShaderPipelineCache->BatchSize = CVarPSOFileCachePrecompileBatchSize.GetValueOnAnyThread();
				ShaderPipelineCache->BatchTime = CVarPSOFileCachePrecompileBatchTime.GetValueOnAnyThread();
				break;
			}
			case BatchMode::Fast:
			{
				ShaderPipelineCache->BatchSize = CVarPSOFileCacheBatchSize.GetValueOnAnyThread();
				ShaderPipelineCache->BatchTime = CVarPSOFileCacheBatchTime.GetValueOnAnyThread();