Problem with GL-CL sharing context

Hi all !

I’m actually experiencing some troubles with the cl_gl sharing extension. I’m on windows 7, developping under Qt Creator (4.7) and using the nvidia OpenCL 1.0 (CUDA 3.2.1 driver). I also installed the Intel OpenCL 1.1 driver.

My program crashed when i try to create a CL image object from a GL texture object; the error is CL_INVALID_CONTEXT.
When i checked for errors when creating context (with clCreateContext), i saw this :
[ul]
[li] I’ve got a VALID GL context ([/li]```
QGLContext::currentContext() != 0

);[/*:m:14kpthuk]
[li] I use [/li]```
wglGetCurrentDC() for CL_WGL_HDC_KHR and wglGetCurrentContext() for CL_GL_CONTEXT_KHR

when passing to the properties ;[/:m:14kpthuk]
[li] When i list all the CL devices “which may be associated with the specified OpenGL context” using clGetGLContextInfoKHR and param_name CL_DEVICES_FOR_GL_CONTEXT_KHR, the returned value is 0 but i query for CL_DEVICES_FOR_GL_CONTEXT_KHR, the size is equal to 1 ?[/
:m:14kpthuk][/li][li] Finally, when the code execute “clCreateContext” with the correct params, it returns the error code “-59” which corresponds to “CL_INVALID_OPERATION” (source : cl.h) but it listed nowhere in the specs ??[/*:m:14kpthuk][/ul][/li]
Could someone give me some hints about that.

Thanks !

When i list all the CL devices “which may be associated with the specified OpenGL context” using clGetGLContextInfoKHR and param_name CL_DEVICES_FOR_GL_CONTEXT_KHR, the returned value is 0 but i query for CL_DEVICES_FOR_GL_CONTEXT_KHR, the size is equal to 1 ?

I don’t understand that sentence. Could you rephrase it?

Finally, when the code execute “clCreateContext” with the correct params, it returns the error code “-59” which corresponds to “CL_INVALID_OPERATION” (source : cl.h) but it listed nowhere in the specs ??

Yeah, that’s a bug. clCreateContext() should never return CL_INVALID_OPERATION.

Have you checked that GL/CL sharing is actually supported? Is “cl_khr_gl_sharing” exposed in clGetDeviceInfo(CL_DEVICE_EXTENSIONS)?

When i list all the CL devices “which may be associated with the specified OpenGL context” using clGetGLContextInfoKHR and param_name CL_DEVICES_FOR_GL_CONTEXT_KHR, the returned value is 0 but i query for CL_DEVICES_FOR_GL_CONTEXT_KHR, the size is equal to 1 ?

Could you rephrase it?

I mean that when i execute the function clGetGLContextInfoKHR to get the number of devices that are associated with an OpenGL context, i get no devices at all with the param_name CL_DEVICES_FOR_GL_CONTEXT_KHR but i get 1 device with the param_name CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR !

Have you checked that GL/CL sharing is actually supported? Is “cl_khr_gl_sharing” exposed in clGetDeviceInfo(CL_DEVICE_EXTENSIONS)?

Yeah, i check this and it’s supported by my CL device (checked with clGetDeviceInfo()).

By the way when i create a CL image object (2D) with the Order “RGB” and Type “Normalized_UInt8” (with the flag READ_WRITE), the function clEnqueueWriteImage returns “CL_OUT_OF_RESOURCES” but when i use Order “RGBA”, there’s not error at all ?!