p.Chaos.Spherical.ISPC

p.Chaos.Spherical.ISPC

#Overview

name: p.Chaos.Spherical.ISPC

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

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

This setting variable is primarily used by the Chaos physics system, which is part of Unreal Engine’s experimental physics framework. Specifically, it’s used in the implementation of spherical constraints for soft body simulations.

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 through the console or configuration files.

The associated variable bChaos_Spherical_ISPC_Enabled directly interacts with p.Chaos.Spherical.ISPC. They share the same value, with bChaos_Spherical_ISPC_Enabled being the actual boolean variable used in the code to control the ISPC optimization.

Developers must be aware of several things when using this variable:

  1. It’s only effective when INTEL_ISPC is defined and the build configuration is not shipping.
  2. It affects the performance and potentially the behavior of spherical constraints in soft body simulations.
  3. The variable is used in both FPBDSphericalConstraint and FPBDSphericalBackstopConstraint classes.

Best practices when using this variable include:

  1. Test the performance with both enabled and disabled states to determine the optimal setting for your specific use case.
  2. Be aware that changing this setting might affect the consistency of physics simulations across different hardware.
  3. Consider leaving it enabled by default unless specific issues are encountered.

Regarding the associated variable bChaos_Spherical_ISPC_Enabled:

This is the actual boolean variable used in the code to control ISPC optimization for spherical constraints. It’s defined differently based on the build configuration:

The variable is used in conditional statements to determine whether to use ISPC-optimized functions (ApplyHelperISPC, ApplyLegacyHelperISPC) or fallback implementations. This allows for runtime toggling of ISPC optimizations in supported configurations, which can be useful for performance testing and debugging.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_Spherical_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosSphericalISPCEnabled(TEXT("p.Chaos.Spherical.ISPC"), bChaos_Spherical_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in spherical constraints"));

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

namespace Chaos::Softs {

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_Spherical_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosSphericalISPCEnabled(TEXT("p.Chaos.Spherical.ISPC"), bChaos_Spherical_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in spherical constraints"));

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

namespace Chaos::Softs {

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDSphericalConstraint.h:19

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_Spherical_ISPC_Enabled = INTEL_ISPC && CHAOS_SPHERICAL_ISPC_ENABLED_DEFAULT;
#else
extern CHAOS_API bool bChaos_Spherical_ISPC_Enabled;
#endif

namespace Chaos::Softs
{

class FPBDSphericalConstraint final

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDSphericalConstraint.h:108

Scope (from outer to inner):

file
namespace    Chaos::Softs
class        class FPBDSphericalConstraint final
function     void Apply

Source code excerpt:

		SCOPE_CYCLE_COUNTER(STAT_PBD_Spherical);

		if (bRealTypeCompatibleWithISPC && bChaos_Spherical_ISPC_Enabled)
		{
			ApplyHelperISPC(Particles, Dt);
		}
		else
		{
			if (SphereRadii.Num() == ParticleCount)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDSphericalConstraint.h:310

Scope (from outer to inner):

file
namespace    Chaos::Softs
class        class FPBDSphericalBackstopConstraint final
function     void Apply

Source code excerpt:

				// This is harder to author, and does not follow the NvCloth specs.
				// However, this is how it's been done in the Unreal Engine PhysX cloth implementation.
				if (bRealTypeCompatibleWithISPC && bChaos_Spherical_ISPC_Enabled)
				{
					ApplyLegacyHelperISPC(Particles, Dt);
				}
				else if (SphereRadii.Num() == ParticleCount)
				{
					if (SphereOffsetDistances.Num() == ParticleCount)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDSphericalConstraint.h:345

Scope (from outer to inner):

file
namespace    Chaos::Softs
class        class FPBDSphericalBackstopConstraint final
function     void Apply

Source code excerpt:

			{
				// SphereOffsetDistances doesn't include the sphere radius
				if (bRealTypeCompatibleWithISPC && bChaos_Spherical_ISPC_Enabled)
				{
					ApplyHelperISPC(Particles, Dt);
				}
				else if (SphereRadii.Num() == ParticleCount)
				{
					if (SphereOffsetDistances.Num() == ParticleCount)