04-06-2021, 04:09 PM
(This post was last modified: 04-06-2021, 04:15 PM by ThoughtMango.)
Hello,
I think I found a 2nd potential perf boost for the Burst backend, mearused using a profiler sample BurstConstraintsImpl.Project() call like so:
I've replaced BurstDistanceConstraintsBatch's job generation code to:
which returned the following result (Ignore total time, the number of simulations in each case is randomised in my test scene, simulation type is one of 2 types in each case, the 0.05ms/cloth is consistent across multiple tests)
EDIT:
I assume this can be applied across all batch job types to improve the performance further
I think I found a 2nd potential perf boost for the Burst backend, mearused using a profiler sample BurstConstraintsImpl.Project() call like so:
Code:
public JobHandle Project(JobHandle inputDeps, float deltaTime)
{
UnityEngine.Profiling.Profiler.BeginSample("Project");
var parameters = m_Solver.abstraction.GetConstraintParameters(m_ConstraintType);
switch(parameters.evaluationOrder)
{
case Oni.ConstraintParameters.EvaluationOrder.Sequential:
inputDeps = EvaluateSequential(inputDeps, deltaTime);
break;
case Oni.ConstraintParameters.EvaluationOrder.Parallel:
inputDeps = EvaluateParallel(inputDeps, deltaTime);
break;
}
UnityEngine.Profiling.Profiler.EndSample();
return inputDeps;
}
Code:
public void SetDistanceConstraints(ObiNativeIntList particleIndices, ObiNativeFloatList restLengths, ObiNativeVector2List stiffnesses, ObiNativeFloatList lambdas, int count)
{
this.particleIndices = particleIndices.AsNativeArray<int>();
this.restLengths = restLengths.AsNativeArray<float>();
this.stiffnesses = stiffnesses.AsNativeArray<float2>();
this.lambdas = lambdas.AsNativeArray<float>();
projectConstraints.particleIndices = this.particleIndices;
projectConstraints.restLengths = this.restLengths;
projectConstraints.stiffnesses = this.stiffnesses;
projectConstraints.lambdas = this.lambdas;
applyConstraints.particleIndices = this.particleIndices;
}
DistanceConstraintsBatchJob projectConstraints = new DistanceConstraintsBatchJob();
public override JobHandle Evaluate(JobHandle inputDeps, float deltaTime)
{
projectConstraints.positions = solverImplementation.positions;
projectConstraints.invMasses = solverImplementation.invMasses;
projectConstraints.deltas = solverImplementation.positionDeltas;
projectConstraints.counts = solverImplementation.positionConstraintCounts;
projectConstraints.deltaTime = deltaTime;
return projectConstraints.Schedule(m_ActiveConstraintCount, 32, inputDeps);
}
ApplyDistanceConstraintsBatchJob applyConstraints = new ApplyDistanceConstraintsBatchJob();
public override JobHandle Apply(JobHandle inputDeps, float deltaTime)
{
var parameters = solverAbstraction.GetConstraintParameters(m_ConstraintType);
applyConstraints.positions = solverImplementation.positions;
applyConstraints.deltas = solverImplementation.positionDeltas;
applyConstraints.counts = solverImplementation.positionConstraintCounts;
applyConstraints.sorFactor = parameters.SORFactor;
return applyConstraints.Schedule(m_ActiveConstraintCount, 64, inputDeps);
}
EDIT:
I assume this can be applied across all batch job types to improve the performance further