omega_doom

Opengl interop - chosen wrong device but works

Discussion created by omega_doom on Jan 16, 2019
Latest reply on Jan 24, 2019 by omega_doom

Hello.

I have quite old hardware in my laptop with switchable graphics - Intel HD 4000 and Radeon HD 7670M.

Switchable graphics works but behaves unexpectedly.

I have following code to choose opencl device for texture interop

 

for(auto& platform : platforms)
  {
  clGetGLContextInfoKHR_fn pclGetGLContextInfoKHR = (clGetGLContextInfoKHR_fn)
  clGetExtensionFunctionAddressForPlatform(platform(), "clGetGLContextInfoKHR");

  if (!pclGetGLContextInfoKHR)
  continue;

  cl_context_properties properties[] =
  {
  CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
  CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
  CL_CONTEXT_PLATFORM, (cl_context_properties)platform(),
  0
  };

  cl_device_id device_id;
  size_t value_size_ret;
  if (CL_SUCCESS != pclGetGLContextInfoKHR(properties, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR
  , sizeof(cl_device_id), &device_id, &value_size_ret))
  continue;

  if (0 == value_size_ret)
  continue;

  return std::unique_ptr<cl::Device>(new cl::Device(device_id));
  }
  return nullptr;

 

It chooses intel instead of amd but for some reason works although slow. I can choose amd device explicitly and it works faster.

I don't understand why Intel opencl device doesn't lead to crash and why intel is chosen instead of amd for high performance settings.

Outcomes