CLENQUEUERELEASEGLOB(3clc)
CLENQUEUERELEASEGLOB π
okay bestie, listen up β this is the clEnqueueReleaseGLObjects page from the OpenCL Manual (section 3clc, we love a numbered-girlie moment). It's the "hand the toy back to OpenGL" function. Let's get into it β¨
NAME π
clEnqueueReleaseGLObjects β release OpenCL memory objects that have been created from OpenGL objects. the give-it-back function, periodt.
cl_int clEnqueueReleaseGLObjects(cl_command_queue command_queue,
cl_uint num_objects,
const cl_mem *mem_objects,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event);
PARAMETERS π¦
command_queueβ a valid command-queue. literally just a valid command-queue, that's the whole vibe check.num_objectsβ how many memory objects we're releasing inmem_objects. count 'em up.mem_objectsβ a pointer to a list of CL memory objects that correspond to GL objects. π«Άevent_wait_list,num_events_in_wait_listβ these two specify events that need to finish before this command can even think about executing. Here's the tea:- if
event_wait_listisNULL, then this particular command does not wait on any event to complete. - if
event_wait_listisNULL,num_events_in_wait_listmust be 0. - if
event_wait_listis notNULL, then the list of events pointed to byevent_wait_listmust be valid andnum_events_in_wait_listmust be greater than 0. - the events in
event_wait_listact as synchronization points. like little bouncers at the door π
- if
eventβ returns an event object that identifies this particular read/write command, so you can query it or queue a wait for it to complete.eventcan beNULL, in which case the app justβ¦ can't query the status of this command or queue a wait for it. no event, no status, that's the deal.
Now here's the special clause π: if the cl_khr_gl_sharing(3clc) extension is supported and an OpenGL context is bound to the current thread, then any OpenGL commands which does:
- affect or access the contents of a memory object listed in the
mem_objectslist, and - are issued on that context after the call to
clEnqueueReleaseGLObjects.RE
will not execute until after execution of any OpenCL commands preceding the clEnqueueReleaseGLObjects which affect or access any of those memory objects. If a non-NULL event object is returned, it will report completion before execution of such OpenGL commands.
DESCRIPTION πΈ
Release OpenCL memory objects that have been created from OpenGL objects. These objects need to be released before they can be used by OpenGL β like, you cannot skip this step bestie. The OpenGL objects are released by the OpenCL context associated with command_queue.
NOTES β
In order to ensure data integrity, the application is responsible for synchronizing access to shared CL/GL objects by their respective APIs. Failure to provide such synchronization may result in race conditions and other undefined behavior including non-portability between implementations. π so please sync, I'm begging.
Prior to calling clEnqueueAcquireGLObjects, the application must ensure that any pending GL operations which access the objects specified in mem_objects have completed. This may be accomplished portably by issuing and waiting for completion of a glFinish command on all GL contexts with pending references to these objects. Implementations may offer more efficient synchronization methods; for example on some platforms calling glFlush may be sufficient, or synchronization may be implicit within a thread, or there may be vendor-specific extensions that enable placing a fence in the GL command stream and waiting for completion of that fence in the CL command queue. Note that no synchronization methods other than glFinish are portable between OpenGL implementations at this time. iconic but also terrifying.
Similarly, after calling clEnqueueReleaseGLObjects, the application is responsible for ensuring that any pending OpenCL operations which access the objects specified in mem_objects have completed prior to executing subsequent GL commands which reference these objects. This may be accomplished portably by calling clWaitForEvents(3clc) with the event object returned by clEnqueueReleaseGLObjects, or by calling clFinish(3clc). As above, some implementations may offer more efficient methods. π₯
The application is responsible for maintaining the proper order of operations if the CL and GL contexts are in separate threads. multithreading said "you're on your own babe".
If a GL context is bound to a thread other than the one in which clEnqueueReleaseGLObjects is called, changes to any of the objects in mem_objects may not be visible to that context without additional steps being taken by the application. For an OpenGL 3.1 (or later) context, the requirements are described in Appendix D ("Shared Objects and Multiple Contexts") of the OpenGL 3.1 Specification. For prior versions of OpenGL, the requirements are implementation-dependent. π
Attempting to access the data store of an OpenGL object after it has been acquired by OpenCL and before it has been released will result in undefined behavior. Similarly, attempting to access a shared CL/GL object from OpenCL before it has been acquired by the OpenCL command queue, or after it has been released, will result in undefined behavior. π do not do this. do NOT.
If the cl_khr_gl_event(3clc) 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. This is referred to as implicit synchronization. slay, the implementation handles it for you π§
ERRORS π
clEnqueueReleaseGLObjects returns CL_SUCCESS if the function is executed successfully. If num_objects is 0 and mem_objects is NULL the function does nothing and returns CL_SUCCESS (girl just vibes). Otherwise, it returns one of the following errors:
CL_INVALID_VALUEifnum_objectsis zero andmem_objectsis not aNULLvalue, or ifnum_objects> 0 andmem_objectsisNULL.CL_INVALID_MEM_OBJECTif memory objects inmem_objectsare not valid OpenCL memory objects.CL_INVALID_COMMAND_QUEUEifcommand_queueis not a valid command-queue.CL_INVALID_CONTEXTif context associated withcommand_queuewas not created from an OpenGL context.CL_INVALID_GL_OBJECTif memory objects inmem_objectshave not been created from a GL object(s).CL_INVALID_EVENT_WAIT_LISTifevent_wait_listisNULLandnum_events_in_wait_list> 0, orevent_wait_listis notNULLandnum_events_in_wait_listis 0, or if event objects inevent_wait_listare not valid events.CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
SPECIFICATION π
OpenCL Specification[1]
SEE ALSO π«Ά
cl_khr_gl_sharing(3clc), clEnqueueAcquireGLObjects(3clc), cl_khr_gl_event(3clc)
AUTHORS π
The Khronos Group
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 58, section 9.7.6 - Sharing memory objects that map to GL objects...
and that's the whole page bestie!! this one came from The Khronos Group, dated 01/14/2021, living in the OpenCL Manual as CLENQUEUERELEASEGLOB(3clc). go release those GL objects, you absolute main character π
ππ¦
π¦ 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