p.Chaos.MultiRes.ISPC
p.Chaos.MultiRes.ISPC
#Overview
name: p.Chaos.MultiRes.ISPC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use ISPC optimizations in MultiRes constraints
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.MultiRes.ISPC is to enable or disable ISPC (Intel SPMD Program Compiler) optimizations in MultiRes constraints within the Chaos physics engine of Unreal Engine 5.
This setting variable is primarily used in the Chaos physics engine, which is an experimental module in Unreal Engine 5. Specifically, it affects the MultiRes (multi-resolution) constraints system within Chaos.
The value of this variable is set through a console variable (CVar) system in Unreal Engine. It’s initialized to true by default, as seen in the source code:
bool bChaos_MultiRes_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosMultiResISPCEnabled(TEXT("p.Chaos.MultiRes.ISPC"), bChaos_MultiRes_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in MultiRes constraints"));
This variable interacts closely with another variable named bChaos_MultiRes_ISPC_Enabled
. They share the same value and are used interchangeably in the code.
Developers should be aware that this variable affects performance optimizations. When enabled, it allows the use of ISPC optimizations, which can potentially improve performance for multi-resolution constraint calculations in the Chaos physics engine.
Best practices when using this variable include:
- Testing performance with and without ISPC optimizations to ensure it provides benefits for your specific use case.
- Being aware that ISPC optimizations may behave differently on different hardware, so thorough testing across target platforms is advisable.
- Considering that in shipping builds, ISPC optimizations are always enabled, so ensure your game performs well with these optimizations on.
Regarding the associated variable bChaos_MultiRes_ISPC_Enabled
:
This is a boolean variable that directly controls whether ISPC optimizations are used in the MultiRes constraints system. It’s used in conditional statements to determine whether to use ISPC-optimized code paths. For example:
if (!bUseXPBD && bChaos_MultiRes_ISPC_Enabled)
{
// Use ISPC-optimized code
}
Developers should treat this variable the same way as p.Chaos.MultiRes.ISPC, as they are effectively the same setting exposed through different mechanisms (console variable vs. direct code access).
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/SoftsMultiResConstraints.cpp:20
Scope: file
Source code excerpt:
bool bChaos_MultiRes_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosMultiResISPCEnabled(TEXT("p.Chaos.MultiRes.ISPC"), bChaos_MultiRes_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in MultiRes constraints"));
bool bChaos_MultiRes_SparseWeightMap_Enabled = false;
FAutoConsoleVariableRef CVarChaosMultiResSparseWeightMapEnabled(TEXT("p.Chaos.MultiRes.SparseWeightMap"), bChaos_MultiRes_SparseWeightMap_Enabled, TEXT("Exploit the sparse weight map structure and skip the particles with 0 stiffness at the beginning and at the end"));
#endif
namespace Chaos::Softs {
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_MultiRes_ISPC_Enabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/SoftsMultiResConstraints.cpp:19
Scope: file
Source code excerpt:
static_assert(sizeof(ispc::FIntVector) == sizeof(Chaos::TVec3<int32>), "sizeof(ispc::FIntVector) != sizeof(Chaos::TVec3<int32>");
bool bChaos_MultiRes_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosMultiResISPCEnabled(TEXT("p.Chaos.MultiRes.ISPC"), bChaos_MultiRes_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in MultiRes constraints"));
bool bChaos_MultiRes_SparseWeightMap_Enabled = false;
FAutoConsoleVariableRef CVarChaosMultiResSparseWeightMapEnabled(TEXT("p.Chaos.MultiRes.SparseWeightMap"), bChaos_MultiRes_SparseWeightMap_Enabled, TEXT("Exploit the sparse weight map structure and skip the particles with 0 stiffness at the beginning and at the end"));
#endif
namespace Chaos::Softs {
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/SoftsMultiResConstraints.cpp:139
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FMultiResConstraints::Apply
Source code excerpt:
}
#if INTEL_ISPC
if (!bUseXPBD && bChaos_MultiRes_ISPC_Enabled)
{
const bool bStiffnessHasWeightMap = Stiffness.HasWeightMap();
const bool bVelocityStiffnessHasWeightMap = VelocityTargetStiffness.HasWeightMap();
if (!bStiffnessHasWeightMap && !bVelocityStiffnessHasWeightMap)
{
ispc::ApplyMultiResConstraints(
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/SoftsMultiResConstraints.cpp:273
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FMultiResConstraints::UpdateFineTargets
Source code excerpt:
#if INTEL_ISPC
if (!bUseXPBD && bChaos_MultiRes_ISPC_Enabled)
{
#if !UE_BUILD_SHIPPING
if (Stiffness.HasWeightMap() && bChaos_MultiRes_SparseWeightMap_Enabled && bStiffnessEntriesInitialized)
{
ispc::MultiResUpdateFineTargets(
(ispc::FVector3f*)&FineTargetPositions.GetData()[NonZeroStiffnessMin],
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/SoftsMultiResConstraints.h:131
Scope: file
Source code excerpt:
// Support ISPC enable/disable in non-shipping builds
#if !INTEL_ISPC
const bool bChaos_MultiRes_ISPC_Enabled = false;
#elif UE_BUILD_SHIPPING
const bool bChaos_MultiRes_ISPC_Enabled = true;
#else
extern CHAOS_API bool bChaos_MultiRes_ISPC_Enabled;
#endif