AndresTraks / BulletSharpPInvoke

.NET wrapper for the Bullet physics library using Platform Invoke

Home Page:http://andrestraks.github.io/BulletSharp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenCL Support

nuzrub opened this issue · comments

I am interested in getting the OpenCL pipeline to work with this project.
However, I would like to know a bit more of your own experience with trying to get that to work.

I imagine it is fairly possible to encapsulate everything that uses OpenCL into a opaque facade and use it with P/Invoke. However, this might need some manual work (which does not seems to be how this library is implemented).

So my questions are: how is this library written, is it auto-generated? If so, is it possible to auto-generate it and then patch it with the OpenCL related stuff?

Additionally, have you ever tried wrarping the OpenCL portions of the code? If so, what is missing to make it work?

I am currently looking to get this to work to generate some large-scale simulations for use as datasets on a research project.

I first wrapped most of the functionality manually and then wrote a custom code generator for the rest. The generator got out of date and broken during development, so I removed it from the repository. The 2.x version of Bullet was pretty much done by then, so there was no need for it anyway.

These days I have way less time to work on the wrapper, but there have been requests to extend the wrapper for the OpenCL pipeline and the robotics code. While the robotics code seems to be actively developed, I'm not so sure about Bullet 3 & OpenCL.

I'm hoping to restart the generator project at some point, but I don't know when I'll get the time. If it happens, it'll probably be based on this WIP rewrite of the old project:
https://github.com/AndresTraks/DotNetWrapperGen

As far as I've found on the web, the development of the OpenCL code is stopped. According to Erwin Coumans, the initial code was heavily sponsored/done by AMD as an effort to push OpenCL forward. However, they never really dispatched a team to continue its development and so the development on it has been near zero. Meanwhile, Coumans went to work for Google, which kinda assigned him to develop all the robotics code and new solvers for Bullet.

Therefore, as you suggested, the Bullet3/OpenCL branch is kinda dead. However, it does work and it is indeed fast. I've been able to get it working without much trouble, but I'm not sure how far it can go in terms of production use.

I might try working out the P/Invoke wrappers for it on the following days/weeks to use within Unity. If I do get it working, I'm certainly sending you a pull request

Thanks for the feedback

I do am aware, Phong, that's how I got to now BulletSharp in the first place.
However, I opted for using the BulletSharp instead of your BulletUnity for two reasons: I do have C++ Bullet experience, so the raw wrappers feel more natural to me and because I do want to try the OpenCL pipeline with Unity, which is not present on both BulletUnity and BulletSharp, so it made more sense to me to work with BulletSharp first.

I did look at the Bullet OpenCL code and I am pretty sure it is possible to wrap the GpuBroadphaseInterface based algorithms.
For the Narrowphase and Solvers, it seems to be non-trivial, as it is all tied up by a "GpuRigidbodyPipeline" class. This class "looks like" a World class, but it is not derived from any other World class, so previous code based on the DiscreteDynamicsWorld would have to be ported to this "GpuRigidbodyPipeline".

The GPU branch still doesn't seem to be going anywhere.
I'll close this, but I'll accept contributions if someone wants to work on this.