OpenCL / OpenGL context with multiple devices

I am currently writing a smoke simulation in OpenCL where I am using OpenGL (freeglut) to render the smoke.

My computer is an Asus Zenbook with an Intel i7 processor and an Intel HD 4000 GPU which are "recognized" (HD 4000 = CL_DEVICE_TYP_GPU and Intel i7 = CL_DEVICE_TYPE_CPU) OpenCL and are on my device list. Both devices support "cl_khr_gl_sharing".

I am setting up the OGL / OCL context along with my properties like this:

cl_context_properties props[] = 
{
    CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(), 
    CL_WGL_HDC_KHR,     (cl_context_properties)wglGetCurrentDC(), 
    CL_CONTEXT_PLATFORM, (cl_context_properties)m_platformID,
    NULL
};
cl_device_id devices[32];
size_t size;
clGetGLContextInfoKHR_fn clGetGLContextInfo = (clGetGLContextInfoKHR_fn)clGetExtensionFunctionAddressForPlatform(m_platformID, "clGetGLContextInfoKHR"); 
clGetGLContextInfo(props, CL_DEVICES_FOR_GL_CONTEXT_KHR, 32 * sizeof(cl_device_id), devices, &size);
cl_uint deviceCount = (cl_uint)(size/sizeof(cl_device_id));

cl_context cntxt = clCreateContext(props, deviceCount, devices, NULL, NULL, &status);

      

But the clCreateContext function returns -33, which is the error code for "INVALID_DEVICE". In the above code, my "devicecount" variable becomes 2, which should imply that both devices are associated with the current GL context.

The context creation only works when transmitted in either of the two devices separately , in which cases the simulation runs fine (although of course very slow on the CPU).

There is a similar question to this one and has been answered, but to be honest I don't really understand the answer.

So my questions are:

Is it possible to create a shared context between OpenCL and OpenGL with multiple CL devices?

If so..

Is the method I'm using to create the context, or is there another way to set up an OCL / OGL context with multiple devices?

+3


source to share