Allow applications to use OpenGL buffer, texture and renderbuffer objects as OpenCL memory objects.
#pragma OPENCL EXTENSION CL_APPLE_gl_sharing : enable #pragma OPENCL EXTENSION CL_KHR_gl_sharing : enable |
These OpenCL functions 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 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 http://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.
An OpenCL memory object created from an OpenGL object (hereinafter refered to as a "shared CL/GL object") remains valid as long as the corresponding GL object has not been deleted. If the GL object is deleted through the GL API (e.g. glDeleteBuffers, glDeleteTextures, or glDeleteRenderbuffers), subsequent use of the CL buffer or image object will result in undefined behavior, including but not limited to possible CL errors and data corruption, but may not result in program termination.
The CL context and corresponding command-queues are dependent on the existence of the GL share group object, or the share group associated with the GL context from which the CL context is created. If the GL share group object or all GL contexts in the share group are destroyed, any use of the CL context or command-queue(s) will result in undefined behavior, which may include program termination. Applications should destroy the CL command-queue(s) and CL context before destroying the corresponding GL share group or contexts
Click an item in the table for details about that function.
clCreateFromGLBuffer | Creates an OpenCL buffer object from an OpenGL buffer object. |
clCreateFromGLTexture2D | Creates an OpenCL 2D image object from an OpenGL 2D texture object, or a single face of an OpenGL cubemap texture object. |
clCreateFromGLTexture3D | Creates an OpenCL 3D image object from an OpenGL 3D 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. |