google / liquidfun

2D physics engine for games
http://google.github.io/liquidfun
4.71k stars 642 forks source link

SIMD optimizations #58

Open karlzwinnen opened 8 years ago

karlzwinnen commented 8 years ago

As Liquidfun uses SIMD for its particle system, i was wondering if there are any plans to optimize the box2d part as well?

It seems there already is a fork of box2d available which makes use of SIMD (and also enables this for SIMD.js through emscripten): http://peterjensen.github.io/html5-box2d/ The source seems to be hosted here: https://github.com/huningxin/box2d.js/tree/sse

Would it be difficult to merge this back in the box2d core liquidfun uses?

jsanmiya commented 8 years ago

Hey Karizwinnen,

That's a cool fork of box2d. It looks like they optimized a few key functions with intrinsics https://github.com/huningxin/box2d.js/blob/sse/Box2D_v2.2.1/Box2D/Dynamics/Contacts/b2ContactSolver.cpp#L674, so yes, it seems possible to pull that in, although we'd have to ensure it works for all platforms, not just Intel processors.

That being said, I think it's nice to stick as close as possible to official Box2D releases (currently we're based on the 2.3.0 release of Box2D). This way, people can use LiquidFun as a drop-in replacement. Pulling in code from other places increases the chance that we'll introduce a deviation.

One thing to note: their SIMD optimizations use SSE https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions, so they're for Intel and AMD chips. LiquidFun's SIMD assembly code is for NEON http://www.arm.com/products/processors/technologies/neon.php, so for ARM chips. So they're optimizations for different platforms. Still useful, but slightly different.

On Wed, Oct 28, 2015 at 8:30 AM, karlzwinnen notifications@github.com wrote:

As Liquidfun uses SIMD for its particle system, i was wondering if there are any plans to optimize the box2d part as well?

It seems there already is a fork of box2d available which makes use of SIMD (and also enables this for SIMD.js through emscripten): http://peterjensen.github.io/html5-box2d/ The source seems to be hosted here: https://github.com/huningxin/box2d.js/tree/sse

Would it be difficult to merge this back in the box2d core liquidfun uses?

— Reply to this email directly or view it on GitHub https://github.com/google/liquidfun/issues/58.