r.SkinCache.SceneMemoryLimitInMB

r.SkinCache.SceneMemoryLimitInMB

#Overview

name: r.SkinCache.SceneMemoryLimitInMB

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SkinCache.SceneMemoryLimitInMB is to control the maximum memory allocation for GPU skin caching per World/Scene in Unreal Engine 5’s rendering system. This setting is crucial for managing memory usage in the GPU skin cache, which is used to optimize skeletal mesh rendering performance.

The Unreal Engine subsystem that primarily relies on this setting variable is the rendering system, specifically the GPU Skin Cache component. This can be seen from the file locations where the variable is referenced, such as GPUSkinCache.cpp and SceneRendering.cpp.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 128.0f megabytes, but can be changed at runtime through console commands or project settings.

The associated variable CVarGPUSkinCacheSceneMemoryLimitInMB interacts directly with r.SkinCache.SceneMemoryLimitInMB. They share the same value and purpose, with CVarGPUSkinCacheSceneMemoryLimitInMB being the actual console variable that can be manipulated at runtime.

Developers must be aware that this variable directly impacts memory usage and performance. Setting it too low might result in insufficient memory for optimal skin caching, while setting it too high could lead to excessive memory consumption.

Best practices when using this variable include:

  1. Monitoring performance and memory usage to find the optimal value for your specific project.
  2. Adjusting the value based on the target hardware capabilities.
  3. Considering the complexity and number of skeletal meshes in your scenes when setting this value.

Regarding the associated variable CVarGPUSkinCacheSceneMemoryLimitInMB:

The purpose of CVarGPUSkinCacheSceneMemoryLimitInMB is to provide a runtime-modifiable console variable for controlling the GPU skin cache memory limit. It’s used to implement the r.SkinCache.SceneMemoryLimitInMB setting in the engine’s code.

This variable is part of the rendering system, specifically the GPU Skin Cache component. It’s used in the FGPUSkinCache::CVarSinkFunction() to update the skin cache settings when changed.

The value of CVarGPUSkinCacheSceneMemoryLimitInMB is set through the console variable system and can be modified at runtime.

Developers should be aware that changes to this variable will affect the GPU skin cache’s memory usage and potentially impact rendering performance.

Best practices for using CVarGPUSkinCacheSceneMemoryLimitInMB include:

  1. Using it for runtime adjustments and performance tuning.
  2. Monitoring its impact on memory usage and rendering performance when modified.
  3. Considering it in conjunction with other GPU skin cache settings for optimal performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:145

Scope: file

Source code excerpt:

static float GSkinCacheSceneMemoryLimitInMB = 128.0f;
static TAutoConsoleVariable<float> CVarGPUSkinCacheSceneMemoryLimitInMB(
	TEXT("r.SkinCache.SceneMemoryLimitInMB"),
	128.0f,
	TEXT("Maximum memory allowed to be allocated per World/Scene in Megs"),
	ECVF_RenderThreadSafe
);

static int32 GAllowDupedVertsForRecomputeTangents = 0;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/GPUSkinCache.h:16

Scope: file

Source code excerpt:

// * Fixes velocity rendering (needed for MotionBlur and TemporalAA) for WorldPosOffset animation and morph target animation
// * RecomputeTangents results in improved tangent space for WorldPosOffset animation and morph target animation
// * fixed amount of memory per Scene (r.SkinCache.SceneMemoryLimitInMB)
// * Velocity Rendering for MotionBlur and TemporalAA (test Velocity in BasePass)
// * r.SkinCache.Mode and r.SkinCache.RecomputeTangents can be toggled at runtime

// TODO:
// * Test: Tessellation
// * Quality/Optimization: increase TANGENT_RANGE for better quality or accumulate two components in one 32bit value

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3700

Scope (from outer to inner):

file
function     void FSceneRenderer::OnRenderFinish

Source code excerpt:

		}
		
		static auto* CVarSkinCacheOOM = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.SkinCache.SceneMemoryLimitInMB"));

		uint64 GPUSkinCacheExtraRequiredMemory = 0;
		if (FGPUSkinCache* SkinCache = Scene->GetGPUSkinCache())
		{
			GPUSkinCacheExtraRequiredMemory = SkinCache->GetExtraRequiredMemoryAndReset();
		}

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:144

Scope: file

Source code excerpt:


static float GSkinCacheSceneMemoryLimitInMB = 128.0f;
static TAutoConsoleVariable<float> CVarGPUSkinCacheSceneMemoryLimitInMB(
	TEXT("r.SkinCache.SceneMemoryLimitInMB"),
	128.0f,
	TEXT("Maximum memory allowed to be allocated per World/Scene in Megs"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSkinCache.cpp:2307

Scope (from outer to inner):

file
function     void FGPUSkinCache::CVarSinkFunction

Source code excerpt:

	int32 NewGPUSkinCacheValue = CVarEnableGPUSkinCache.GetValueOnAnyThread() != 0;
	int32 NewRecomputeTangentsValue = CVarGPUSkinCacheRecomputeTangents.GetValueOnAnyThread();
	const float NewSceneMaxSizeInMb = CVarGPUSkinCacheSceneMemoryLimitInMB.GetValueOnAnyThread();
	const int32 NewNumTangentIntermediateBuffers = CVarGPUSkinNumTangentIntermediateBuffers.GetValueOnAnyThread();
	const bool NewSkipCompilingGPUSkinVF = CVarSkipCompilingGPUSkinVF.GetValueOnAnyThread();

	if (GEnableGPUSkinCacheShaders)
	{
		if (GIsRHIInitialized && IsGPUSkinCacheRayTracingSupported() && IsRayTracingEnabled())