p.Chaos.Spring.ISPC
p.Chaos.Spring.ISPC
#Overview
name: p.Chaos.Spring.ISPC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use ISPC optimizations in Spring constraints
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Spring.ISPC is to control whether ISPC (Intel SPMD Program Compiler) optimizations are used in Spring constraints within the Chaos physics system of Unreal Engine 5.
This setting variable is primarily used by the Chaos physics system, specifically for the Spring constraints module. It’s part of the experimental Chaos namespace, indicating it’s a feature of the new physics engine in Unreal Engine 5.
The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It’s initialized to true by default, enabling ISPC optimizations.
The associated variable bChaos_Spring_ISPC_Enabled directly interacts with p.Chaos.Spring.ISPC. They share the same value, with bChaos_Spring_ISPC_Enabled being the actual boolean variable used in the code to check if ISPC optimizations should be applied.
Developers should be aware that this optimization is platform-dependent and may not be available on all systems. The code checks for INTEL_ISPC define and bRealTypeCompatibleWithISPC before applying ISPC optimizations.
Best practices when using this variable include:
- Ensure it’s only enabled on platforms that support ISPC.
- Test performance with and without ISPC optimizations to ensure it provides benefits for your specific use case.
- Be cautious when modifying this setting in shipping builds, as it’s conditionally compiled out in those configurations.
Regarding the associated variable bChaos_Spring_ISPC_Enabled:
- Its purpose is to provide a runtime-accessible boolean flag for the ISPC optimization setting.
- It’s used directly in the Chaos::Softs namespace, specifically in the FPBDSpringConstraints::Apply function.
- Its value is set by the p.Chaos.Spring.ISPC console variable.
- It interacts with platform-specific code (INTEL_ISPC) and type compatibility checks (bRealTypeCompatibleWithISPC).
- Developers should be aware that in shipping builds or on platforms without ISPC support, this variable becomes a compile-time constant.
- Best practices include using this variable for runtime checks and performance profiling in debug and development builds.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDSpringConstraints.cpp:19
Scope: file
Source code excerpt:
bool bChaos_Spring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosSpringISPCEnabled(TEXT("p.Chaos.Spring.ISPC"), bChaos_Spring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in 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
static int32 Chaos_Spring_ParallelConstraintCount = 100;
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_Spring_ISPC_Enabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDSpringConstraints.cpp:18
Scope: file
Source code excerpt:
static_assert(sizeof(ispc::FIntVector2) == sizeof(Chaos::TVec2<int32>), "sizeof(ispc::FIntVector2) != sizeof(Chaos::TVec2<int32>)");
bool bChaos_Spring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosSpringISPCEnabled(TEXT("p.Chaos.Spring.ISPC"), bChaos_Spring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in 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
static int32 Chaos_Spring_ParallelConstraintCount = 100;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDSpringConstraints.cpp:104
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDSpringConstraints::Apply
Source code excerpt:
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_Spring_ISPC_Enabled)
{
for (int32 ConstraintColorIndex = 0; ConstraintColorIndex < ConstraintColorNum; ++ConstraintColorIndex)
{
const int32 ColorStart = ConstraintsPerColorStartIndex[ConstraintColorIndex];
const int32 ColorSize = ConstraintsPerColorStartIndex[ConstraintColorIndex + 1] - ColorStart;
ispc::ApplySpringConstraints(
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDSpringConstraints.cpp:136
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDSpringConstraints::Apply
Source code excerpt:
{
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_Spring_ISPC_Enabled)
{
for (int32 ConstraintColorIndex = 0; ConstraintColorIndex < ConstraintColorNum; ++ConstraintColorIndex)
{
const int32 ColorStart = ConstraintsPerColorStartIndex[ConstraintColorIndex];
const int32 ColorSize = ConstraintsPerColorStartIndex[ConstraintColorIndex + 1] - ColorStart;
ispc::ApplySpringConstraintsWithWeightMaps(
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDSpringConstraints.h:242
Scope: file
Source code excerpt:
// Support run-time toggling on supported platforms in non-shipping configurations
#if !INTEL_ISPC || UE_BUILD_SHIPPING
static constexpr bool bChaos_Spring_ISPC_Enabled = INTEL_ISPC && CHAOS_SPRING_ISPC_ENABLED_DEFAULT;
#else
extern CHAOS_API bool bChaos_Spring_ISPC_Enabled;
#endif