p.ChaosCloth.Solver.ParallelClothPostUpdate

p.ChaosCloth.Solver.ParallelClothPostUpdate

#Overview

name: p.ChaosCloth.Solver.ParallelClothPostUpdate

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.ChaosCloth.Solver.ParallelClothPostUpdate is to control whether the post-update process for each cloth in the Chaos Cloth simulation should be performed in parallel.

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 cloth simulation solver’s performance and behavior.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. It is associated with the boolean variable bClothSolverParallelClothPostUpdate.

This variable interacts closely with other parallel processing settings for the Chaos Cloth solver, such as ParallelClothPreUpdate and ParallelClothUpdate. Together, these variables control the parallelization of different stages in the cloth simulation process.

Developers should be aware that enabling this setting can improve performance on multi-core systems by allowing the post-update process for multiple cloth instances to run simultaneously. However, it may also introduce some non-determinism in the simulation results due to the parallel execution order.

Best practices when using this variable include:

  1. Enable it by default for better performance on multi-core systems.
  2. Consider disabling it if absolute determinism is required for the cloth simulation results.
  3. Test the performance impact with and without this setting enabled, as the benefits may vary depending on the number of cloth instances and available CPU cores.

Regarding the associated variable bClothSolverParallelClothPostUpdate:

This boolean variable directly controls the behavior specified by the p.ChaosCloth.Solver.ParallelClothPostUpdate setting. It is used in the FClothingSimulationSolver::Update, FClothingSimulationSolver::UpdateFromCache, and related functions to determine whether to force single-threaded execution of the post-update process for each cloth instance.

The variable is initialized to true by default, meaning parallel post-update is enabled out of the box. Developers can modify this variable through the console command system to enable or disable parallel post-update at runtime.

When working with this variable, developers should consider the same performance and determinism trade-offs mentioned for the console variable. They should also be aware that changes to this variable will take effect immediately in the next simulation step, allowing for dynamic adjustments to the cloth simulation’s parallelization 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/ChaosClothingSimulationSolver.cpp:65

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

FAutoConsoleVariableRef CVarClothSolverParallelClothPreUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothPreUpdate"), bClothSolverParallelClothPreUpdate, TEXT("Pre-transform the cloth particles for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverParallelClothUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothUpdate"), bClothSolverParallelClothUpdate, TEXT("Skin the physics mesh and do the other cloth update for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverParallelClothPostUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothPostUpdate"), bClothSolverParallelClothPostUpdate, TEXT("Pre-transform the cloth particles for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverDebugHitchLength(TEXT("p.ChaosCloth.Solver.DebugHitchLength"), ClothSolverDebugHitchLength, TEXT("Hitch length in ms. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDebugHitchInterval(TEXT("p.ChaosCloth.Solver.DebugHitchInterval"), ClothSolverDebugHitchInterval, TEXT("Hitch interval in frames. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDisableCollision(TEXT("p.ChaosCloth.Solver.DisableCollision"), bClothSolverDisableCollision, TEXT("Disable all collision particles. Needs reset of the simulation (p.ChaosCloth.Reset)."));
#endif

FAutoConsoleVariableRef CVarClothSolverDisableTimeDependentNumIterations(TEXT("p.ChaosCloth.Solver.DisableTimeDependentNumIterations"), bClothSolverDisableTimeDependentNumIterations, TEXT("Make the number of iterations independent from the time step."));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

static bool bClothSolverParallelClothPreUpdate = true;
static bool bClothSolverParallelClothUpdate = true;
static bool bClothSolverParallelClothPostUpdate = true;
static bool bClothSolverDisableTimeDependentNumIterations = false;
static bool bClothSolverUseVelocityScale = true;
static float ClothSolverMaxVelocity = 0.f;

#if !UE_BUILD_SHIPPING
static int32 ClothSolverDebugHitchLength = 0;

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

FAutoConsoleVariableRef CVarClothSolverParallelClothPreUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothPreUpdate"), bClothSolverParallelClothPreUpdate, TEXT("Pre-transform the cloth particles for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverParallelClothUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothUpdate"), bClothSolverParallelClothUpdate, TEXT("Skin the physics mesh and do the other cloth update for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverParallelClothPostUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothPostUpdate"), bClothSolverParallelClothPostUpdate, TEXT("Pre-transform the cloth particles for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverDebugHitchLength(TEXT("p.ChaosCloth.Solver.DebugHitchLength"), ClothSolverDebugHitchLength, TEXT("Hitch length in ms. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDebugHitchInterval(TEXT("p.ChaosCloth.Solver.DebugHitchInterval"), ClothSolverDebugHitchInterval, TEXT("Hitch interval in frames. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDisableCollision(TEXT("p.ChaosCloth.Solver.DisableCollision"), bClothSolverDisableCollision, TEXT("Disable all collision particles. Needs reset of the simulation (p.ChaosCloth.Reset)."));
#endif

FAutoConsoleVariableRef CVarClothSolverDisableTimeDependentNumIterations(TEXT("p.ChaosCloth.Solver.DisableTimeDependentNumIterations"), bClothSolverDisableTimeDependentNumIterations, TEXT("Make the number of iterations independent from the time step."));

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothingSimulationSolver::Update

Source code excerpt:

			FClothingSimulationCloth* const Cloth = Cloths[ClothIndex];
			Cloth->PostUpdate(this);
		}, /*bForceSingleThreaded =*/ !bClothSolverParallelClothPostUpdate);
	}

	// Save old space location for next update
	OldLocalSpaceLocation = LocalSpaceLocation;
}

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothingSimulationSolver::UpdateFromCache

Source code excerpt:

		Cloth->UpdateFromCache(CacheData);
		Cloth->PostUpdate(this);
	}, /*bForceSingleThreaded =*/ !bClothSolverParallelClothPostUpdate);

}

void FClothingSimulationSolver::UpdateFromCache(const TArray<FVector>& CachedPositions, const TArray<FVector>& CachedVelocities) 
{
	Chaos::Softs::FSolverParticles& SolverParticles = Evolution ? Evolution->GetParticles() : PBDEvolution->GetParticles();

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothingSimulationSolver::UpdateFromCache

Source code excerpt:

		FClothingSimulationCloth* const Cloth = Cloths[ClothIndex];
		Cloth->PostUpdate(this);
	}, /*bForceSingleThreaded =*/ !bClothSolverParallelClothPostUpdate);
}

int32 FClothingSimulationSolver::GetNumUsedIterations() const
{
	return Evolution ? Evolution->GetNumUsedIterations() : PBDEvolution->GetIterations();
}