Physics using OpenCL?

I see AMD has produced a a very cool Tress FX API for physics based hair, that uses DirectCompute.

Which got me thinking that surely OpenCL could be used for physics calculations. Has anyone already built a library to do this?

EDIT: A quick google shows AMD demoed something like this back in 2009, but obviously that got shelved…

EDIT: Ah…

http://bulletphysics.org/wordpress/?p=340

OpenCL can be used for anything really, but interop with OpenGL is still problematic. Sharing buffers is easy enough, but when it’s time to synchronize CL computation with GL rendering, we’re forced to use clFinish/glFinish, sacrificing performance. It’s been almost 3 years and no vendor supports ARB_cl_event or KHR_gl_event yet.

ARB_compute_shader, which is compute via OpenGL/GLSL, might be a more approachable (and obviously less powerful) solution. There are no synchronization issues and you won’t have to learn another API. Only Nvidia supports this currently but we should see support from other vendors soon. Unfortunately the spec has bumped the required GL version to 4.2 (was 3.0 originally), so hardware support will be limited.

Very informative, thanks.

Use it for skeletal animation or morph targets. Performance problems caused by cl/glfinish are moot because you have to transform your vertices before you can render them anyways.

How does that matter?

Since when did I become senior member??? If only my programming skills would increase as steadily as my forum ranking :slight_smile: