r.ShaderPipelineCache.PrecompileBatchSize
r.ShaderPipelineCache.PrecompileBatchSize
#Overview
name: r.ShaderPipelineCache.PrecompileBatchSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Set the number of PipelineStateObjects to compile in a single batch operation when pre-optimizing the cache. Defaults to a maximum of 50 per frame, due to async. file IO it is less in practice.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPipelineCache.PrecompileBatchSize is to control the number of PipelineStateObjects (PSOs) that are compiled in a single batch operation when pre-optimizing the shader pipeline cache. This setting is primarily used for the rendering system, specifically for shader compilation and optimization.
This setting variable is relied upon by the Unreal Engine’s rendering subsystem, particularly within the RenderCore module. It is used in the ShaderPipelineCache class, which is responsible for managing and optimizing shader pipeline states.
The value of this variable is set through a console variable (CVarPSOFileCachePrecompileBatchSize) with a default value of 50. It can be modified at runtime through console commands or configuration files.
The associated variable CVarPSOFileCachePrecompileBatchSize directly interacts with r.ShaderPipelineCache.PrecompileBatchSize. They share the same value and purpose.
Developers must be aware that this variable affects the performance and responsiveness of shader compilation. A larger batch size may lead to more efficient compilation but could potentially cause longer frame times or stuttering during the precompilation process.
Best practices when using this variable include:
- Adjusting the value based on the target hardware capabilities and project requirements.
- Monitoring performance impacts when modifying this value.
- Considering the trade-off between compilation speed and runtime performance.
- Using it in conjunction with other shader pipeline cache settings for optimal results.
Regarding the associated variable CVarPSOFileCachePrecompileBatchSize:
The purpose of CVarPSOFileCachePrecompileBatchSize is identical to r.ShaderPipelineCache.PrecompileBatchSize. It is the internal representation of the console variable used to control the precompile batch size.
This variable is used within the RenderCore module, specifically in the ShaderPipelineCache implementation.
The value is set when the console variable is initialized and can be accessed using the GetValueOnAnyThread() method.
CVarPSOFileCachePrecompileBatchSize directly interacts with the ShaderPipelineCache class, setting the BatchSize member variable when the batch mode is set to Precompile.
Developers should be aware that this variable is the actual storage for the console variable value and is used internally by the engine.
Best practices for using this variable include:
- Accessing its value through the provided console variable interface rather than directly.
- Understanding that changes to this variable will affect the shader precompilation process.
- Considering the impact on memory usage and compilation time when adjusting this value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:70
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarPSOFileCachePrecompileBatchSize(
TEXT("r.ShaderPipelineCache.PrecompileBatchSize"),
50,
TEXT("Set the number of PipelineStateObjects to compile in a single batch operation when pre-optimizing the cache. Defaults to a maximum of 50 per frame, due to async. file IO it is less in practice."),
ECVF_Default | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarPSOFileCacheBackgroundBatchTime(
TEXT("r.ShaderPipelineCache.BackgroundBatchTime"),
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Public/ShaderPipelineCache.h:95
Scope (from outer to inner):
file
class class FShaderPipelineCache : public FTickableObjectRenderThread
Source code excerpt:
Background, // The maximum batch size is defined by r.ShaderPipelineCache.BackgroundBatchSize
Fast, // The maximum batch size is defined by r.ShaderPipelineCache.BatchSize
Precompile // The maximum batch size is defined by r.ShaderPipelineCache.PrecompileBatchSize
};
/** Sets the precompilation batching mode. */
static RENDERCORE_API void SetBatchMode(BatchMode Mode);
/** Resumes precompilation batching. */
#Associated Variable and Callsites
This variable is associated with another variable named CVarPSOFileCachePrecompileBatchSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:69
Scope: file
Source code excerpt:
ECVF_Default | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarPSOFileCachePrecompileBatchSize(
TEXT("r.ShaderPipelineCache.PrecompileBatchSize"),
50,
TEXT("Set the number of PipelineStateObjects to compile in a single batch operation when pre-optimizing the cache. Defaults to a maximum of 50 per frame, due to async. file IO it is less in practice."),
ECVF_Default | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarPSOFileCacheBackgroundBatchTime(
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderPipelineCache.cpp:774
Scope (from outer to inner):
file
function void FShaderPipelineCache::SetBatchMode
Source code excerpt:
case BatchMode::Precompile:
{
ShaderPipelineCache->BatchSize = CVarPSOFileCachePrecompileBatchSize.GetValueOnAnyThread();
ShaderPipelineCache->BatchTime = CVarPSOFileCachePrecompileBatchTime.GetValueOnAnyThread();
break;
}
case BatchMode::Fast:
{
ShaderPipelineCache->BatchSize = CVarPSOFileCacheBatchSize.GetValueOnAnyThread();