Repository navigation
perf(rbd): performance improvements of the RBD solver - #45
Merged
Merged
Conversation
…colored sweeps to their buckets
…tead of two extra passes per substep
… from lever arms and inertias
…when the other body is static
…e traversal, per-workgroup pair appends
…ll arrays stay in registers
…r last narrow-phase update, like rapier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR significantly improves performances of the rigid-body solver, reaching up to 10x performance improvements in heavy scenes (like a 110K ring of cubes). Depending on the machine this makes Nexus attractive compared to, e.g., Rapier, when simulating more than ~8K objects in 3D (tested on an Apple M4 Max).
The optimizations are mainly gains from (1) better parallelism, especially for the broad-phase which had single-workgroup tasks, and (2) better memory access patterns by leveraging AoSoA in the solver (similar to rapier’s simd path). Loop-unrolling also brought some interesting speedups mainly because this mitigates an issue with how rust-gpu array accesses are compiled.
I also ported the twist friction model from rapier to nexus, resulting in an additional 20% performance improvements on heavy scenes.
List of optimizations:
With these optimizations, we are reaching performances level that get almost as competitive as an AVBD solver (which we don’t support yet), despite remaining on our Soft-TGS solver. Both scenes below are inspired from the AVBD solver’s paper.
Pyramids made of 505K cubes total hit by two balls
Runs in 25ms/step on M4 Max, 14ms/step on an RTX 5080.
A ring of 110K cubes hit by a ball, 11ms/step
Runs in 14ms/step on M4 Max, 8ms/step on an RTX 5080.