r.SkinCache.MaxDispatchesPerCmdList

r.SkinCache.MaxDispatchesPerCmdList

#Overview

name: r.SkinCache.MaxDispatchesPerCmdList

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.MaxDispatchesPerCmdList is to control the maximum number of compute shader dispatches that are batched together into a single command list in the GPU Skin Cache system. This setting is used to prevent potential Time Detection and Recovery (TDR) issues in the rendering pipeline.

This setting variable is primarily used in the GPU Skin Cache subsystem of Unreal Engine’s rendering module. The GPU Skin Cache is responsible for efficient skinning of characters and other deformable meshes on the GPU.

The value of this variable is set through the Unreal Engine console system, as indicated by the FAutoConsoleVariableRef declaration. It can be modified at runtime using console commands or through configuration files.

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

Developers must be aware that this variable affects the performance and stability of the GPU Skin Cache system. Setting it too low might impact performance, while setting it too high could potentially lead to TDR issues on some hardware.

Best practices when using this variable include:

  1. Only modify it if experiencing TDR issues related to the GPU Skin Cache.
  2. Start with small increments when adjusting the value to find the optimal setting for your specific use case.
  3. Test thoroughly on various hardware configurations to ensure stability across different systems.

Regarding the associated variable GSkinCacheMaxDispatchesPerCmdList:

The purpose of GSkinCacheMaxDispatchesPerCmdList is to store the actual integer value used in the GPU Skin Cache logic to control the maximum number of compute shader dispatches per command list.

This variable is used directly in the FGPUSkinCache::IncrementDispatchCounter function to determine when to submit a new command list. When the number of dispatches reaches the value of GSkinCacheMaxDispatchesPerCmdList, a new command list is submitted using RHICmdList.SubmitCommandsHint().

The value of GSkinCacheMaxDispatchesPerCmdList is set through the r.SkinCache.MaxDispatchesPerCmdList console variable.

Developers should be aware that setting GSkinCacheMaxDispatchesPerCmdList to 0 effectively disables the dispatch limiting feature, as the condition GSkinCacheMaxDispatchesPerCmdList > 0 is checked before incrementing the dispatch counter.

Best practices for using GSkinCacheMaxDispatchesPerCmdList include:

  1. Avoid directly modifying this variable in code; instead, use the r.SkinCache.MaxDispatchesPerCmdList console variable to change its value.
  2. Monitor performance and stability when adjusting this value, as it can impact both rendering efficiency and system stability.
  3. Consider logging or profiling the number of dispatches per frame to help fine-tune this value for your specific use case.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static int32 GSkinCacheMaxDispatchesPerCmdList = 0;
FAutoConsoleVariableRef CVarGPUSkinCacheMaxDispatchesPerCmdList(
	TEXT("r.SkinCache.MaxDispatchesPerCmdList"),
	GSkinCacheMaxDispatchesPerCmdList,
	TEXT("Maximum number of compute shader dispatches which are batched together into a single command list to fix potential TDRs."),
	ECVF_RenderThreadSafe
);

static int32 GSkinCachePrintMemorySummary = 0;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static int32 GSkinCacheMaxDispatchesPerCmdList = 0;
FAutoConsoleVariableRef CVarGPUSkinCacheMaxDispatchesPerCmdList(
	TEXT("r.SkinCache.MaxDispatchesPerCmdList"),
	GSkinCacheMaxDispatchesPerCmdList,
	TEXT("Maximum number of compute shader dispatches which are batched together into a single command list to fix potential TDRs."),
	ECVF_RenderThreadSafe
);

static int32 GSkinCachePrintMemorySummary = 0;
FAutoConsoleVariableRef CVarGPUSkinCachePrintMemorySummary(

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

Scope (from outer to inner):

file
function     void FGPUSkinCache::IncrementDispatchCounter

Source code excerpt:

void FGPUSkinCache::IncrementDispatchCounter(FRHICommandList& RHICmdList)
{
	if (GSkinCacheMaxDispatchesPerCmdList > 0)
	{
		DispatchCounter++;
		if (DispatchCounter >= GSkinCacheMaxDispatchesPerCmdList)
		{
			//UE_LOG(LogSkinCache, Log, TEXT("SubmitCommandsHint issued after %d dispatches"), DispatchCounter);
			RHICmdList.SubmitCommandsHint();
			DispatchCounter = 0;
		}
	}