r.SkinCache.MemoryLimitForBatchedRayTracingGeometryUpdates

r.SkinCache.MemoryLimitForBatchedRayTracingGeometryUpdates

#Overview

name: r.SkinCache.MemoryLimitForBatchedRayTracingGeometryUpdates

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.SkinCache.MemoryLimitForBatchedRayTracingGeometryUpdates is to control the memory limit for batched ray tracing geometry updates in the skin cache system of Unreal Engine 5.

This setting variable is primarily used in the ray tracing and skinned geometry rendering subsystem of Unreal Engine 5. Based on the callsites, it’s part of the Engine module, specifically in the RayTracingSkinnedGeometry component.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 512 (MB) and can be modified at runtime using console commands.

The associated variable GMemoryLimitForBatchedRayTracingGeometryUpdates directly interacts with r.SkinCache.MemoryLimitForBatchedRayTracingGeometryUpdates. They share the same value, with the console variable controlling the static integer variable.

Developers should be aware that this variable affects the memory management of ray tracing geometry updates for skinned meshes. It sets a threshold for when to flush pending resource deletions before allocating new Bottom Level Acceleration Structure (BLAS) data.

Best practices when using this variable include:

  1. Monitoring performance and memory usage to find the optimal value for your specific use case.
  2. Being cautious when modifying this value, as it can impact rendering performance and memory usage.
  3. Understanding that higher values may lead to more batched updates but could also increase memory pressure.

Regarding the associated variable GMemoryLimitForBatchedRayTracingGeometryUpdates:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RayTracingSkinnedGeometry.cpp:12

Scope: file

Source code excerpt:

static int32 GMemoryLimitForBatchedRayTracingGeometryUpdates = 512;
FAutoConsoleVariableRef CVarSkinnedGeometryMemoryLimitForBatchedRayTracingGeometryUpdates(
	TEXT("r.SkinCache.MemoryLimitForBatchedRayTracingGeometryUpdates"),
	GMemoryLimitForBatchedRayTracingGeometryUpdates,
	TEXT(""),
	ECVF_RenderThreadSafe
);

static int32 GRayTracingUseTransientForScratch = 0;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RayTracingSkinnedGeometry.cpp:10

Scope: file

Source code excerpt:

DECLARE_GPU_STAT(SkinnedGeometryUpdateBLAS);

static int32 GMemoryLimitForBatchedRayTracingGeometryUpdates = 512;
FAutoConsoleVariableRef CVarSkinnedGeometryMemoryLimitForBatchedRayTracingGeometryUpdates(
	TEXT("r.SkinCache.MemoryLimitForBatchedRayTracingGeometryUpdates"),
	GMemoryLimitForBatchedRayTracingGeometryUpdates,
	TEXT(""),
	ECVF_RenderThreadSafe
);

static int32 GRayTracingUseTransientForScratch = 0;
FAutoConsoleVariableRef CVarSkinnedGeometryRayTracingUseTransientForScratch(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RayTracingSkinnedGeometry.cpp:94

Scope (from outer to inner):

file
function     void FRayTracingSkinnedGeometryUpdateQueue::Commit

Source code excerpt:

		// If we have more deferred deleted data than set limit then force flush to make sure all pending releases have actually been freed
		// before reallocating a lot of new BLAS data
		if (EstimatedMemoryPendingRelease >= GMemoryLimitForBatchedRayTracingGeometryUpdates * 1024ull * 1024ull)
		{
			RHICmdList.ImmediateFlush(EImmediateFlushType::FlushRHIThreadFlushResources);
			//UE_LOG(LogRenderer, Display, TEXT("Flushing RHI resource pending deletes due to %d MB limit"), GMemoryLimitForBatchedRayTracingGeometryUpdates);
		}
				
		// Track the amount of primitives which need to be build/updated in a single batch
		uint64 PrimitivesToUpdates = 0;
		TArray<FRayTracingGeometryBuildParams> BatchedBuildParams;
		TArray<FRayTracingGeometryBuildParams> BatchedUpdateParams;