r.SkinCache.SkipCompilingGPUSkinVF

r.SkinCache.SkipCompilingGPUSkinVF

#Overview

name: r.SkinCache.SkipCompilingGPUSkinVF

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.SkipCompilingGPUSkinVF is to control the compilation of GPU Skin Vertex Factory shader permutations in Unreal Engine’s rendering system. Specifically, it’s used to reduce the number of shader variants compiled for the GPU skinning system.

This setting variable is primarily used in the Engine’s rendering subsystem, particularly in the GPU skinning and skin cache modules. It’s referenced in the GPUSkinCache.cpp and SkeletalRenderGPUSkin.cpp files, which are part of the core rendering pipeline for skeletal meshes.

The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of false. This means by default, all GPU Skin Vertex Factory variants are compiled.

The associated variable CVarSkipCompilingGPUSkinVF directly interacts with r.SkinCache.SkipCompilingGPUSkinVF. They share the same value and are used interchangeably in the code.

Developers must be aware of several important points when using this variable:

  1. Setting this to true will reduce shader permutations but may limit functionality.
  2. It cannot be disabled while the skin cache is turned off.
  3. When set to true, it may cause skeletal meshes to draw in reference pose if the appropriate shaders are not available.

Best practices for using this variable include:

  1. Only enable it if you’re experiencing issues with shader compilation times or storage.
  2. Ensure that the skin cache is enabled when using this variable.
  3. Be prepared to increase the r.SkinCache.SceneMemoryLimitInMB if you encounter rendering issues.

Regarding the associated variable CVarSkipCompilingGPUSkinVF:

The purpose of CVarSkipCompilingGPUSkinVF is identical to r.SkinCache.SkipCompilingGPUSkinVF. It’s an internal representation of the console variable used within the C++ code.

This variable is used in the Engine’s GPU skinning system, specifically in the GPUSkinCache module.

Its value is set through the console variable system and is read-only during runtime.

CVarSkipCompilingGPUSkinVF directly interacts with r.SkinCache.SkipCompilingGPUSkinVF, sharing the same value.

Developers should be aware that this variable is used internally and should generally interact with r.SkinCache.SkipCompilingGPUSkinVF instead.

Best practices include using the CVarSinkFunction to react to changes in this variable’s value, as shown in the provided code snippet.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarSkipCompilingGPUSkinVF(
	TEXT("r.SkinCache.SkipCompilingGPUSkinVF"),
	false,
	TEXT("Reduce GPU Skin Vertex Factory shader permutations. Cannot be disabled while the skin cache is turned off.\n")
	TEXT(" False ( 0): Compile all GPU Skin Vertex factory variants.\n")
	TEXT(" True  ( 1): Don't compile all GPU Skin Vertex factory variants."),
    ECVF_RenderThreadSafe | ECVF_ReadOnly
);

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

Scope (from outer to inner):

file
function     bool ShouldWeCompileGPUSkinVFShaders

Source code excerpt:


	// If the skin cache is enabled and we've been asked to skip GPU Skin VF shaders.
	static FShaderPlatformCachedIniValue<bool> PerPlatformCVar(TEXT("r.SkinCache.SkipCompilingGPUSkinVF"));
	return (PerPlatformCVar.Get(Platform) == false);
}

ENGINE_API bool GPUSkinCacheNeedsDuplicatedVertices()
{
#if WITH_EDITOR // Duplicated vertices are used in the editor when merging meshes

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalRenderGPUSkin.cpp:1585

Scope (from outer to inner):

file
function     const FVertexFactory* FSkeletalMeshObjectGPUSkin::GetSkinVertexFactory

Source code excerpt:


	// If we have not compiled GPU Skin vertex factory variants
	static const auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SkinCache.SkipCompilingGPUSkinVF"));
	if (FeatureLevel != ERHIFeatureLevel::ES3_1 && CVar && CVar->GetBool() == true)
	{
		UE_LOG(LogSkeletalMesh, Display, TEXT("We are attempting to render with a GPU Skin Vertex Factory, but r.SkinCache.SkipCompilingGPUSkinVF=1 so we don't have shaders.  Skeletal meshes will draw in ref pose.  Either disable r.SkinCache.SkipCompilingGPUSkinVF or increase the r.SkinCache.SceneMemoryLimitInMB size."));
		return LOD.GPUSkinVertexFactories.PassthroughVertexFactories[ChunkIdx].Get();
	}

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarSkipCompilingGPUSkinVF(
	TEXT("r.SkinCache.SkipCompilingGPUSkinVF"),
	false,
	TEXT("Reduce GPU Skin Vertex Factory shader permutations. Cannot be disabled while the skin cache is turned off.\n")
	TEXT(" False ( 0): Compile all GPU Skin Vertex factory variants.\n")
	TEXT(" True  ( 1): Don't compile all GPU Skin Vertex factory variants."),
    ECVF_RenderThreadSafe | ECVF_ReadOnly

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

Scope (from outer to inner):

file
function     void FGPUSkinCache::CVarSinkFunction

Source code excerpt:

	const float NewSceneMaxSizeInMb = CVarGPUSkinCacheSceneMemoryLimitInMB.GetValueOnAnyThread();
	const int32 NewNumTangentIntermediateBuffers = CVarGPUSkinNumTangentIntermediateBuffers.GetValueOnAnyThread();
	const bool NewSkipCompilingGPUSkinVF = CVarSkipCompilingGPUSkinVF.GetValueOnAnyThread();

	if (GEnableGPUSkinCacheShaders)
	{
		if (GIsRHIInitialized && IsGPUSkinCacheRayTracingSupported() && IsRayTracingEnabled())
		{
			// Skin cache is *required* for ray tracing.