| 470 | } |
| 471 | |
| 472 | void DeviceManager::markDeviceForInterop(const int device, |
| 473 | const void* wHandle) { |
| 474 | try { |
| 475 | if (device >= static_cast<int>(mQueues.size()) || |
| 476 | device >= static_cast<int>(DeviceManager::MAX_DEVICES)) { |
| 477 | AF_TRACE("Invalid device (}) passed for CL-GL Interop", device); |
| 478 | throw cl::Error(CL_INVALID_DEVICE, |
| 479 | "Invalid device passed for CL-GL Interop"); |
| 480 | } else { |
| 481 | mQueues[device]->finish(); |
| 482 | |
| 483 | // check if the device has CL_GL sharing extension enabled |
| 484 | bool temp = |
| 485 | checkExtnAvailability(*mDevices[device], CL_GL_SHARING_EXT); |
| 486 | if (!temp) { |
| 487 | /* return silently if given device has not OpenGL sharing |
| 488 | * extension enabled so that regular queue is used for it */ |
| 489 | return; |
| 490 | } |
| 491 | |
| 492 | // call forge to get OpenGL sharing context and details |
| 493 | Platform plat(mDevices[device]->getInfo<CL_DEVICE_PLATFORM>()); |
| 494 | |
| 495 | long long wnd_ctx, wnd_dsp; |
| 496 | fgMngr->plugin().fg_get_window_context_handle( |
| 497 | &wnd_ctx, const_cast<fg_window>(wHandle)); |
| 498 | fgMngr->plugin().fg_get_window_display_handle( |
| 499 | &wnd_dsp, const_cast<fg_window>(wHandle)); |
| 500 | #ifdef OS_MAC |
| 501 | CGLContextObj cgl_current_ctx = CGLGetCurrentContext(); |
| 502 | CGLShareGroupObj cgl_share_group = |
| 503 | CGLGetShareGroup(cgl_current_ctx); |
| 504 | |
| 505 | cl_context_properties cps[] = { |
| 506 | CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, |
| 507 | (cl_context_properties)cgl_share_group, 0}; |
| 508 | #else |
| 509 | cl_context_properties cps[] = { |
| 510 | CL_GL_CONTEXT_KHR, |
| 511 | static_cast<cl_context_properties>(wnd_ctx), |
| 512 | #if defined(_WIN32) || defined(_MSC_VER) |
| 513 | CL_WGL_HDC_KHR, |
| 514 | (cl_context_properties)wnd_dsp, |
| 515 | #else |
| 516 | CL_GLX_DISPLAY_KHR, |
| 517 | static_cast<cl_context_properties>(wnd_dsp), |
| 518 | #endif |
| 519 | CL_CONTEXT_PLATFORM, |
| 520 | (cl_context_properties)plat(), |
| 521 | 0 |
| 522 | }; |
| 523 | |
| 524 | // Check if current OpenCL device is belongs to the OpenGL context |
| 525 | { |
| 526 | cl_context_properties test_cps[] = { |
| 527 | CL_GL_CONTEXT_KHR, |
| 528 | static_cast<cl_context_properties>(wnd_ctx), |
| 529 | CL_CONTEXT_PLATFORM, (cl_context_properties)plat(), 0}; |
nothing calls this directly
no test coverage detected