r.SkinCache.NumTangentIntermediateBuffers

r.SkinCache.NumTangentIntermediateBuffers

#Overview

name: r.SkinCache.NumTangentIntermediateBuffers

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.NumTangentIntermediateBuffers is to control the number of intermediate buffers used for storing intermediate results during the process of recomputing tangents in the GPU Skin Cache system. This setting is part of Unreal Engine’s rendering system, specifically the GPU Skin Cache module.

This setting variable is primarily used in the Engine module, particularly within the GPU Skin Cache subsystem. Based on the callsites, it’s clear that this variable is utilized in the GPUSkinCache.cpp file, which is part of the rendering pipeline responsible for GPU-based skinning calculations.

The value of this variable is set through a console variable (CVarGPUSkinNumTangentIntermediateBuffers) using the TAutoConsoleVariable template. The default value is set to 1, but it can be changed at runtime through console commands or project settings.

The associated variable GNumTangentIntermediateBuffers interacts directly with r.SkinCache.NumTangentIntermediateBuffers. They share the same initial value, and GNumTangentIntermediateBuffers is likely used as a cached version of the console variable for faster access in performance-critical code paths.

Developers should be aware that increasing the number of intermediate buffers may allow for better GPU utilization by enabling overlap of compute jobs. However, this comes at the cost of increased memory usage. Therefore, the optimal value will depend on the specific hardware and the requirements of the game or application.

Best practices when using this variable include:

  1. Profiling the application to determine if increasing the number of buffers provides a meaningful performance improvement.
  2. Balancing the potential performance gain against the increased memory usage.
  3. Testing on various hardware configurations to ensure the chosen value works well across different GPUs.
  4. Considering dynamic adjustment of this value based on the detected hardware capabilities.

Regarding the associated variable CVarGPUSkinNumTangentIntermediateBuffers:

The purpose of CVarGPUSkinNumTangentIntermediateBuffers is to provide a runtime-configurable way to control the number of intermediate buffers used in the GPU Skin Cache system. It’s part of the console variable system in Unreal Engine, allowing for easy tweaking and experimentation with different values.

This console variable is used in the Engine module, specifically within the GPU Skin Cache subsystem. It’s defined and used in the GPUSkinCache.cpp file.

The value of CVarGPUSkinNumTangentIntermediateBuffers is set when it’s declared, with a default value of 1. It can be changed at runtime through console commands or engine configuration files.

CVarGPUSkinNumTangentIntermediateBuffers interacts directly with the r.SkinCache.NumTangentIntermediateBuffers setting and the GNumTangentIntermediateBuffers variable. Its value is read in the CVarSinkFunction, which suggests it’s part of a system that reacts to changes in console variables.

Developers should be aware that this is a render thread safe variable (ECVF_RenderThreadSafe), meaning it can be safely changed from any thread without causing race conditions or undefined behavior in the rendering system.

Best practices for using this console variable include:

  1. Using it for experimentation and performance tuning during development.
  2. Documenting any non-default values used in shipping builds.
  3. Considering exposing it as a user-configurable setting if it significantly impacts performance on different hardware configurations.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static int32 GNumTangentIntermediateBuffers = 1;
static TAutoConsoleVariable<float> CVarGPUSkinNumTangentIntermediateBuffers(
	TEXT("r.SkinCache.NumTangentIntermediateBuffers"),
	1,
	TEXT("How many intermediate buffers to use for intermediate results while\n")
	TEXT("doing Recompute Tangents; more may allow the GPU to overlap compute jobs."),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


static int32 GNumTangentIntermediateBuffers = 1;
static TAutoConsoleVariable<float> CVarGPUSkinNumTangentIntermediateBuffers(
	TEXT("r.SkinCache.NumTangentIntermediateBuffers"),
	1,
	TEXT("How many intermediate buffers to use for intermediate results while\n")
	TEXT("doing Recompute Tangents; more may allow the GPU to overlap compute jobs."),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     void FGPUSkinCache::CVarSinkFunction

Source code excerpt:

	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())
		{