CL_KHR_GL_SHARING(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’… 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_INT8 or CL_BGRA, CL_UNORM_INT8
  • GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV β†’ CL_RGBA, CL_UNORM_INT8
  • GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV β†’ CL_BGRA, CL_UNORM_INT8
  • GL_RGBA16 β†’ CL_RGBA, CL_UNORM_INT16
  • GL_RGBA8I, GL_RGBA8I_EXT β†’ CL_RGBA, CL_SIGNED_INT8
  • GL_RGBA16I, GL_RGBA16I_EXT β†’ CL_RGBA, CL_SIGNED_INT16
  • GL_RGBA32I, GL_RGBA32I_EXT β†’ CL_RGBA, CL_SIGNED_INT32
  • GL_RGBA8UI, GL_RGBA8UI_EXT β†’ CL_RGBA, CL_UNSIGNED_INT8
  • GL_RGBA16UI, GL_RGBA16UI_EXT β†’ CL_RGBA, CL_UNSIGNED_INT16
  • GL_RGBA32UI, GL_RGBA32UI_EXT β†’ CL_RGBA, CL_UNSIGNED_INT32
  • GL_RGBA16F, GL_RGBA16F_ARB β†’ CL_RGBA, CL_HALF_FLOAT
  • GL_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 πŸ’–)


πŸ“œ 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 🧚✨

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 πŸŽ€

  1. 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