a.ParallelBlendPhysics
a.ParallelBlendPhysics
#Overview
name: a.ParallelBlendPhysics
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If 1, physics blending will be run across the task graph system. If 0, blending will run purely on the game thread
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of a.ParallelBlendPhysics is to control whether physics blending in Unreal Engine 5 runs across the task graph system or purely on the game thread. This setting variable is primarily used for optimizing the performance of physics simulations in skeletal mesh animations.
The Unreal Engine subsystem that relies on this setting variable is the Physics Engine, specifically the animation system for skeletal meshes. This can be seen from the file location (PhysAnim.cpp) and the function name (BlendInPhysicsInternal) where it’s being used.
The value of this variable is set using a console variable (CVarUseParallelBlendPhysics) with a default value of 1. This means that by default, physics blending will run across the task graph system.
The associated variable CVarUseParallelBlendPhysics interacts directly with a.ParallelBlendPhysics. They share the same value and purpose.
Developers must be aware that:
- Setting this variable to 1 enables parallel physics blending, which can improve performance on multi-core systems.
- Setting it to 0 will force physics blending to run solely on the game thread, which might be useful for debugging or on systems where parallel execution causes issues.
Best practices when using this variable include:
- Leave it at the default value (1) unless there’s a specific reason to change it.
- Consider the target hardware when adjusting this setting. Parallel blending is generally more beneficial on systems with multiple cores.
- Profile the game’s performance with both settings to determine which works best for your specific use case.
Regarding the associated variable CVarUseParallelBlendPhysics:
- It’s a TAutoConsoleVariable
, which means it can be changed at runtime through the console. - It’s used in the BlendInPhysicsInternal function of the USkeletalMeshComponent class.
- The actual usage checks if the variable is non-zero and if threading should be used for performance (FApp::ShouldUseThreadingForPerformance()).
- When enabled, it triggers the creation of a parallel animation evaluation task (FParallelBlendPhysicsTask).
Developers should be aware that changing this variable at runtime could have immediate effects on physics blending performance and behavior. It’s important to test thoroughly if you plan to modify this setting dynamically during gameplay.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysAnim.cpp:391
Scope: file
Source code excerpt:
}
TAutoConsoleVariable<int32> CVarUseParallelBlendPhysics(TEXT("a.ParallelBlendPhysics"), 1, TEXT("If 1, physics blending will be run across the task graph system. If 0, blending will run purely on the game thread"));
void USkeletalMeshComponent::BlendInPhysicsInternal(FTickFunction& ThisTickFunction)
{
check(IsInGameThread());
// Can't do anything without a SkeletalMesh
#Associated Variable and Callsites
This variable is associated with another variable named CVarUseParallelBlendPhysics
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysAnim.cpp:391
Scope: file
Source code excerpt:
}
TAutoConsoleVariable<int32> CVarUseParallelBlendPhysics(TEXT("a.ParallelBlendPhysics"), 1, TEXT("If 1, physics blending will be run across the task graph system. If 0, blending will run purely on the game thread"));
void USkeletalMeshComponent::BlendInPhysicsInternal(FTickFunction& ThisTickFunction)
{
check(IsInGameThread());
// Can't do anything without a SkeletalMesh
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysAnim.cpp:411
Scope (from outer to inner):
file
function void USkeletalMeshComponent::BlendInPhysicsInternal
Source code excerpt:
check(!IsValidRef(ParallelAnimationEvaluationTask));
const bool bParallelBlend = !!CVarUseParallelBlendPhysics.GetValueOnGameThread() && FApp::ShouldUseThreadingForPerformance();
if(bParallelBlend)
{
SwapEvaluationContextBuffers();
ParallelAnimationEvaluationTask = TGraphTask<FParallelBlendPhysicsTask>::CreateTask().ConstructAndDispatchWhenReady(this);