p.Chaos.XPBDSpring.ISPC
p.Chaos.XPBDSpring.ISPC
#Overview
name: p.Chaos.XPBDSpring.ISPC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use ISPC optimizations in XPBD Spring constraints
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.XPBDSpring.ISPC is to control whether ISPC (Intel SPMD Program Compiler) optimizations are used in XPBD (Extended Position Based Dynamics) Spring constraints within the Chaos physics system of Unreal Engine 5.
This setting variable is primarily used in the Chaos physics system, specifically for the XPBD Spring constraints. It’s part of the experimental Chaos module, which is a physics simulation system in Unreal Engine 5.
The value of this variable is set through a console variable (CVar) named “p.Chaos.XPBDSpring.ISPC”. It’s initialized to true by default in the C++ code.
The associated variable bChaos_XPBDSpring_ISPC_Enabled directly interacts with p.Chaos.XPBDSpring.ISPC. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable controls performance optimizations. Enabling it (which is the default) allows the use of ISPC optimizations, potentially improving performance for XPBD Spring constraints calculations. However, it’s only effective when INTEL_ISPC is defined and the real type is compatible with ISPC.
Best practices when using this variable include:
- Leave it enabled by default for better performance.
- Consider disabling it for debugging purposes or if encountering unexpected behavior in XPBD Spring constraints.
- Be aware that its effect is conditional on INTEL_ISPC being defined and the real type being compatible with ISPC.
Regarding the associated variable bChaos_XPBDSpring_ISPC_Enabled:
The purpose of bChaos_XPBDSpring_ISPC_Enabled is the same as p.Chaos.XPBDSpring.ISPC - to control ISPC optimizations in XPBD Spring constraints.
It’s used in the Chaos physics system, specifically in the XPBDAnisotropicSpringConstraints and XPBDSpringConstraints components.
The value is set through the console variable p.Chaos.XPBDSpring.ISPC and is initialized to true by default.
This variable directly interacts with p.Chaos.XPBDSpring.ISPC, sharing the same value.
Developers should be aware that this variable is used in conditional statements to determine whether to use ISPC-optimized code paths. It’s also defined differently based on the build configuration (shipping vs. non-shipping) and whether INTEL_ISPC is defined.
Best practices include using this variable consistently with p.Chaos.XPBDSpring.ISPC and being aware of its behavior in different build configurations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDSpringConstraints.cpp:22
Scope: file
Source code excerpt:
bool bChaos_XPBDSpring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosXPBDSpringISPCEnabled(TEXT("p.Chaos.XPBDSpring.ISPC"), bChaos_XPBDSpring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in XPBD Spring constraints"));
#endif
namespace Chaos::Softs {
// @todo(chaos): the parallel threshold (or decision to run parallel) should probably be owned by the solver and passed to the constraint container
int32 Chaos_XPBDSpring_ParallelConstraintCount = 100;
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_XPBDSpring_ISPC_Enabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDAnisotropicSpringConstraints.cpp:371
Scope (from outer to inner):
file
function void FXPBDAnisotropicEdgeSpringConstraints::Apply
Source code excerpt:
const int32 ConstraintColorNum = ConstraintsPerColorStartIndex.Num() - 1;
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_XPBDSpring_ISPC_Enabled)
{
const bool bSingleLambda = Chaos_XPBDSpring_SplitDampingMode == (int32)EXPBDSplitDampingMode::SingleLambda;
if (!StiffnessHasWeightMap && !StiffnessWeftHasWeightMap && !StiffnessBiasHasWeightMap && !DampingHasWeightMap)
{
const FSolverVec3 ExpStiffnessValue((FSolverReal)StiffnessWeft, (FSolverReal)StiffnessWarp, (FSolverReal)StiffnessBias);
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDAnisotropicSpringConstraints.cpp:1264
Scope (from outer to inner):
file
function void FXPBDAnisotropicAxialSpringConstraints::InitColor
function void FXPBDAnisotropicAxialSpringConstraints::Apply
Source code excerpt:
const int32 ConstraintColorNum = ConstraintsPerColorStartIndex.Num() - 1;
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_XPBDSpring_ISPC_Enabled)
{
const bool bSingleLambda = Chaos_XPBDSpring_SplitDampingMode == (int32)EXPBDSplitDampingMode::SingleLambda;
if (!StiffnessHasWeightMap && !StiffnessWeftHasWeightMap && !StiffnessBiasHasWeightMap && !DampingHasWeightMap)
{
const FSolverVec3 ExpStiffnessValue((FSolverReal)StiffnessWeft, (FSolverReal)StiffnessWarp, (FSolverReal)StiffnessBias);
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDSpringConstraints.cpp:21
Scope: file
Source code excerpt:
static_assert(sizeof(ispc::FIntVector2) == sizeof(Chaos::TVec2<int32>), "sizeof(ispc::FIntVector2) != sizeof(Chaos::TVec2<int32>)");
bool bChaos_XPBDSpring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosXPBDSpringISPCEnabled(TEXT("p.Chaos.XPBDSpring.ISPC"), bChaos_XPBDSpring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in XPBD Spring constraints"));
#endif
namespace Chaos::Softs {
// @todo(chaos): the parallel threshold (or decision to run parallel) should probably be owned by the solver and passed to the constraint container
int32 Chaos_XPBDSpring_ParallelConstraintCount = 100;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDSpringConstraints.cpp:130
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FXPBDSpringConstraints::Apply
Source code excerpt:
const int32 ConstraintColorNum = ConstraintsPerColorStartIndex.Num() - 1;
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_XPBDSpring_ISPC_Enabled)
{
const bool bSingleLambda = Chaos_XPBDSpring_SplitDampingMode == (int32)EXPBDSplitDampingMode::SingleLambda;
if (!StiffnessHasWeightMap && !DampingHasWeightMap)
{
const FSolverReal ExpStiffnessValue = (FSolverReal)Stiffness;
const FSolverReal DampingRatioValue = (FSolverReal)DampingRatio;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/XPBDSpringConstraints.h:489
Scope: file
Source code excerpt:
// Support ISPC enable/disable in non-shipping builds
#if !INTEL_ISPC
const bool bChaos_XPBDSpring_ISPC_Enabled = false;
#elif UE_BUILD_SHIPPING
const bool bChaos_XPBDSpring_ISPC_Enabled = true;
#else
extern CHAOS_API bool bChaos_XPBDSpring_ISPC_Enabled;
#endif