r.SkinCache.RayTracingUseTransientForScratch

r.SkinCache.RayTracingUseTransientForScratch

#Overview

name: r.SkinCache.RayTracingUseTransientForScratch

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.RayTracingUseTransientForScratch is to control the memory allocation strategy for BLAS (Bottom-Level Acceleration Structure) scratch buffers in ray tracing for skinned geometry.

This setting variable is primarily used in the ray tracing subsystem of Unreal Engine, specifically for handling skinned geometry. It’s part of the rendering system, focusing on optimizing memory usage for ray tracing operations.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands or configuration files.

The associated variable GRayTracingUseTransientForScratch directly interacts with r.SkinCache.RayTracingUseTransientForScratch. They share the same value, with GRayTracingUseTransientForScratch being the actual integer variable used in the code logic.

Developers should be aware that this variable affects memory allocation strategies. When enabled (set to a value greater than 0), it uses transient memory for BLAS scratch allocation. This can potentially reduce memory footprint and allocation overhead, which is particularly important for performance-sensitive ray tracing operations.

Best practices when using this variable include:

  1. Testing performance with and without transient memory allocation to determine the optimal setting for your specific use case.
  2. Monitoring memory usage and performance metrics when adjusting this setting.
  3. Considering the trade-offs between memory footprint and potential allocation overhead.

Regarding the associated variable GRayTracingUseTransientForScratch:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static int32 GRayTracingUseTransientForScratch = 0;
FAutoConsoleVariableRef CVarSkinnedGeometryRayTracingUseTransientForScratch(
	TEXT("r.SkinCache.RayTracingUseTransientForScratch"),
	GRayTracingUseTransientForScratch,
	TEXT("Use Transient memory for BLAS scratch allocation to reduce memory footprint and allocation overhead."),
	ECVF_RenderThreadSafe
);

static int32 GMaxRayTracingPrimitivesPerCmdList = -1;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static int32 GRayTracingUseTransientForScratch = 0;
FAutoConsoleVariableRef CVarSkinnedGeometryRayTracingUseTransientForScratch(
	TEXT("r.SkinCache.RayTracingUseTransientForScratch"),
	GRayTracingUseTransientForScratch,
	TEXT("Use Transient memory for BLAS scratch allocation to reduce memory footprint and allocation overhead."),
	ECVF_RenderThreadSafe
);

static int32 GMaxRayTracingPrimitivesPerCmdList = -1;
FAutoConsoleVariableRef CVarSkinnedGeometryMaxRayTracingPrimitivesPerCmdList(

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

Scope (from outer to inner):

file
function     uint32 FRayTracingSkinnedGeometryUpdateQueue::ComputeScratchBufferSize

Source code excerpt:

	uint32 ScratchBLASSize = 0;

	if (ToUpdate.Num() && GRayTracingUseTransientForScratch > 0)
	{
		for (TMap<FRayTracingGeometry*, FRayTracingUpdateInfo>::TRangedForConstIterator Iter = ToUpdate.begin(); Iter != ToUpdate.end(); ++Iter)
		{			
			FRayTracingUpdateInfo const& UpdateInfo = Iter.Value();
			ScratchBLASSize = Align(ScratchBLASSize + UpdateInfo.ScratchSize, ScratchAlignment);
		}