Creates a linked event object.
cl_event clCreateEventFromEGLSyncKHR(cl_context context,
CLeglSyncKHR sync,
CLeglDisplayKHR display,
cl_int *errcode_ret)context-
A valid OpenCL context created from an OpenGL context or share group, using the
cl_khr_gl_sharingextension. sync-
The name of a sync object of type
EGL_SYNC_FENCE_KHRcreated with respect to EGLDisplaydisplay.
An event object may be created by linking to an EGL sync object. Completion of such an event object is equivalent to waiting for completion of the fence command associated with the linked EGL sync object.
The parameters of an event object linked to an EGL sync object will return the following values when queried with clGetEventInfo:
-
The
CL_EVENT_COMMAND_QUEUEof a linked event is NULL, because the event is not associated with any OpenCL command queue. -
The
CL_EVENT_COMMAND_TYPEof a linked event isCL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR, indicating that the event is associated with a EGL sync object, rather than an OpenCL command. -
The
CL_EVENT_COMMAND_EXECUTION_STATUSof a linked event is eitherCL_SUBMITTED, indicating that the fence command associated with the sync object has not yet completed, orCL_COMPLETE, indicating that the fence command has completed.
clCreateEventFromEGLSyncKHR performs an implicit clRetainEvent on the returned event object.
Creating a linked event object also places a reference on the linked EGL sync object.
When the event object is deleted, the reference will be removed from the EGL sync object.
Events returned from clCreateEventFromEGLSyncKHR may only be consumed by clEnqueueAcquire*** commands.
Passing such events to any other CL API that enqueues commands will generate a CL_INVALID_EVENT error."
Event objects can also be used to reflect the status of an EGL fence sync object.
The sync object in turn refers to a fence command executing in an EGL client API command stream.
This provides another method of coordinating sharing of EGL / EGL client API objects with OpenCL.
Completion of EGL / EGL client API commands may be determined by placing an EGL fence command after commands using eglCreateSyncKHR, creating an event from the resulting EGL sync object using clCreateEventFromEGLSyncKHR and then specifying it in the event_wait_list of a clEnqueueAcquire*** command.
This method may be considerably more efficient than calling operations like glFinish, and is referred to as explicit synchronization.
The application is responsible for ensuring the command stream associated with the EGL fence is flushed to ensure the CL queue is submitted to the device.
Explicit synchronization is most useful when an EGL client API context bound to another thread is accessing the memory objects.
Returns a valid OpenCL event object and errcode_ret is set to CL_SUCCESS if the event object is created successfully.
Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:
-
CL_INVALID_CONTEXTifcontextis not a valid context or was not created from a GL context. -
CL_INVALID_EGL_OBJECT_KHRifsyncis not a valid EGLSyncKHR handle created with respect to EGLDisplaydisplay. -
CL_INVALID_EGL_OBJECT_KHRifsyncis not a valid EGLSyncKHR object of typeEGL_SYNC_FENCE_KHRcreated with respect to EGLDisplaydisplay.