p.Chaos.CollisionSpring.ISPC

p.Chaos.CollisionSpring.ISPC

#Overview

name: p.Chaos.CollisionSpring.ISPC

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.CollisionSpring.ISPC is to control whether ISPC (Intel SPMD Program Compiler) optimizations are used in collision spring constraints within the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used by the Chaos physics system, specifically in the collision spring constraints module. It’s part of the Experimental Chaos runtime, which is an advanced physics simulation system 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, meaning ISPC optimizations are enabled out of the box.

The associated variable bChaos_CollisionSpring_ISPC_Enabled directly interacts with p.Chaos.CollisionSpring.ISPC. They share the same value, with bChaos_CollisionSpring_ISPC_Enabled being used in the actual code logic.

Developers must be aware that this variable affects performance optimization. When enabled, it uses ISPC to potentially improve the performance of collision spring constraint calculations. However, it’s only effective when INTEL_ISPC is defined and the build is not a shipping build (except in shipping builds, where it’s always enabled if INTEL_ISPC is defined).

Best practices when using this variable include:

  1. Leave it enabled by default for potential performance benefits.
  2. If experiencing issues specifically related to collision spring constraints, consider disabling it for debugging purposes.
  3. Profile your game with this option both enabled and disabled to understand its impact on your specific use case.
  4. Be aware that changing this setting might affect the behavior of physics simulations, so thorough testing is recommended after changes.

Regarding the associated variable bChaos_CollisionSpring_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/PBDCollisionSpringConstraintsBase.cpp:21

Scope: file

Source code excerpt:


bool bChaos_CollisionSpring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosCollisionSpringsISPCEnabled(TEXT("p.Chaos.CollisionSpring.ISPC"), bChaos_CollisionSpring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in collision spring constraints"));
#endif

#if UE_BUILD_SHIPPING
static constexpr Chaos::Softs::FSolverReal KinematicColliderMaxTimer = (Chaos::Softs::FSolverReal)0.1f;
static constexpr Chaos::Softs::FSolverReal KinematicColliderFalloffMultiplier = (Chaos::Softs::FSolverReal)1.f;
static constexpr Chaos::Softs::FSolverReal KinematicColliderMaxDepthMultiplier = (Chaos::Softs::FSolverReal)10.f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionSpringConstraintsBase.cpp:20

Scope: file

Source code excerpt:

static_assert(sizeof(ispc::FIntVector) == sizeof(Chaos::TVec3<int32>), "sizeof(ispc::FIntVector) != sizeof(Chaos::TVec3<int32>");

bool bChaos_CollisionSpring_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosCollisionSpringsISPCEnabled(TEXT("p.Chaos.CollisionSpring.ISPC"), bChaos_CollisionSpring_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in collision spring constraints"));
#endif

#if UE_BUILD_SHIPPING
static constexpr Chaos::Softs::FSolverReal KinematicColliderMaxTimer = (Chaos::Softs::FSolverReal)0.1f;
static constexpr Chaos::Softs::FSolverReal KinematicColliderFalloffMultiplier = (Chaos::Softs::FSolverReal)1.f;
static constexpr Chaos::Softs::FSolverReal KinematicColliderMaxDepthMultiplier = (Chaos::Softs::FSolverReal)10.f;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionSpringConstraintsBase.cpp:694

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FPBDCollisionSpringConstraintsBase::ApplyKinematicConstraints

Source code excerpt:

#if INTEL_ISPC
	static_assert(sizeof(ispc::FIntVector) == sizeof(TVector<int32, MaxKinematicConnectionsPerPoint>), "sizeof(ispc::FIntVector) != sizeof(TVector<int32, MaxKinematicConnectionsPerPoint>)");
	if (bRealTypeCompatibleWithISPC && bChaos_CollisionSpring_ISPC_Enabled)
	{
		if (ThicknessWeighted.HasWeightMap())
		{
			ispc::ApplyKinematicCollisionSpringConstraintsWithMaps(
				(ispc::FVector4f*)Particles.GetPAndInvM().GetData(),
				(const ispc::FVector3f*)Particles.XArray().GetData(),

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDCollisionSpringConstraintsBase.h:252

Scope: file

Source code excerpt:

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


#endif