p.Chaos.XPBDBending.ISPC

p.Chaos.XPBDBending.ISPC

#Overview

name: p.Chaos.XPBDBending.ISPC

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 p.Chaos.XPBDBending.ISPC is to control whether ISPC (Intel SPMD Program Compiler) optimizations are used in XPBD (Extended Position Based Dynamics) Bending constraints within the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used by the Chaos physics system, specifically in the XPBD Bending constraints module. It’s part of the experimental Chaos namespace, indicating it’s a feature that may still be in development or testing.

The value of this variable is set through a console variable (CVar) system. It’s initialized to true by default but can be changed at runtime through the console or configuration files.

The associated variable bChaos_XPBDBending_ISPC_Enabled directly interacts with p.Chaos.XPBDBending.ISPC. They share the same value and are used interchangeably in the code.

Developers should be aware that:

  1. This optimization is only available when INTEL_ISPC is defined and the build is not a shipping build.
  2. The optimization affects the performance of XPBD Bending constraints calculations.
  3. It’s part of the experimental Chaos namespace, so its behavior or availability might change in future versions.

Best practices when using this variable include:

  1. Test the performance with and without ISPC optimizations to ensure it provides benefits for your specific use case.
  2. Be cautious when using it in production builds, as it’s marked as experimental.
  3. Keep in mind that it might not be available or have an effect in shipping builds.

Regarding the associated variable bChaos_XPBDBending_ISPC_Enabled:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDBendingConstraints.cpp:11

Scope: file

Source code excerpt:

#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_XPBDBending_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosXPBDBendingISPCEnabled(TEXT("p.Chaos.XPBDBending.ISPC"), bChaos_XPBDBending_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in XPBD Bending constraints"));

static_assert(sizeof(ispc::FVector4f) == sizeof(Chaos::Softs::FPAndInvM), "sizeof(ispc::FVector4f) != sizeof(Chaos::Softs::FPAndInvM");
static_assert(sizeof(ispc::FVector3f) == sizeof(Chaos::Softs::FSolverVec3), "sizeof(ispc::FVector3f) != sizeof(Chaos::Softs::FSolverVec3");
static_assert(sizeof(ispc::FVector2f) == sizeof(Chaos::Softs::FSolverVec2), "sizeof(ispc::FVector2f) != sizeof(Chaos::Softs::FSolverVec2");
#endif

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDAnisotropicBendingConstraints.cpp:669

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FXPBDAnisotropicBendingConstraints::InitColor
function     void FXPBDAnisotropicBendingConstraints::Apply

Source code excerpt:

		const int32 ConstraintColorNum = ConstraintsPerColorStartIndex.Num() - 1;
#if INTEL_ISPC
		if (bRealTypeCompatibleWithISPC && bChaos_XPBDBending_ISPC_Enabled)
		{
			if (!StiffnessHasWeightMap && !StiffnessWeftHasWeightMap && !StiffnessBiasHasWeightMap &&
				!BucklingStiffnessHasWeightMap && !BucklingStiffnessWeftHasWeightMap && !BucklingStiffnessBiasHasWeightMap &&
				!DampingHasWeightMap)
			{
				const FSolverVec3 ExpStiffnessValue((FSolverReal)StiffnessWeft, (FSolverReal)StiffnessWarp, (FSolverReal)StiffnessBias);

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDBendingConstraints.cpp:10

Scope: file

Source code excerpt:


#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_XPBDBending_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosXPBDBendingISPCEnabled(TEXT("p.Chaos.XPBDBending.ISPC"), bChaos_XPBDBending_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in XPBD Bending constraints"));

static_assert(sizeof(ispc::FVector4f) == sizeof(Chaos::Softs::FPAndInvM), "sizeof(ispc::FVector4f) != sizeof(Chaos::Softs::FPAndInvM");
static_assert(sizeof(ispc::FVector3f) == sizeof(Chaos::Softs::FSolverVec3), "sizeof(ispc::FVector3f) != sizeof(Chaos::Softs::FSolverVec3");
static_assert(sizeof(ispc::FVector2f) == sizeof(Chaos::Softs::FSolverVec2), "sizeof(ispc::FVector2f) != sizeof(Chaos::Softs::FSolverVec2");
#endif

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDBendingConstraints.cpp:252

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FXPBDBendingConstraints::InitColor
function     void FXPBDBendingConstraints::Apply

Source code excerpt:


#if INTEL_ISPC
		if (bRealTypeCompatibleWithISPC && bChaos_XPBDBending_ISPC_Enabled)
		{
			if (!StiffnessHasWeightMap && !BucklingStiffnessHasWeightMap && !DampingHasWeightMap)
			{
				const FSolverReal ExpStiffnessValue = (FSolverReal)XPBDStiffness;
				const FSolverReal ExpBucklingValue = (FSolverReal)XPBDBucklingStiffness;
				const FSolverReal DampingRatioValue = (FSolverReal)DampingRatio;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/XPBDBendingConstraints.h:453

Scope: file

Source code excerpt:

// Support ISPC enable/disable in non-shipping builds
#if !INTEL_ISPC
const bool bChaos_XPBDBending_ISPC_Enabled = false;
#elif UE_BUILD_SHIPPING
const bool bChaos_XPBDBending_ISPC_Enabled = true;
#else
extern CHAOS_API bool bChaos_XPBDBending_ISPC_Enabled;
#endif