C Specification

To create an OpenCL event object linked to an EGL fence sync object, call the function

// Provided by cl_khr_egl_event
cl_event clCreateEventFromEGLSyncKHR(
    cl_context context,
    CLeglSyncKHR sync,
    CLeglDisplayKHR display,
    cl_int* errcode_ret);
clCreateEventFromEGLSyncKHR is provided by the cl_khr_egl_event extension.

Parameters

  • context is a valid OpenCL context created from an OpenGL context or share group, using the cl_khr_gl_sharing extension.

  • sync is the name of a sync object of type EGL_SYNC_FENCE_KHR created with respect to EGLDisplay display.

  • display is the EGLDisplay handle.

  • errcode_ret will return an appropriate error code. If errcode_ret is NULL, no error code is returned.

Description

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_QUEUE of a linked event is NULL, because the event is not associated with any OpenCL command-queue.

  • The CL_EVENT_COMMAND_TYPE of a linked event is CL_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_STATUS of a linked event is either CL_SUBMITTED, indicating that the fence command associated with the sync object has not yet completed, or CL_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 commands to acquire and release memory objects. Passing such events to any other CL API that enqueues commands will generate a CL_INVALID_EVENT error.

clCreateEventFromEGLSyncKHR 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_CONTEXT if context is not a valid context, or was not created from a GL context.

  • CL_INVALID_EGL_OBJECT_KHR if sync is not a valid EGLSyncKHR object of type EGL_SYNC_FENCE_KHR created with respect to EGLDisplay display.

See Also

Document Notes

For more information, see the OpenCL Specification

This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2025 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0