【问题标题】:CGLGetDeviceFromGLRenderer alternative on 10.910.9 上的 CGLGetDeviceFromGLRenderer 替代方案
【发布时间】:2014-11-16 08:19:04
【问题描述】:

在 Mac Pro 上,我需要找到连接到屏幕的 GPU 的 cl_device_id。

CGLGetDeviceFromGLRenderer 被提及(在 WWDC 2014,Session 601)作为 API,用于将 OpenGL 渲染器的虚拟屏幕编号转换为等效的 OpenCL 设备 ID。

问题在于 CGLGetDeviceFromGLRenderer 仅在 OS X 10 (Yosemite) 上可用。

Mac OS 10.9 是否有替代方案或解决方法?

【问题讨论】:

  • 能够获取 CL/GL 互操作上下文的 CL 设备通常是连接到屏幕的设备。

标签: macos opengl core-graphics opencl gpgpu


【解决方案1】:

你可以自己写函数:

#if !defined(MAC_OS_X_VERSION_10_10)
cl_device_id CGLGetDeviceFromGLRenderer(GLint rendererID)
{
    // For GPUs that support OpenCL in Mac OS X, the rendererID may be
    // transformed into a cl_device_id by masking away the low byte:
    // https://developer.apple.com/library/mac/technotes/tn2335/_index.html
    cl_device_id device_id = (cl_device_id)(intptr_t)(rendererID &~ 0xff);
    return device_id;
}
#endif

【讨论】:

    猜你喜欢
    • 2015-06-13
    • 2019-04-22
    • 2018-08-07
    • 2017-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多