3

I'm currently writing a smoke simulation in OpenCL where I use OpenGL (freeglut) to visualize the smoke.

My computer is a Asus Zenbook with a Intel i7 CPU and a Intel HD 4000 GPU which are both "recognized" (HD 4000 = CL_DEVICE_TYP_GPU & Intel i7 = CL_DEVICE_TYPE_CPU) by OpenCL and contained in my device list. Both devices supports "cl_khr_gl_sharing".

I'm setting up the OGL/OCL context together with its 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 error code for "INVALID_DEVICE". In the code above my "devicecount" variable becomes equal to 2 which should imply that both devices are associable with the current GL context.

Creating the context works only when passing in either of the two devices separately and in these cases the simulation runs fine (though of course very slow on the CPU).

A similar question is this one and it 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 correct or is there another way of setting up a OCL/OGL context with more than one device?

Community
  • 1
  • 1
Ferenziz
  • 79
  • 4
  • But gl runs in a single device or some sli/crossfire setup. Can you enable that with those devices? Did you try software rendering with gl? Maybe there is something like very old games in times of T&L acceleration beggining. – huseyin tugrul buyukisik Apr 28 '15 at 17:25
  • @huseyintugrulbuyukisik I have no clue how to enable sli/crossfire. I'm honestly not quite sure about what those setups are. I have not tried software rendering, how would that help or answer my question? – Ferenziz Apr 28 '15 at 17:53
  • It might not be possible to create a Context with those 2 devices, as there might be some hardware limitations, hence the OpenCL driver is not allowing to create a context for them. Normally the context should be created, but it is not compulsory – Chanakya.sun Aug 30 '15 at 11:01

1 Answers1

0

Yes, you can create context having one GL device and mulitple CL devices. Each GL device can have interop with any of the CL device if the inter-gpu interop is supported by the corresponding vendor.

Ayush
  • 1
  • 1