CL_KHR_GL_SHARING(3clc)
π CL_KHR_GL_SHARING π
okay so this is CL_KHR_GL_SHARING(3clc) from the OpenCL Manual, and bestie it is long, so we're doing this in parts. buckle up π
β¨ NAME β¨
cl_khr_gl_sharing β Allow applications to use OpenGL buffer, texture and renderbuffer objects as OpenCL memory objects.
cl_khr_gl_sharing
π DESCRIPTION π
So this is a Kronos-approved extension name. If your implementation supports it, "cl_khr_gl_sharing" will be returned for CL_DEVICE_EXTENSIONS when you call clGetDeviceInfo(3clc). no cap π―
The OpenCL specification in section 9.7 defines how to share data with texture and buffer objects in a parallel OpenGL implementation, but it does not define how the association between an OpenCL context and an OpenGL context or share group is established. This extension is literally the missing piece: it 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_PLATFORM_EXTENSIONS or CL_DEVICE_EXTENSIONS string described in the table of allowed values for param_name for clGetDeviceInfo(3clc) β¨
An OpenGL implementation supporting buffer objects and sharing of texture and buffer object images with OpenCL is required by this extension. like, non-negotiable. π βοΈ
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. it's giving collaboration π«Ά
- 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 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. those ones are simply not invited to the party π
π¦ GL internal format β CL image format π¦
matching GL formats to their CL glow-ups (channel order, channel data type):
GL_RGBA8βCL_RGBA, CL_UNORM_INT8orCL_BGRA, CL_UNORM_INT8GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REVβCL_RGBA, CL_UNORM_INT8GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REVβCL_BGRA, CL_UNORM_INT8GL_RGBA16βCL_RGBA, CL_UNORM_INT16GL_RGBA8I, GL_RGBA8I_EXTβCL_RGBA, CL_SIGNED_INT8GL_RGBA16I, GL_RGBA16I_EXTβCL_RGBA, CL_SIGNED_INT16GL_RGBA32I, GL_RGBA32I_EXTβCL_RGBA, CL_SIGNED_INT32GL_RGBA8UI, GL_RGBA8UI_EXTβCL_RGBA, CL_UNSIGNED_INT8GL_RGBA16UI, GL_RGBA16UI_EXTβCL_RGBA, CL_UNSIGNED_INT16GL_RGBA32UI, GL_RGBA32UI_EXTβCL_RGBA, CL_UNSIGNED_INT32GL_RGBA16F, GL_RGBA16F_ARBβCL_RGBA, CL_HALF_FLOATGL_RGBA32F, GL_RGBA32F_ARBβCL_RGBA, CL_FLOAT
πΈ Lifetime of Shared Objects πΈ
π₯ OpenCL Functions That Allow Sharing π₯
Click an item in the table for details about that function. (it was a table in the original, we're doing bullets now, same energy, same facts π)
clGetGLContextInfoKHR(3clc)β Query the device.clCreateFromGLBuffer(3clc)β Creates an OpenCL buffer object from an OpenGL buffer object.clCreateFromGLTexture(3clc)β 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(3clc)β Creates an OpenCL 2D image object from an OpenGL renderbuffer object.clGetGLObjectInfo(3clc)β Query an OpenGL memory object used to create an OpenCL memory object.clGetGLTextureInfo(3clc)β Get additional information about the GL texture object associated with a memory object.clEnqueueAcquireGLObjects(3clc)β Acquire OpenCL memory objects that have been created from OpenGL objects.clEnqueueReleaseGLObjects(3clc)β Release OpenCL memory objects that have been created from OpenGL objects.
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
EXTENSION(3clc), clGetGLContextInfoKHR(3clc)
π AUTHORS π
The Khronos Group
part 1 done, bestie β more parts incoming, don't go anywhere π§β¨
π COPYRIGHT (yes bestie, we're doing the legal bit, stay with me)
Okay so this whole page is brought to you by:
Copyright Β© 2007-2011 The Khronos Group Inc.
And here's the actual permission text, word for word, no edits, no vibes-based paraphrasing, because legal text is sacred:
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.
TL;DR of the TL;DR: use it, remix it, ship it, sell it β just keep the copyright notice and this permission notice attached to all copies or substantial portions. That's the whole deal. π€
π NOTES
Just one note, and it's a citation, so it's giving very "academic bestie" energy π
- OpenCL Specification page 39, section 9.6 - Creating CL context from a GL context or share group
That's your receipt, bestie β if you wanna read the source of truth for yourself, that's exactly where to look. Go read it. Slay. π
And that's the whole page, start to finish!! π¦β¨
This one came to you from The Khronos Group, dated 01/14/2021, living in your terminal as CL_KHR_GL_SHARING(3clc). thanks for reading the entire thing, you're genuinely the main character for that ππ
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms