p.Chaos.PreSubstepInterpolation.ISPC

p.Chaos.PreSubstepInterpolation.ISPC

#Overview

name: p.Chaos.PreSubstepInterpolation.ISPC

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.PreSubstepInterpolation.ISPC is to enable or disable ISPC (Intel SPMD Program Compiler) optimization for the pre-substep interpolation process in the Chaos Cloth simulation system of Unreal Engine 5.

This setting variable is primarily used in the Chaos Cloth simulation system, which is part of the ChaosCloth plugin in Unreal Engine 5. It specifically affects the pre-substep interpolation process, which is a crucial step in cloth simulation.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands. It is initially set to the value of CHAOS_PRE_SUBSTEP_INTERPOLATION_ISPC_ENABLED_DEFAULT.

This variable interacts closely with bChaos_PreSubstepInterpolation_ISPC_Enabled, which is the actual boolean flag used in the code to determine whether ISPC optimization should be applied.

Developers must be aware that this optimization is only applicable when using ISPC and when the real type (floating-point representation) is compatible with ISPC. The code checks for both INTEL_ISPC and bRealTypeCompatibleWithISPC before applying the optimization.

Best practices when using this variable include:

  1. Ensure that ISPC is properly set up in your project if you intend to use this optimization.
  2. Test performance with and without this optimization enabled to determine if it benefits your specific use case.
  3. Be aware that enabling this optimization might affect the precision or behavior of the cloth simulation, so thorough testing is recommended.

Regarding the associated variable bChaos_PreSubstepInterpolation_ISPC_Enabled:

This is the actual boolean flag used in the code to determine whether ISPC optimization should be applied for pre-substep interpolation. It is set based on the console variable p.Chaos.PreSubstepInterpolation.ISPC.

It is used in the PreSubstep function of the FClothingSimulationSolver class to conditionally apply ISPC-optimized code for interpolation calculations. This optimization can potentially improve performance, especially on Intel processors that support ISPC.

Developers should be aware that this flag is checked in combination with bRealTypeCompatibleWithISPC, ensuring that the optimization is only applied when appropriate. When using this variable, ensure that your project’s build settings support ISPC if you intend to take advantage of this optimization.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:40

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarChaosCalculateBoundsISPCEnabled(TEXT("p.Chaos.CalculateBounds.ISPC"), bChaos_CalculateBounds_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in CalculateBounds"));
bool bChaos_PreSubstepInterpolation_ISPC_Enabled = CHAOS_PRE_SUBSTEP_INTERPOLATION_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosPreSubstepInterpolationISPCEnabled(TEXT("p.Chaos.PreSubstepInterpolation.ISPC"), bChaos_PreSubstepInterpolation_ISPC_Enabled, TEXT("Whether to use ISPC optimization in PreSubstep"));

static_assert(sizeof(ispc::FVector3f) == sizeof(Chaos::Softs::FSolverVec3), "sizeof(ispc::FVector) != sizeof(Chaos::Softs::FSolverVec3)");
static_assert(sizeof(ispc::FTransform3f) == sizeof(Chaos::Softs::FSolverRigidTransform3), "sizeof(ispc::FVector) != sizeof(Chaos::Softs::FSolverRigidTransform3)");
#endif

namespace Chaos

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:39

Scope: file

Source code excerpt:

bool bChaos_CalculateBounds_ISPC_Enabled = CHAOS_CALCULATE_BOUNDS_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosCalculateBoundsISPCEnabled(TEXT("p.Chaos.CalculateBounds.ISPC"), bChaos_CalculateBounds_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in CalculateBounds"));
bool bChaos_PreSubstepInterpolation_ISPC_Enabled = CHAOS_PRE_SUBSTEP_INTERPOLATION_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosPreSubstepInterpolationISPCEnabled(TEXT("p.Chaos.PreSubstepInterpolation.ISPC"), bChaos_PreSubstepInterpolation_ISPC_Enabled, TEXT("Whether to use ISPC optimization in PreSubstep"));

static_assert(sizeof(ispc::FVector3f) == sizeof(Chaos::Softs::FSolverVec3), "sizeof(ispc::FVector) != sizeof(Chaos::Softs::FSolverVec3)");
static_assert(sizeof(ispc::FTransform3f) == sizeof(Chaos::Softs::FSolverRigidTransform3), "sizeof(ispc::FVector) != sizeof(Chaos::Softs::FSolverRigidTransform3)");
#endif

namespace Chaos

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:1729

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothingSimulationSolver::PreSubstep
lambda-function

Source code excerpt:

				GetClothConstraints(SoftBodyId).SetSkipSelfCollisionInit(!bDetectSelfCollisions);
#if INTEL_ISPC
				if (bRealTypeCompatibleWithISPC && bChaos_PreSubstepInterpolation_ISPC_Enabled)  // TODO: Make the ISPC works with both Single and Double depending on the FSolverReal type
				{
					ispc::PreSubstepInterpolation(
						(ispc::FVector3f*)Particles.GetArrayView(InterpolatedAnimationPositions).GetData(),
						(ispc::FVector3f*)Particles.GetArrayView(InterpolatedAnimationNormals).GetData(),
						(const ispc::FVector3f*)Particles.GetConstArrayView(AnimationPositions).GetData(),
						(const ispc::FVector3f*)Particles.GetConstArrayView(OldAnimationPositions).GetData(),

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:1785

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothingSimulationSolver::PreSubstep
lambda-function

Source code excerpt:

	
#if INTEL_ISPC
			if (bRealTypeCompatibleWithISPC && bChaos_PreSubstepInterpolation_ISPC_Enabled)  // TODO: Make the ISPC works with both Single and Double depending on the FSolverReal type
			{
				ispc::PreSubstepInterpolation(
					(ispc::FVector3f*)InterpolatedAnimationPositions.GetData(),
					(ispc::FVector3f*)InterpolatedAnimationNormals.GetData(),
					(const ispc::FVector3f*)AnimationPositions.GetData(),
					(const ispc::FVector3f*)OldAnimationPositions.GetData(),

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Public/ChaosCloth/ChaosClothingSimulationSolver.h:478

Scope: file

Source code excerpt:

static constexpr bool bChaos_CalculateBounds_ISPC_Enabled = INTEL_ISPC && CHAOS_CALCULATE_BOUNDS_ISPC_ENABLED_DEFAULT;
static constexpr bool bChaos_PreSimulationTransforms_ISPC_Enabled = INTEL_ISPC && CHAOS_PRE_SIMULATION_TRANSFORMS_ISPC_ENABLED_DEFAULT;
static constexpr bool bChaos_PreSubstepInterpolation_ISPC_Enabled = INTEL_ISPC && CHAOS_PRE_SUBSTEP_INTERPOLATION_ISPC_ENABLED_DEFAULT;
#else
extern bool bChaos_PreSimulationTransforms_ISPC_Enabled;
extern bool bChaos_CalculateBounds_ISPC_Enabled;
extern bool bChaos_PreSubstepInterpolation_ISPC_Enabled;
#endif