Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Optimizing Obi Cloth Scheduled Jobs
#3
Quote:Hi!

As soon as you have rigidbodies in your scene, this will lead to a race condition: several particles writing to the same memory location simultaneously (BurstMath.ApplyImpulse, line 300-ish in BurstColliderCollisionConstraintsBatch.cs).

The only way to correctly parallelize that is to ensure only one particle can update rigidbody velocities at a time, which is doable using CAS (compare-and-swap) operations. Or, make sure there are no rigidbodies in your scene, which is a quite restrictive assumption.

For the GPU backend in Obi 7, since there's no two-way rigidbody coupling support (at least not at launch), contact solving is fully parallel. And since it happens on the GPU, it can handle orders of magnitude more contacts.
Ah okay, thanks for the quick reply, I'll likely revert this change I had sneaked in on my end then since we'll likely want to use rigidbodies in our scene anyways (on the CPU) since we are currently GPU bound at the moment.

Quote:In order to allocate space for the contacts array and batch data, the collision spatial acceleration structure has to be built and the contacts queue been generated. These allocations have to happen in the main thread, so GenerateContactsJob must be completed: otherwise you don't know how much memory needs to be allocated. You cannot chain GenerateContactsJob and DequeueIntoArrayJob together.

As you can see in the profiler pic you attached, you wouldn't be saving 0.09 ms by chaining these together. The main thread is busy scheduling other jobs a bit earlier, about 0.05 ms after the end of the previous job, and is also busy doing some other stuff right after the end of the previous job. So at least half of those 0.09 ms are spent on the main thread.
Ah okay, thanks for the validating my concerns.

P.S. Thanks for making Obi Cloth and making it Burst friendly. Sonrisa
Reply


Messages In This Thread
RE: Optimizing Obi Cloth Scheduled Jobs - by initialPrefabs - 22-07-2022, 03:42 PM