cl_khr_gl_event

Create a CL event object from a GL sync object.

#pragma OPENCL EXTENSION cl_khr_gl_event : enable

Description

This extension enables the funciton clCreateEventFromGLsyncKHR.

This extension allows creating OpenCL event objects linked to OpenGL fence sync objects, potentially improving efficiency of sharing images and buffers between the two APIs. The companion GL_ARB_cl_event OpenGL extension provides the complementary functionality of creating an OpenGL sync object from an OpenCL event object.

This extension modifies the behavior of clEnqueueAcquireGLObjects and clEnqueueReleaseGLObjects to implicitly guarantee synchronization with an OpenGL context bound in the same thread as the OpenCL context.

If this extension is supported by an implementation, 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.

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. This is referred to as implicit synchronization.

If the cl_khr_gl_event extension is supported and the OpenGL context in question supports fence sync objects, 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, and determining completion of that event object via clEnqueueAcquireGLObjects. This method may be considerably more efficient than calling glFinish, and is referred to as explicit synchronization. Explicit synchronization is most useful when an OpenGL context bound to another thread is accessing the memory objects.

If the cl_khr_gl_event 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. Note that 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.

Notes

When this extension is enabled, the following functions are also affected:

  • clGetEventInfo: Adds CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR as a possible return when param_name is CL_EVENT_COMMAND_TYPE.
  • clWaitForEvents: Event objects can also be used to reflect the status of an OpenGL sync object..

Specification

OpenCL Specification

Also see

EXTENSION, clCreateEventFromGLsyncKHR

Copyright © 2007-2010 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.