tick.HiPriSkinnedMeshes

tick.HiPriSkinnedMeshes

#Overview

name: tick.HiPriSkinnedMeshes

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of tick.HiPriSkinnedMeshes is to control the scheduling priority of skinned component ticks in the Unreal Engine’s tick system. It is primarily used for performance optimization in the animation and rendering systems.

This setting variable is mainly utilized by the Engine’s SkeletalMeshComponent subsystem, which is responsible for handling skeletal mesh animations and rendering. It’s part of the core Engine module and not associated with any specific plugin.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning high-priority ticking is enabled by default. Developers can change this value at runtime using console commands or through configuration files.

The associated variable CVarHiPriSkinnedMeshesTicks directly interacts with tick.HiPriSkinnedMeshes. They share the same value and purpose.

Developers must be aware that changing this variable affects the order of execution for skinned mesh component updates. When set to a value greater than 0, it schedules the skinned component ticks in a tick group that executes before other ticks, potentially improving performance for animation-heavy scenes.

Best practices when using this variable include:

  1. Profiling the game to determine if high-priority skinned mesh ticking provides a performance benefit.
  2. Being cautious when modifying this value, as it can affect the execution order of other systems that may depend on skinned mesh updates.
  3. Using it in conjunction with other animation and rendering optimizations for best results.

Regarding the associated variable CVarHiPriSkinnedMeshesTicks:

The purpose of CVarHiPriSkinnedMeshesTicks is to provide a programmatic interface to the tick.HiPriSkinnedMeshes setting. It’s used within the C++ code to read and apply the setting’s value.

This variable is used in the Engine’s SkeletalMeshComponent system, specifically in the registration and execution of component tick functions.

The value of CVarHiPriSkinnedMeshesTicks is set through the CVar system, mirroring tick.HiPriSkinnedMeshes.

It directly interacts with the PrimaryComponentTick of SkeletalMeshComponent, setting its priority based on the variable’s value.

Developers should be aware that this variable is used to determine the tick priority at runtime, and changes to it will affect the scheduling of skinned mesh updates.

Best practices include:

  1. Accessing the value using GetValueOnGameThread() to ensure thread-safe operations.
  2. Considering the impact on overall game performance when modifying this value, as it affects the execution order of component ticks.
  3. Using this in conjunction with profiling tools to optimize animation and rendering performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkeletalMeshComponent.cpp:63

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarHiPriSkinnedMeshesTicks(
	TEXT("tick.HiPriSkinnedMeshes"),
	1,
	TEXT("If > 0, then schedule the skinned component ticks in a tick group before other ticks."));

// Deprecated. Please switch to ANIM_SKINNED_ASSET_ISPC_ENABLED_DEFAULT and "a.SkinnedAsset.ISPC", see SkinnedAsset.cpp.
#if !defined(ANIM_SKELETAL_MESH_ISPC_ENABLED_DEFAULT)
#define ANIM_SKELETAL_MESH_ISPC_ENABLED_DEFAULT 1

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkeletalMeshComponent.cpp:62

Scope: file

Source code excerpt:

	TEXT("Sleep for the given time in each parallel animation task. Time is given in ms. This is a debug option used for critical path analysis and forcing a change in the critical path."));

static TAutoConsoleVariable<int32> CVarHiPriSkinnedMeshesTicks(
	TEXT("tick.HiPriSkinnedMeshes"),
	1,
	TEXT("If > 0, then schedule the skinned component ticks in a tick group before other ticks."));

// Deprecated. Please switch to ANIM_SKINNED_ASSET_ISPC_ENABLED_DEFAULT and "a.SkinnedAsset.ISPC", see SkinnedAsset.cpp.
#if !defined(ANIM_SKELETAL_MESH_ISPC_ENABLED_DEFAULT)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkeletalMeshComponent.cpp:494

Scope (from outer to inner):

file
function     void USkeletalMeshComponent::RegisterComponentTickFunctions

Source code excerpt:

{
	Super::RegisterComponentTickFunctions(bRegister);
	const bool bDoHiPri = CVarHiPriSkinnedMeshesTicks.GetValueOnGameThread() > 0;
	if (PrimaryComponentTick.bHighPriority != bDoHiPri)
	{
		// Note that if animation is so long that we are blocked in EndPhysics we may want to reduce the priority. However, there is a risk that this function will not go wide early enough.
		// This requires profiling and is very game dependent so cvar for now makes sense
		PrimaryComponentTick.SetPriorityIncludingPrerequisites(bDoHiPri);
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SkeletalMeshComponent.cpp:1727

Scope (from outer to inner):

file
function     void USkeletalMeshComponent::TickComponent

Source code excerpt:

		ThisTickFunction->EndTickGroup = EndTickGroup;

		const bool bDoHiPri = CVarHiPriSkinnedMeshesTicks.GetValueOnGameThread() > 0;
		check(PrimaryComponentTick.bHighPriority == bDoHiPri)
	}

	// If we are waiting for ParallelEval to complete or if we require Physics, 
	// then FinalizeBoneTransform will be called and Anim events will be dispatched there. 
	// We prefer doing it there so these events are triggered once we have a new updated pose.