So after having my elderly 8800GT graphics card rained on (yes the studio be leaky me, maties!) I went out and got myself a whopping GTX 470…and what better to stress it out than openCL particles?
10 million of them at ~60fps!!!
Oh yes: GPU 99%, CPU 0%
Managed to get this working on Windows 7 64-bit. I’m using CUDA 3.1 and latest beta drivers (258.69).
Main thing I had to change was the way the Platform, Device and Context were specified.
In essence on a PC this is specified as:
cl_context_properties properties[] = {
CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
CL_CONTEXT_PLATFORM, (cl_context_properties)clPlatform,
0};
and requires windows.h…there were also a bunch of minor changes necessary throughtout the ofxOpenCL addon (including, including assert.h, specifying, cl.h instead of opencl.h, adding a reference to the current platform in a var I called clPlatform, etc etc)…
I also had to add a call to clEnqueueAcquireGLObjects just before doing kernalUpdate->run1D and a clEnqueueReleaseGLObjects just after…I got the idea for doing that from these cut down openCL-examples.
I’m sure there’s a neat way to impliment a system for registering cl buffer objects created by gl objects so that this code could be moved into the addon itself, but for now I’ve left it in the Update method…didn’t want to mess too much with your code Memo - although happy to have go if you like?
BTW: according to a post here the OSX method for registering an openCL context has been changed…can’t confirm as I don’t have Snow Leopard running yet…
I’ve put a 0.61 project folder here. I’ve only tested it on Win 7 64-bit. Enjoy PC-heads.
EDIT: realised the project folder doesn’t have the modified Addon - duf - that and the src folder for the particles example (on its own) are below.
Memo & Rui: thanks heaps for sharing!
ofxOpenCL.zip
src.zip