r.RayTracing.PSOCacheSize
r.RayTracing.PSOCacheSize
#Overview
name: r.RayTracing.PSOCacheSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Number of ray tracing pipelines to keep in the cache (default = 50). Set to 0 to disable eviction.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.PSOCacheSize is to control the size of the ray tracing pipeline state object (PSO) cache in Unreal Engine 5’s rendering system. This setting variable determines the number of ray tracing pipelines to keep in the cache.
This setting variable is primarily used by the RHI (Rendering Hardware Interface) subsystem of Unreal Engine 5, specifically within the ray tracing functionality. It’s part of the engine’s rendering pipeline and affects the performance of ray tracing operations.
The value of this variable is set through the console variable system. It’s defined with a default value of 50, meaning the cache will store up to 50 ray tracing pipelines by default.
The associated variable CVarRTPSOCacheSize directly interacts with r.RayTracing.PSOCacheSize. They share the same value and purpose, with CVarRTPSOCacheSize being the actual console variable implementation.
Developers should be aware of the following when using this variable:
- It’s marked as read-only and render thread safe, meaning it should not be modified during runtime.
- Setting the value to 0 disables cache eviction, which could lead to increased memory usage if not managed carefully.
- The cache size directly affects performance and memory usage related to ray tracing operations.
Best practices for using this variable include:
- Adjust the value based on the specific needs of your project. Larger values may improve performance by reducing pipeline state recompilations but will consume more memory.
- Monitor performance and memory usage when tweaking this value to find the optimal balance for your project.
- Consider leaving it at the default value of 50 unless you have specific performance issues related to ray tracing pipeline state creation.
Regarding the associated variable CVarRTPSOCacheSize:
- Its purpose is identical to r.RayTracing.PSOCacheSize, serving as the actual console variable implementation.
- It’s used within the RHI subsystem to control the ray tracing PSO cache size.
- The value is set when the console variable is initialized and can be accessed using GetValueOnAnyThread().
- It directly interacts with the ray tracing pipeline cache, determining when to trim the cache and how many pipelines to keep.
- Developers should be aware that this variable is conditionally compiled based on the RHI_RAYTRACING macro, meaning it’s only available when ray tracing is supported.
- Best practices include using this variable for runtime checks of the current cache size setting and avoiding direct modification of its value, as it’s intended to be controlled through the console variable system.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineStateCache.cpp:158
Scope: file
Source code excerpt:
#if RHI_RAYTRACING
static TAutoConsoleVariable<int32> CVarRTPSOCacheSize(
TEXT("r.RayTracing.PSOCacheSize"),
50,
TEXT("Number of ray tracing pipelines to keep in the cache (default = 50). Set to 0 to disable eviction.\n"),
ECVF_ReadOnly | ECVF_RenderThreadSafe
);
#endif // RHI_RAYTRACING
#Associated Variable and Callsites
This variable is associated with another variable named CVarRTPSOCacheSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineStateCache.cpp:157
Scope: file
Source code excerpt:
#if RHI_RAYTRACING
static TAutoConsoleVariable<int32> CVarRTPSOCacheSize(
TEXT("r.RayTracing.PSOCacheSize"),
50,
TEXT("Number of ray tracing pipelines to keep in the cache (default = 50). Set to 0 to disable eviction.\n"),
ECVF_ReadOnly | ECVF_RenderThreadSafe
);
#endif // RHI_RAYTRACING
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/PipelineStateCache.cpp:2545
Scope (from outer to inner):
file
function FRayTracingPipelineState* PipelineStateCache::GetAndOrCreateRayTracingPipelineState
Source code excerpt:
// Remove old pipelines once per frame
const int32 TargetCacheSize = CVarRTPSOCacheSize.GetValueOnAnyThread();
if (TargetCacheSize > 0 && GRayTracingPipelineCache.GetLastTrimFrame() != GFrameCounter)
{
GRayTracingPipelineCache.Trim(TargetCacheSize);
}
Result = GRayTracingPipelineCache.Add(Initializer);