1 of 1 people found this helpful
I think, it should work as long as the CPU device supports cl_khr_gl_sharing extension and its in the list of all CL devices which may be associated with the specified OpenGL context queried using clGetGLContextInfoKHR . You may try following workflow:
// Say, you have declared the context property as below:
cl_context_properties props =
CL_CONTEXT_PLATFORM, (cl_context_properties) platform,
CL_GL_CONTEXT_KHR, (cl_context_properties) hRC,
//HDC used to create the OpenGL context
CL_WGL_HDC_KHR, (cl_context_properties) hDC,
// Get the list of all CL devices which may be associated with the specified OpenGL context.
clGetGLContextInfoKHR(props, CL_DEVICES_FOR_GL_CONTEXT_KHR, listSize, deviceList, NULL));
// Check if the "deviceList" contains the CPU device and if so, find the CPU device from the "deviceList" using clGetDeviceInfo(..,CL_DEVICE_TYPE, …)
// Say, cpu device id is cpuDeviceId
// Then create a context only for CPU device
context = clCreateContext(props, 1, &cpuDeviceId, 0, 0, NULL);
// Now, its possible to share the GL texture or buffer
Thank you for reply. I had some problems but the main reason why I couldn't use CPU device is that I didn't use clEnqueueAcquireGLObjects and clEnqueueReleaseGLObjects. For some reason I didn't need to do this while executing my kernels on AMD GPU device.