PDA

View Full Version : OpenCL + OpenGL (interop)



Executor
11-01-2009, 02:39 AM
How i may use OpenCL with OpenGL?
I try line this:


glGenTextures(1, &texDispMap);
glBindTexture(GL_TEXTURE_2D, texDispMap);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, hmap_dim, hmap_dim, 0, GL_RGBA, GL_FLOAT, 0);

bufCL_Disp = clCreateFromGLTexture2D(ctxGPU, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, texDispMap, &errNum);

errNum is CL_OUT_OF_HOST_MEMORY
I go read specs, and I see "context is a valid OpenCL context created from an OpenGL context.".
Ok... I must create CL context from GL context... How I may do that?
I must use http://www.khronos.org/registry/cl/exte ... haring.txt (http://www.khronos.org/registry/cl/extensions/khr/cl_khr_gl_sharing.txt) extension for that? How? I dont find in cl.h tokens/functions for this extension.

dbs2
11-01-2009, 11:15 AM
The method for getting a context connected to a GL device is implementation dependent. Apple's implementation does it by passing in a special Apple constant to clCreateContext that specifies the Apple CL Share Group you want to use. I'm not sure how it works on other platforms.

Executor
11-09-2009, 05:16 AM
I found answer here:
viewtopic.php?f=28&t=2174 (http://www.khronos.org/message_boards/viewtopic.php?f=28&t=2174)

I need use cl_gl.h from ATI Stream SDK, in official headers tokens not founds.