p.Chaos.AxialSpring.ISPC
p.Chaos.AxialSpring.ISPC
#Overview
name: p.Chaos.AxialSpring.ISPC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use ISPC optimizations in AxialSpring constraints
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.AxialSpring.ISPC is to control whether ISPC (Intel SPMD Program Compiler) optimizations are used in AxialSpring constraints within the Chaos physics engine of Unreal Engine 5.
This setting variable is primarily used by the Chaos physics engine, which is part of Unreal Engine’s experimental physics system. It specifically affects the AxialSpring constraints, which are likely used in soft body simulations or other physics-based animations.
The value of this variable is set through a console variable system. It’s initialized to true by default, but can be changed at runtime in non-shipping builds.
The associated variable bChaos_AxialSpring_ISPC_Enabled directly interacts with p.Chaos.AxialSpring.ISPC. They share the same value, with bChaos_AxialSpring_ISPC_Enabled being the C++ boolean variable that the code checks when deciding whether to use ISPC optimizations.
Developers must be aware that:
- This optimization is only available when INTEL_ISPC is defined and the build is not a shipping build.
- The optimization is enabled by default but can be toggled at runtime in development builds.
- The ISPC optimization is used in the Apply function of FPBDAxialSpringConstraints, potentially affecting performance and behavior of physics simulations.
Best practices when using this variable include:
- Test the performance and behavior of your physics simulations with this optimization both enabled and disabled to ensure it provides benefits in your specific use case.
- Be cautious when changing this setting in shipping builds, as it’s designed to be constant in those configurations for performance reasons.
- Ensure that the data structures used in your code are compatible with the ISPC implementations, as there are static assertions checking the size of certain structures.
Regarding the associated variable bChaos_AxialSpring_ISPC_Enabled:
- Its purpose is to provide a C++ accessible boolean that reflects the state of the p.Chaos.AxialSpring.ISPC console variable.
- It’s used directly in the Chaos physics engine code to determine whether to use ISPC optimizations.
- Its value is set by the console variable system and can be changed at runtime in non-shipping builds.
- Developers should be aware that in shipping builds, this variable becomes a constexpr boolean, which allows for compile-time optimizations but prevents runtime toggling.
- Best practice is to use this variable for any runtime checks in your code rather than accessing the console variable directly, as it provides a more efficient and type-safe way to check the optimization state.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDAxialSpringConstraints.cpp:11
Scope: file
Source code excerpt:
#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_AxialSpring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosAxialSpringISPCEnabled(TEXT("p.Chaos.AxialSpring.ISPC"), bChaos_AxialSpring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in AxialSpring constraints"));
static_assert(sizeof(ispc::FVector4f) == sizeof(Chaos::Softs::FPAndInvM), "sizeof(ispc::FVector4f) != sizeof(Chaos::Softs::FPAndInvM");
static_assert(sizeof(ispc::FIntVector) == sizeof(Chaos::TVec3<int32>), "sizeof(ispc::FIntVector) != sizeof(Chaos::TVec3<int32>");
#endif
namespace Chaos::Softs {
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_AxialSpring_ISPC_Enabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDAxialSpringConstraints.cpp:10
Scope: file
Source code excerpt:
#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_AxialSpring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosAxialSpringISPCEnabled(TEXT("p.Chaos.AxialSpring.ISPC"), bChaos_AxialSpring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in AxialSpring constraints"));
static_assert(sizeof(ispc::FVector4f) == sizeof(Chaos::Softs::FPAndInvM), "sizeof(ispc::FVector4f) != sizeof(Chaos::Softs::FPAndInvM");
static_assert(sizeof(ispc::FIntVector) == sizeof(Chaos::TVec3<int32>), "sizeof(ispc::FIntVector) != sizeof(Chaos::TVec3<int32>");
#endif
namespace Chaos::Softs {
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDAxialSpringConstraints.cpp:108
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDAxialSpringConstraints::Apply
Source code excerpt:
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_AxialSpring_ISPC_Enabled)
{
for (int32 ConstraintColorIndex = 0; ConstraintColorIndex < ConstraintColorNum; ++ConstraintColorIndex)
{
const int32 ColorStart = ConstraintsPerColorStartIndex[ConstraintColorIndex];
const int32 ColorSize = ConstraintsPerColorStartIndex[ConstraintColorIndex + 1] - ColorStart;
ispc::ApplyAxialSpringConstraints(
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDAxialSpringConstraints.cpp:141
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDAxialSpringConstraints::Apply
Source code excerpt:
{
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_AxialSpring_ISPC_Enabled)
{
for (int32 ConstraintColorIndex = 0; ConstraintColorIndex < ConstraintColorNum; ++ConstraintColorIndex)
{
const int32 ColorStart = ConstraintsPerColorStartIndex[ConstraintColorIndex];
const int32 ColorSize = ConstraintsPerColorStartIndex[ConstraintColorIndex + 1] - ColorStart;
ispc::ApplyAxialSpringConstraintsWithWeightMaps(
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDAxialSpringConstraints.h:162
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_AxialSpring_ISPC_Enabled = INTEL_ISPC && CHAOS_AXIAL_SPRING_ISPC_ENABLED_DEFAULT;
#else
extern CHAOS_API bool bChaos_AxialSpring_ISPC_Enabled;
#endif