CL_KHR_GL_EVENT(3clc)
π cl_khr_gl_event β OpenCL Manual (3clc) π
okay bestie, sit DOWN, because this one is literally about making OpenCL and OpenGL hold hands across the fence π β¨
πΈ NAME πΈ
cl_khr_gl_event β create an OpenCL event object from a GL sync object.
like. that's the whole thing. it's giving "tiny extension, massive glow-up" π«Ά
β¨ DESCRIPTION β¨
This extension enables the function clCreateEventFromGLsyncKHR(3clc). yes queen, it unlocks a whole new function, we love to see it π
What it actually does: it lets you create OpenCL event objects that are linked to OpenGL fence sync objects. which β ngl β can potentially improve efficiency of sharing images and buffers between the two APIs. two APIs, one brain cell, working together π§π
The companion GL_ARB_cl_event OpenGL extension provides the complementary functionality β it goes the other way and creates an OpenGL sync object from an OpenCL event object. it's a two-way street, mutual, iconic π
Plus β plot twist β this extension also modifies the behavior of clEnqueueAcquireGLObjects(3clc) and clEnqueueReleaseGLObjects(3clc), so they now implicitly guarantee synchronization with an OpenGL context bound in the same thread as the OpenCL context. automatic sync?? we love a no-extra-work moment πβ¨
If an implementation supports this extension, the string cl_khr_gl_event will be present in the CL_PLATFORM_EXTENSIONS or CL_DEVICE_EXTENSIONS string described in the table of param_name values for clGetDeviceInfo(3clc). so go check that string, that's your vibe check π
π NOTES π
Event objects can also be used to reflect the status of an OpenGL sync object. And that sync object in turn refers to a fence command executing in an OpenGL command stream. which gives you another method of coordinating the sharing of buffers and images between OpenGL and OpenCL β see section 9.7.6.1 for the deets π
Implicit synchronization β if the cl_khr_gl_event extension is supported, then the OpenCL implementation will ensure that any such pending OpenGL operations are complete for an OpenGL context bound to the same thread as the OpenCL context. that's the whole thing. it just handles it. no cap π«Ά
Explicit synchronization β if the cl_khr_gl_event extension is supported and the OpenGL context in question supports fence sync objects, then completion of OpenGL commands may also be determined by:
- placing a GL fence command after those commands using
glFenceSync, - creating an event from the resulting GL sync object using
clCreateEventFromGLsyncKHR(3clc), - and determining completion of that event object via
clEnqueueAcquireGLObjects(3clc).
This method may be considerably more efficient than calling glFinish. it's called explicit synchronization, and honestly? it's the main character of this manpage π₯ Explicit synchronization is most useful when an OpenGL context bound to another thread is accessing the memory objects. different thread, same drama, handled π
If the extension is NOT supported β completion of OpenGL commands may be determined by issuing and waiting for completion of a glFinish command on all OpenGL contexts with pending references to these objects. Some implementations may offer other efficient synchronization methods β if such methods exist, they will be described in platform-specific documentation. so go read your platform docs, bestie, they might be hiding something good π
π¨ okay real talk, important warning: no synchronization method other thanglFinishis portable between all OpenGL implementations and all OpenCL implementations. While this is the only way to ensure completion that is portable to all platforms,glFinishis an expensive operation and its use should be avoided if thecl_khr_gl_eventextension is supported on a platform. expensive!! like, designer-bag expensive. avoid it when you can ππΈ
π SPECIFICATION π
OpenCL Specification[1] β go read it, it's the source of truth β
π SEE ALSO π
π AUTHORS π
The Khronos Group β yeah, the whole group. collective slay π«Ά
Β©οΈ COPYRIGHT Β©οΈ
Copyright Β© 2007-2011 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.
ποΈ NOTES ποΈ
- OpenCL Specification page 61, section 9.8 - Creating CL event objets
and that's the whole page, bestie!! this manual page came to you from The Khronos Group, dated 01/14/2021, filed under CL_KHR_GL_EVENT(3clc) β go forth and sync responsibly πβ¨ππ¦
π¦ 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