p.Chaos.GetSimData.ISPC
p.Chaos.GetSimData.ISPC
#Overview
name: p.Chaos.GetSimData.ISPC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use ISPC optimizations when getting simulation data
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.GetSimData.ISPC is to control whether to use ISPC (Intel SPMD Program Compiler) optimizations when getting simulation data in the Chaos Cloth simulation system.
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 performance optimization of retrieving simulation data.
The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be changed at runtime through the console. It’s initialized to true by default.
The associated variable bChaos_GetSimData_ISPC_Enabled directly interacts with p.Chaos.GetSimData.ISPC. They share the same value and are used interchangeably in the code.
Developers must be aware that this optimization is only available when INTEL_ISPC is defined and enabled. In shipping builds, this variable becomes a compile-time constant for performance reasons.
Best practices when using this variable include:
- Only enable it when ISPC support is available on the target platform.
- Consider the performance impact and test thoroughly when enabling or disabling this optimization.
- Be aware that changing this value at runtime may affect performance but not functionality.
Regarding the associated variable bChaos_GetSimData_ISPC_Enabled:
- It’s used as the actual boolean flag in the code to check whether ISPC optimizations should be used.
- In non-shipping builds on supported platforms, it can be toggled at runtime.
- In shipping builds or on unsupported platforms, it becomes a compile-time constant.
- It’s used in conditional compilation blocks to include or exclude ISPC-optimized code paths.
Developers should ensure that the ISPC-optimized code path is properly maintained and tested alongside the non-optimized path to prevent divergent behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulation.cpp:50
Scope: file
Source code excerpt:
bool bChaos_GetSimData_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosGetSimDataISPCEnabled(TEXT("p.Chaos.GetSimData.ISPC"), bChaos_GetSimData_ISPC_Enabled, TEXT("Whether to use ISPC optimizations when getting simulation data"));
#endif
DECLARE_CYCLE_STAT(TEXT("Chaos Cloth Simulate"), STAT_ChaosClothSimulate, STATGROUP_ChaosCloth);
DECLARE_CYCLE_STAT(TEXT("Chaos Cloth Create Actor"), STAT_ChaosClothCreateActor, STATGROUP_ChaosCloth);
DECLARE_CYCLE_STAT(TEXT("Chaos Cloth Get Simulation Data"), STAT_ChaosClothGetSimulationData, STATGROUP_ChaosCloth);
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_GetSimData_ISPC_Enabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulation.cpp:49
Scope: file
Source code excerpt:
static_assert(sizeof(ispc::FTransform) == sizeof(Chaos::FRigidTransform3), "sizeof(ispc::FTransform) != sizeof(Chaos::FRigidTransform3)");
bool bChaos_GetSimData_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosGetSimDataISPCEnabled(TEXT("p.Chaos.GetSimData.ISPC"), bChaos_GetSimData_ISPC_Enabled, TEXT("Whether to use ISPC optimizations when getting simulation data"));
#endif
DECLARE_CYCLE_STAT(TEXT("Chaos Cloth Simulate"), STAT_ChaosClothSimulate, STATGROUP_ChaosCloth);
DECLARE_CYCLE_STAT(TEXT("Chaos Cloth Create Actor"), STAT_ChaosClothCreateActor, STATGROUP_ChaosCloth);
DECLARE_CYCLE_STAT(TEXT("Chaos Cloth Get Simulation Data"), STAT_ChaosClothGetSimulationData, STATGROUP_ChaosCloth);
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulation.cpp:686
Scope (from outer to inner):
file
function void FClothingSimulation::Simulate
function void FClothingSimulation::GetSimulationData
Source code excerpt:
// Transform into the cloth reference simulation space used at the time of simulation
#if INTEL_ISPC
if (bChaos_GetSimData_ISPC_Enabled)
{
// ISPC is assuming float input here
check(sizeof(ispc::FVector3f) == Data.Positions.GetTypeSize());
check(sizeof(ispc::FVector3f) == Data.Normals.GetTypeSize());
ispc::GetClothingSimulationData(
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Public/ChaosCloth/ChaosClothingSimulation.h:171
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_GetSimData_ISPC_Enabled = INTEL_ISPC && CHAOS_GET_SIM_DATA_ISPC_ENABLED_DEFAULT;
#else
extern bool bChaos_GetSimData_ISPC_Enabled;
#endif