cl_khr_gl_sharing

Allow applications to use OpenGL buffer, texture and renderbuffer objects as OpenCL memory objects.

cl_khr_gl_sharing

Description

OpenCL Functions That Allow Sharing

Click an item in the table for details about that function.

clGetGLContextInfoKHR Query the device.
clCreateFromGLBuffer Creates an OpenCL buffer object from an OpenGL buffer object.
clCreateFromGLTexture Creates an OpenCL image object, image array object, or image buffer object from an OpenGL texture object, texture array object, texture buffer object, or a single face of an OpenGL cubemap texture object.
clCreateFromGLRenderbuffer Creates an OpenCL 2D image object from an OpenGL renderbuffer object.
clGetGLObjectInfo Query an OpenGL memory object used to create an OpenCL memory object.
clGetGLTextureInfo Get additional information about the GL texture object associated with a memory object.
clEnqueueAcquireGLObjects Acquire OpenCL memory objects that have been created from OpenGL objects.
clEnqueueReleaseGLObjects Release OpenCL memory objects that have been created from OpenGL objects.

This is a Kronos-approved extension name. If this extension is supported, "cl_khr_gl_sharing" will be returned for CL_DEVICE_EXTENSIONS using clGetDeviceInfo.

The OpenCL specification in section 9.7 defines how to share data with texture and buffer objects in a parallel OpenGL implementation, but does not define how the association between an OpenCL context and an OpenGL context or share group is established. This extension defines optional attributes to OpenCL context creation routines which associate a GL context or share group object with a newly created OpenCL context. If this extension is supported by an implementation, the string "cl_khr_gl_sharing" will be present in the CL_DEVICE_EXTENSIONS string described in the table of allowed values for param_name for clGetDeviceInfo or in the CL_PLATFORM_EXTENSIONS string described in the table of allowed values for param_name for clGetPlatformInfo.

This section discusses OpenCL functions that allow applications to use OpenGL buffer, texture, and renderbuffer objects as OpenCL memory objects. This allows efficient sharing of data between OpenCL and OpenGL. The OpenCL API may be used to execute kernels that read and/or write memory objects that are also OpenGL objects.

An OpenCL image object may be created from an OpenGL texture or renderbuffer object. An OpenCL buffer object may be created from an OpenGL buffer object.

OpenCL memory objects may be created from OpenGL objects if and only if the OpenCL context has been created from an OpenGL share group object or context. OpenGL share groups and contexts are created using platform specific APIs such as EGL, CGL, WGL, and GLX. On MacOS X, an OpenCL context may be created from an OpenGL share group object using the OpenCL platform extension cl_apple_gl_sharing. On other platforms including Microsoft Windows, Linux/Unix and others, an OpenCL context may be created from an OpenGL context using the Khronos platform extension cl_khr_gl_sharing. Refer to the platform documentation for your OpenCL implementation, or visit the Khronos Registry at https://www.khronos.org/registry/cl/ for more information.

Any supported OpenGL object defined within the GL share group object, or the share group associated with the GL context from which the CL context is created, may be shared, with the exception of the default OpenGL objects (i.e. objects named zero), which may not be shared.

If the cl_khr_mipmap_image extension is supported by the OpenCL device, the cl_khr_gl_sharing extension adds support for creating a mip-mapped CL image from a mip-mapped GL texture.

To create a mip-mapped CL image from a mip-mapped GL texture, the miplevel argument to clCreateFromGLTexture should be a negative value. If miplevel is a negative value then a CL mipmapped image object is created from a mipmapped GL texture object instead of a CL image object for a specific miplevel of a GL texture.

Specification

OpenCL Specification

Also see

EXTENSION, cl_khr_mipmap_image

Copyright © 2007-2013 The Khronos Group Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.