CL_KHR_GL_EVENT(3clc)

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

πŸ’– 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:

  1. placing a GL fence command after those commands using glFenceSync,
  2. creating an event from the resulting GL sync object using clCreateEventFromGLsyncKHR(3clc),
  3. 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 than glFinish is portable between all OpenGL implementations and all OpenCL implementations. While this is the only way to ensure completion that is portable to all platforms, glFinish is an expensive operation and its use should be avoided if the cl_khr_gl_event extension 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 Β© 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 πŸ—’οΈ

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