r.PSO.RuntimeCreationHitchThreshold
r.PSO.RuntimeCreationHitchThreshold
#Overview
name: r.PSO.RuntimeCreationHitchThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Threshold for runtime PSO creation to count as a hitch (in msec) (default 20)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PSO.RuntimeCreationHitchThreshold is to set a threshold for detecting hitches during runtime Pipeline State Object (PSO) creation in Unreal Engine’s rendering system. This variable is used to monitor and track performance issues related to PSO creation during gameplay.
This setting variable is primarily used in the RHI (Rendering Hardware Interface) module of Unreal Engine. Specifically, it’s referenced in the PipelineStateCache.cpp file, which is part of the runtime rendering system.
The value of this variable is set using a TAutoConsoleVariable, which allows it to be modified through the console or configuration files. By default, it’s set to 20 milliseconds.
The associated variable CVarPSORuntimeCreationHitchThreshold directly interacts with r.PSO.RuntimeCreationHitchThreshold. They share the same value and purpose.
Developers must be aware that this variable is marked as ECVF_ReadOnly and ECVF_RenderThreadSafe, meaning it should not be modified during runtime and is safe to access from the render thread.
Best practices when using this variable include:
- Monitoring the STAT_RuntimeGraphicsPSOHitchCount statistic to identify frequent hitches during PSO creation.
- Adjusting the threshold value based on the specific performance requirements of the game or application.
- Using this in conjunction with other PSO-related optimizations to improve overall rendering performance.
Regarding the associated variable CVarPSORuntimeCreationHitchThreshold:
- It’s used to retrieve the current threshold value in the CheckAndUpdateHitchCountStat function.
- This function compares the PSO creation time against the threshold to determine if a hitch has occurred.
- If a hitch is detected, it increments a statistic counter (STAT_RuntimeGraphicsPSOHitchCount for graphics PSOs).
Developers should use this variable to fine-tune their performance monitoring and optimization efforts, especially when dealing with complex scenes that require frequent PSO creation during runtime.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineStateCache.cpp:150
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarPSORuntimeCreationHitchThreshold(
TEXT("r.PSO.RuntimeCreationHitchThreshold"),
20,
TEXT("Threshold for runtime PSO creation to count as a hitch (in msec) (default 20)"),
ECVF_ReadOnly | ECVF_RenderThreadSafe
);
#if RHI_RAYTRACING
#Associated Variable and Callsites
This variable is associated with another variable named CVarPSORuntimeCreationHitchThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineStateCache.cpp:149
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarPSORuntimeCreationHitchThreshold(
TEXT("r.PSO.RuntimeCreationHitchThreshold"),
20,
TEXT("Threshold for runtime PSO creation to count as a hitch (in msec) (default 20)"),
ECVF_ReadOnly | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineStateCache.cpp:195
Scope (from outer to inner):
file
function static inline void CheckAndUpdateHitchCountStat
Source code excerpt:
if (bIsRuntimePSO)
{
int32 RuntimePSOCreationHitchThreshold = CVarPSORuntimeCreationHitchThreshold.GetValueOnAnyThread();
double PSOCreationTimeMs = FPlatformTime::ToMilliseconds64(FPlatformTime::Cycles64() - StartTime);
if (PSOCreationTimeMs > RuntimePSOCreationHitchThreshold)
{
if (PSOType == FPSOPrecacheRequestID::EType::Graphics)
{
INC_DWORD_STAT(STAT_RuntimeGraphicsPSOHitchCount);