Gpu accel
This pull request adds GPU acceleration benchmarking support for Rapier 3D in both the main crate and the examples, and introduces new dependencies and features to enable GPU compute via WGPU. The changes include the addition of benchmarking binaries and infrastructure for comparing CPU and GPU performance, as well as the configuration needed to support GPU acceleration in both the single-precision and double-precision versions of the 2D and 3D crates.
**GPU Acceleration Feature and Dependencies**
* Added a new optional feature `gpu-acceleration` to `rapier2d`, `rapier2d-f64`, `rapier3d`, and `rapier3d-f64`, which enables GPU compute support via the WGPU backend. This includes new optional dependencies on `wgpu`, `bytemuck`, and `pollster`. [[1]](diffhunk://#diff-09d165cbcbc2f51ebe448a2ad05e51b39b9ea161ab03851a3f3199fa45155149R52) [[2]](diffhunk://#diff-09d165cbcbc2f51ebe448a2ad05e51b39b9ea161ab03851a3f3199fa45155149R96-R111) [[3]](diffhunk://#diff-8666c076dbb52cc83945c6397f1e902d5dab3e6a29f653048794576feae3a6f1R52) [[4]](diffhunk://#diff-8666c076dbb52cc83945c6397f1e902d5dab3e6a29f653048794576feae3a6f1R93-R97) [[5]](diffhunk://#diff-f537520afd3fddca2c45e76efea67f68e0fae917462e9ea4e535f015dd9f8b2bR56) [[6]](diffhunk://#diff-f537520afd3fddca2c45e76efea67f68e0fae917462e9ea4e535f015dd9f8b2bR100-R115) [[7]](diffhunk://#diff-fef6c27fc5e5df21fbb8c0ff77c3d788ba799bf945203597b286f48561089954R55) [[8]](diffhunk://#diff-fef6c27fc5e5df21fbb8c0ff77c3d788ba799bf945203597b286f48561089954R96-R100)
**Benchmarking Infrastructure**
* Added a new benchmark binary `gpu_benchmarks` to `rapier3d` (and similarly for `rapier2d`), which benchmarks CPU vs GPU performance for physics operations, printing a summary table. This is only built when the `gpu-acceleration` feature is enabled. [[1]](diffhunk://#diff-f537520afd3fddca2c45e76efea67f68e0fae917462e9ea4e535f015dd9f8b2bR100-R115) [[2]](diffhunk://#diff-09d165cbcbc2f51ebe448a2ad05e51b39b9ea161ab03851a3f3199fa45155149R96-R111) [[3]](diffhunk://#diff-cc7793a17a1c793e91c1f01b276a6246f190f4d8b78ce9884e0a34234c58e221R1-R195)
* Added a new example binary `gpu_benchmark` in `examples3d`, providing a similar CPU vs GPU benchmark for user experimentation. [[1]](diffhunk://#diff-5fe052dd3df958f3b33fbf5a920bf23cca4d87a6aa1bdecfdc36540effecaf29R46-R49) [[2]](diffhunk://#diff-c79c7dd138ff3f8d33f5e6177d6abbd6909c43e0b8808a784f25916ac57d0fe4R1-R216)
**Benchmark Implementation**
* The new benchmarks create test scenes with varying numbers of rigid bodies, run both CPU and GPU integration steps, and compare timings, including transfer overheads and actual GPU compute. Results are summarized in an easy-to-read table. [[1]](diffhunk://#diff-cc7793a17a1c793e91c1f01b276a6246f190f4d8b78ce9884e0a34234c58e221R1-R195) [[2]](diffhunk://#diff-c79c7dd138ff3f8d33f5e6177d6abbd6909c43e0b8808a784f25916ac57d0fe4R1-R216)
**Development and Testing Improvements**
* Added `criterion` as a development dependency (for benchmarking with HTML reports) and configured the new GPU benchmarks to run only when the `gpu-acceleration` feature is enabled. [[1]](diffhunk://#diff-09d165cbcbc2f51ebe448a2ad05e51b39b9ea161ab03851a3f3199fa45155149R96-R111) [[2]](diffhunk://#diff-f537520afd3fddca2c45e76efea67f68e0fae917462e9ea4e535f015dd9f8b2bR100-R115)
These changes lay the groundwork for further GPU compute integration and provide both automated and example-driven ways to measure performance gains.
合并状态:未合并 关闭于 2026-02-10 1 条评论