1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010-2011 LunarG, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
32 * Public EGL API entrypoints
34 * Generally, we use the EGLDisplay parameter as a key to lookup the
35 * appropriate device driver handle, then jump though the driver's
36 * dispatch table to handle the function.
38 * That allows us the option of supporting multiple, simultaneous,
39 * heterogeneous hardware devices in the future.
41 * The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are
42 * opaque handles. Internal objects are linked to a display to
45 * For each public API entry point, the opaque handles are looked up
46 * before being dispatched to the drivers. When it fails to look up
56 * is generated and the driver function is not called. An
57 * uninitialized EGLDisplay has no driver associated with it. When
58 * such display is detected,
64 * Some of the entry points use current display, context, or surface
65 * implicitly. For such entry points, the implicit objects are also
66 * checked before calling the driver function. Other than the
67 * errors listed above,
69 * EGL_BAD_CURRENT_SURFACE
71 * may also be generated.
73 * Notes on naming conventions:
75 * eglFooBar - public EGL function
76 * EGL_FOO_BAR - public EGL token
77 * EGLDatatype - public EGL datatype
79 * _eglFooBar - private EGL function
80 * _EGLDatatype - private EGL datatype, typedef'd struct
81 * _egl_struct - private EGL struct, non-typedef'd
89 #include "c99_compat.h"
90 #include "c11/threads.h"
91 #include "GL/mesa_glinterop.h"
92 #include "eglcompiler.h"
94 #include "eglglobals.h"
95 #include "eglcontext.h"
96 #include "egldisplay.h"
97 #include "egltypedefs.h"
98 #include "eglcurrent.h"
99 #include "egldriver.h"
100 #include "eglsurface.h"
101 #include "eglconfig.h"
102 #include "eglimage.h"
107 * Macros to help return an API entrypoint.
109 * These macros will unlock the display and record the error code.
111 #define RETURN_EGL_ERROR(disp, err, ret) \
114 _eglUnlockDisplay(disp); \
115 /* EGL error codes are non-zero */ \
117 _eglError(err, __func__); \
121 #define RETURN_EGL_SUCCESS(disp, ret) \
122 RETURN_EGL_ERROR(disp, EGL_SUCCESS, ret)
124 /* record EGL_SUCCESS only when ret evaluates to true */
125 #define RETURN_EGL_EVAL(disp, ret) \
126 RETURN_EGL_ERROR(disp, (ret) ? EGL_SUCCESS : 0, ret)
130 * A bunch of macros and checks to simplify error checking.
133 #define _EGL_CHECK_DISPLAY(disp, ret, drv) \
135 drv = _eglCheckDisplay(disp, __func__); \
137 RETURN_EGL_ERROR(disp, 0, ret); \
140 #define _EGL_CHECK_OBJECT(disp, type, obj, ret, drv) \
142 drv = _eglCheck ## type(disp, obj, __func__); \
144 RETURN_EGL_ERROR(disp, 0, ret); \
147 #define _EGL_CHECK_SURFACE(disp, surf, ret, drv) \
148 _EGL_CHECK_OBJECT(disp, Surface, surf, ret, drv)
150 #define _EGL_CHECK_CONTEXT(disp, context, ret, drv) \
151 _EGL_CHECK_OBJECT(disp, Context, context, ret, drv)
153 #define _EGL_CHECK_CONFIG(disp, conf, ret, drv) \
154 _EGL_CHECK_OBJECT(disp, Config, conf, ret, drv)
156 #define _EGL_CHECK_SYNC(disp, s, ret, drv) \
157 _EGL_CHECK_OBJECT(disp, Sync, s, ret, drv)
160 static inline _EGLDriver
*
161 _eglCheckDisplay(_EGLDisplay
*disp
, const char *msg
)
164 _eglError(EGL_BAD_DISPLAY
, msg
);
167 if (!disp
->Initialized
) {
168 _eglError(EGL_NOT_INITIALIZED
, msg
);
175 static inline _EGLDriver
*
176 _eglCheckSurface(_EGLDisplay
*disp
, _EGLSurface
*surf
, const char *msg
)
178 _EGLDriver
*drv
= _eglCheckDisplay(disp
, msg
);
182 _eglError(EGL_BAD_SURFACE
, msg
);
189 static inline _EGLDriver
*
190 _eglCheckContext(_EGLDisplay
*disp
, _EGLContext
*context
, const char *msg
)
192 _EGLDriver
*drv
= _eglCheckDisplay(disp
, msg
);
196 _eglError(EGL_BAD_CONTEXT
, msg
);
203 static inline _EGLDriver
*
204 _eglCheckConfig(_EGLDisplay
*disp
, _EGLConfig
*conf
, const char *msg
)
206 _EGLDriver
*drv
= _eglCheckDisplay(disp
, msg
);
210 _eglError(EGL_BAD_CONFIG
, msg
);
217 static inline _EGLDriver
*
218 _eglCheckSync(_EGLDisplay
*disp
, _EGLSync
*s
, const char *msg
)
220 _EGLDriver
*drv
= _eglCheckDisplay(disp
, msg
);
224 _eglError(EGL_BAD_PARAMETER
, msg
);
232 * Lookup and lock a display.
234 static inline _EGLDisplay
*
235 _eglLockDisplay(EGLDisplay display
)
237 _EGLDisplay
*dpy
= _eglLookupDisplay(display
);
239 mtx_lock(&dpy
->Mutex
);
248 _eglUnlockDisplay(_EGLDisplay
*dpy
)
250 mtx_unlock(&dpy
->Mutex
);
255 * Convert an attribute list from EGLint[] to EGLAttrib[].
257 * Return an EGL error code. The output parameter out_attrib_list is modified
261 _eglConvertIntsToAttribs(const EGLint
*int_list
, EGLAttrib
**out_attrib_list
)
264 EGLAttrib
*attrib_list
;
267 while (int_list
[2*len
] != EGL_NONE
)
272 *out_attrib_list
= NULL
;
276 if (2*len
+ 1 > SIZE_MAX
/ sizeof(EGLAttrib
))
277 return EGL_BAD_ALLOC
;
279 attrib_list
= malloc((2*len
+ 1) * sizeof(EGLAttrib
));
281 return EGL_BAD_ALLOC
;
283 for (size_t i
= 0; i
< len
; ++i
) {
284 attrib_list
[2*i
+ 0] = int_list
[2*i
+ 0];
285 attrib_list
[2*i
+ 1] = int_list
[2*i
+ 1];
288 attrib_list
[2*len
] = EGL_NONE
;
290 *out_attrib_list
= attrib_list
;
296 _eglConvertAttribsToInt(const EGLAttrib
*attr_list
)
298 EGLint
*int_attribs
= NULL
;
300 /* Convert attributes from EGLAttrib[] to EGLint[] */
304 while (attr_list
[size
] != EGL_NONE
)
307 size
+= 1; /* add space for EGL_NONE */
309 int_attribs
= calloc(size
, sizeof(int_attribs
[0]));
313 for (i
= 0; i
< size
; i
++)
314 int_attribs
[i
] = attr_list
[i
];
321 * This is typically the first EGL function that an application calls.
322 * It associates a private _EGLDisplay object to the native display.
324 EGLDisplay EGLAPIENTRY
325 eglGetDisplay(EGLNativeDisplayType nativeDisplay
)
327 _EGLPlatformType plat
;
329 void *native_display_ptr
;
331 STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay
));
332 native_display_ptr
= (void*) nativeDisplay
;
334 plat
= _eglGetNativePlatform(native_display_ptr
);
335 dpy
= _eglFindDisplay(plat
, native_display_ptr
);
336 return _eglGetDisplayHandle(dpy
);
340 _eglGetPlatformDisplayCommon(EGLenum platform
, void *native_display
,
341 const EGLint
*attrib_list
)
346 #ifdef HAVE_X11_PLATFORM
347 case EGL_PLATFORM_X11_EXT
:
348 dpy
= _eglGetX11Display((Display
*) native_display
, attrib_list
);
351 #ifdef HAVE_DRM_PLATFORM
352 case EGL_PLATFORM_GBM_MESA
:
353 dpy
= _eglGetGbmDisplay((struct gbm_device
*) native_display
,
357 #ifdef HAVE_WAYLAND_PLATFORM
358 case EGL_PLATFORM_WAYLAND_EXT
:
359 dpy
= _eglGetWaylandDisplay((struct wl_display
*) native_display
,
364 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, NULL
);
367 return _eglGetDisplayHandle(dpy
);
370 static EGLDisplay EGLAPIENTRY
371 eglGetPlatformDisplayEXT(EGLenum platform
, void *native_display
,
372 const EGLint
*attrib_list
)
374 return _eglGetPlatformDisplayCommon(platform
, native_display
, attrib_list
);
377 EGLDisplay EGLAPIENTRY
378 eglGetPlatformDisplay(EGLenum platform
, void *native_display
,
379 const EGLAttrib
*attrib_list
)
384 int_attribs
= _eglConvertAttribsToInt(attrib_list
);
385 if (attrib_list
&& !int_attribs
)
386 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, NULL
);
388 display
= _eglGetPlatformDisplayCommon(platform
, native_display
, int_attribs
);
394 * Copy the extension into the string and update the string pointer.
397 _eglAppendExtension(char **str
, const char *ext
)
400 size_t len
= strlen(ext
);
417 * Examine the individual extension enable/disable flags and recompute
418 * the driver's Extensions string.
421 _eglCreateExtensionsString(_EGLDisplay
*dpy
)
423 #define _EGL_CHECK_EXTENSION(ext) \
425 if (dpy->Extensions.ext) { \
426 _eglAppendExtension(&exts, "EGL_" #ext); \
427 assert(exts <= dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN); \
431 char *exts
= dpy
->ExtensionsString
;
433 /* Please keep these sorted alphabetically. */
434 _EGL_CHECK_EXTENSION(ANDROID_framebuffer_target
);
435 _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer
);
436 _EGL_CHECK_EXTENSION(ANDROID_recordable
);
438 _EGL_CHECK_EXTENSION(CHROMIUM_sync_control
);
440 _EGL_CHECK_EXTENSION(EXT_buffer_age
);
441 _EGL_CHECK_EXTENSION(EXT_create_context_robustness
);
442 _EGL_CHECK_EXTENSION(EXT_image_dma_buf_import
);
443 _EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage
);
445 _EGL_CHECK_EXTENSION(KHR_cl_event2
);
446 _EGL_CHECK_EXTENSION(KHR_create_context
);
447 _EGL_CHECK_EXTENSION(KHR_fence_sync
);
448 _EGL_CHECK_EXTENSION(KHR_get_all_proc_addresses
);
449 _EGL_CHECK_EXTENSION(KHR_gl_colorspace
);
450 _EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image
);
451 _EGL_CHECK_EXTENSION(KHR_gl_texture_2D_image
);
452 _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image
);
453 _EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image
);
454 if (dpy
->Extensions
.KHR_image_base
&& dpy
->Extensions
.KHR_image_pixmap
)
455 _eglAppendExtension(&exts
, "EGL_KHR_image");
456 _EGL_CHECK_EXTENSION(KHR_image_base
);
457 _EGL_CHECK_EXTENSION(KHR_image_pixmap
);
458 _EGL_CHECK_EXTENSION(KHR_no_config_context
);
459 _EGL_CHECK_EXTENSION(KHR_reusable_sync
);
460 _EGL_CHECK_EXTENSION(KHR_surfaceless_context
);
461 _EGL_CHECK_EXTENSION(KHR_wait_sync
);
463 if (dpy
->Extensions
.KHR_no_config_context
)
464 _eglAppendExtension(&exts
, "EGL_MESA_configless_context");
465 _EGL_CHECK_EXTENSION(MESA_drm_image
);
466 _EGL_CHECK_EXTENSION(MESA_image_dma_buf_export
);
468 _EGL_CHECK_EXTENSION(NOK_swap_region
);
469 _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap
);
471 _EGL_CHECK_EXTENSION(NV_post_sub_buffer
);
473 _EGL_CHECK_EXTENSION(WL_bind_wayland_display
);
474 _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image
);
476 #undef _EGL_CHECK_EXTENSION
480 _eglCreateAPIsString(_EGLDisplay
*dpy
)
482 if (dpy
->ClientAPIs
& EGL_OPENGL_BIT
)
483 strcat(dpy
->ClientAPIsString
, "OpenGL ");
485 if (dpy
->ClientAPIs
& EGL_OPENGL_ES_BIT
||
486 dpy
->ClientAPIs
& EGL_OPENGL_ES2_BIT
||
487 dpy
->ClientAPIs
& EGL_OPENGL_ES3_BIT_KHR
) {
488 strcat(dpy
->ClientAPIsString
, "OpenGL_ES ");
491 if (dpy
->ClientAPIs
& EGL_OPENVG_BIT
)
492 strcat(dpy
->ClientAPIsString
, "OpenVG ");
494 assert(strlen(dpy
->ClientAPIsString
) < sizeof(dpy
->ClientAPIsString
));
498 _eglComputeVersion(_EGLDisplay
*disp
)
502 if (disp
->Extensions
.KHR_fence_sync
&&
503 disp
->Extensions
.KHR_cl_event2
&&
504 disp
->Extensions
.KHR_wait_sync
&&
505 disp
->Extensions
.KHR_image_base
&&
506 disp
->Extensions
.KHR_gl_texture_2D_image
&&
507 disp
->Extensions
.KHR_gl_texture_3D_image
&&
508 disp
->Extensions
.KHR_gl_texture_cubemap_image
&&
509 disp
->Extensions
.KHR_gl_renderbuffer_image
&&
510 disp
->Extensions
.KHR_create_context
&&
511 disp
->Extensions
.EXT_create_context_robustness
&&
512 disp
->Extensions
.KHR_get_all_proc_addresses
&&
513 disp
->Extensions
.KHR_gl_colorspace
&&
514 disp
->Extensions
.KHR_surfaceless_context
)
519 * This is typically the second EGL function that an application calls.
520 * Here we load/initialize the actual hardware driver.
522 EGLBoolean EGLAPIENTRY
523 eglInitialize(EGLDisplay dpy
, EGLint
*major
, EGLint
*minor
)
525 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
528 RETURN_EGL_ERROR(NULL
, EGL_BAD_DISPLAY
, EGL_FALSE
);
530 if (!disp
->Initialized
) {
531 if (!_eglMatchDriver(disp
, EGL_FALSE
))
532 RETURN_EGL_ERROR(disp
, EGL_NOT_INITIALIZED
, EGL_FALSE
);
534 /* limit to APIs supported by core */
535 disp
->ClientAPIs
&= _EGL_API_ALL_BITS
;
537 /* EGL_KHR_get_all_proc_addresses is a corner-case extension. The spec
538 * classifies it as an EGL display extension, though conceptually it's an
539 * EGL client extension.
541 * From the EGL_KHR_get_all_proc_addresses spec:
543 * The EGL implementation must expose the name
544 * EGL_KHR_client_get_all_proc_addresses if and only if it exposes
545 * EGL_KHR_get_all_proc_addresses and supports
546 * EGL_EXT_client_extensions.
548 * Mesa unconditionally exposes both client extensions mentioned above,
549 * so the spec requires that each EGLDisplay unconditionally expose
550 * EGL_KHR_get_all_proc_addresses also.
552 disp
->Extensions
.KHR_get_all_proc_addresses
= EGL_TRUE
;
554 _eglComputeVersion(disp
);
555 _eglCreateExtensionsString(disp
);
556 _eglCreateAPIsString(disp
);
557 snprintf(disp
->VersionString
, sizeof(disp
->VersionString
),
558 "%d.%d (%s)", disp
->Version
/ 10, disp
->Version
% 10,
562 /* Update applications version of major and minor if not NULL */
563 if ((major
!= NULL
) && (minor
!= NULL
)) {
564 *major
= disp
->Version
/ 10;
565 *minor
= disp
->Version
% 10;
568 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
572 EGLBoolean EGLAPIENTRY
573 eglTerminate(EGLDisplay dpy
)
575 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
578 RETURN_EGL_ERROR(NULL
, EGL_BAD_DISPLAY
, EGL_FALSE
);
580 if (disp
->Initialized
) {
581 _EGLDriver
*drv
= disp
->Driver
;
583 drv
->API
.Terminate(drv
, disp
);
584 /* do not reset disp->Driver */
585 disp
->ClientAPIsString
[0] = 0;
586 disp
->Initialized
= EGL_FALSE
;
589 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
593 const char * EGLAPIENTRY
594 eglQueryString(EGLDisplay dpy
, EGLint name
)
599 if (dpy
== EGL_NO_DISPLAY
&& name
== EGL_EXTENSIONS
) {
600 RETURN_EGL_SUCCESS(NULL
, _eglGlobal
.ClientExtensionString
);
603 disp
= _eglLockDisplay(dpy
);
604 _EGL_CHECK_DISPLAY(disp
, NULL
, drv
);
608 RETURN_EGL_SUCCESS(disp
, _EGL_VENDOR_STRING
);
610 RETURN_EGL_SUCCESS(disp
, disp
->VersionString
);
612 RETURN_EGL_SUCCESS(disp
, disp
->ExtensionsString
);
613 case EGL_CLIENT_APIS
:
614 RETURN_EGL_SUCCESS(disp
, disp
->ClientAPIsString
);
616 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, NULL
);
621 EGLBoolean EGLAPIENTRY
622 eglGetConfigs(EGLDisplay dpy
, EGLConfig
*configs
,
623 EGLint config_size
, EGLint
*num_config
)
625 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
629 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
630 ret
= drv
->API
.GetConfigs(drv
, disp
, configs
, config_size
, num_config
);
632 RETURN_EGL_EVAL(disp
, ret
);
636 EGLBoolean EGLAPIENTRY
637 eglChooseConfig(EGLDisplay dpy
, const EGLint
*attrib_list
, EGLConfig
*configs
,
638 EGLint config_size
, EGLint
*num_config
)
640 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
644 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
645 ret
= drv
->API
.ChooseConfig(drv
, disp
, attrib_list
, configs
,
646 config_size
, num_config
);
648 RETURN_EGL_EVAL(disp
, ret
);
652 EGLBoolean EGLAPIENTRY
653 eglGetConfigAttrib(EGLDisplay dpy
, EGLConfig config
,
654 EGLint attribute
, EGLint
*value
)
656 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
657 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
661 _EGL_CHECK_CONFIG(disp
, conf
, EGL_FALSE
, drv
);
662 ret
= drv
->API
.GetConfigAttrib(drv
, disp
, conf
, attribute
, value
);
664 RETURN_EGL_EVAL(disp
, ret
);
668 EGLContext EGLAPIENTRY
669 eglCreateContext(EGLDisplay dpy
, EGLConfig config
, EGLContext share_list
,
670 const EGLint
*attrib_list
)
672 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
673 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
674 _EGLContext
*share
= _eglLookupContext(share_list
, disp
);
676 _EGLContext
*context
;
679 _EGL_CHECK_DISPLAY(disp
, EGL_NO_CONTEXT
, drv
);
681 if (!config
&& !disp
->Extensions
.KHR_no_config_context
)
682 RETURN_EGL_ERROR(disp
, EGL_BAD_CONFIG
, EGL_NO_CONTEXT
);
684 if (!share
&& share_list
!= EGL_NO_CONTEXT
)
685 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_CONTEXT
);
687 context
= drv
->API
.CreateContext(drv
, disp
, conf
, share
, attrib_list
);
688 ret
= (context
) ? _eglLinkContext(context
) : EGL_NO_CONTEXT
;
690 RETURN_EGL_EVAL(disp
, ret
);
694 EGLBoolean EGLAPIENTRY
695 eglDestroyContext(EGLDisplay dpy
, EGLContext ctx
)
697 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
698 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
702 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
703 _eglUnlinkContext(context
);
704 ret
= drv
->API
.DestroyContext(drv
, disp
, context
);
706 RETURN_EGL_EVAL(disp
, ret
);
710 EGLBoolean EGLAPIENTRY
711 eglMakeCurrent(EGLDisplay dpy
, EGLSurface draw
, EGLSurface read
,
714 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
715 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
716 _EGLSurface
*draw_surf
= _eglLookupSurface(draw
, disp
);
717 _EGLSurface
*read_surf
= _eglLookupSurface(read
, disp
);
722 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
725 /* display is allowed to be uninitialized under certain condition */
726 if (!disp
->Initialized
) {
727 if (draw
!= EGL_NO_SURFACE
|| read
!= EGL_NO_SURFACE
||
728 ctx
!= EGL_NO_CONTEXT
)
729 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
732 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
734 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
735 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
736 if (!draw_surf
|| !read_surf
) {
737 /* From the EGL 1.4 (20130211) spec:
739 * To release the current context without assigning a new one, set ctx
740 * to EGL_NO_CONTEXT and set draw and read to EGL_NO_SURFACE.
742 if (!disp
->Extensions
.KHR_surfaceless_context
&& ctx
!= EGL_NO_CONTEXT
)
743 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
745 if ((!draw_surf
&& draw
!= EGL_NO_SURFACE
) ||
746 (!read_surf
&& read
!= EGL_NO_SURFACE
))
747 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
748 if (draw_surf
|| read_surf
)
749 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_FALSE
);
752 ret
= drv
->API
.MakeCurrent(drv
, disp
, draw_surf
, read_surf
, context
);
754 RETURN_EGL_EVAL(disp
, ret
);
758 EGLBoolean EGLAPIENTRY
759 eglQueryContext(EGLDisplay dpy
, EGLContext ctx
,
760 EGLint attribute
, EGLint
*value
)
762 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
763 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
767 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
768 ret
= drv
->API
.QueryContext(drv
, disp
, context
, attribute
, value
);
770 RETURN_EGL_EVAL(disp
, ret
);
775 _eglCreateWindowSurfaceCommon(_EGLDisplay
*disp
, EGLConfig config
,
776 void *native_window
, const EGLint
*attrib_list
)
778 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
783 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
785 if (native_window
== NULL
)
786 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_WINDOW
, EGL_NO_SURFACE
);
788 surf
= drv
->API
.CreateWindowSurface(drv
, disp
, conf
, native_window
,
790 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
792 RETURN_EGL_EVAL(disp
, ret
);
796 EGLSurface EGLAPIENTRY
797 eglCreateWindowSurface(EGLDisplay dpy
, EGLConfig config
,
798 EGLNativeWindowType window
, const EGLint
*attrib_list
)
800 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
801 STATIC_ASSERT(sizeof(void*) == sizeof(window
));
802 return _eglCreateWindowSurfaceCommon(disp
, config
, (void*) window
,
807 fixupNativeWindow(_EGLDisplay
*disp
, void *native_window
)
809 #ifdef HAVE_X11_PLATFORM
810 if (disp
->Platform
== _EGL_PLATFORM_X11
&& native_window
!= NULL
) {
811 /* The `native_window` parameter for the X11 platform differs between
812 * eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
813 * eglCreateWindowSurface(), the type of `native_window` is an Xlib
814 * `Window`. In eglCreatePlatformWindowSurfaceEXT(), the type is
815 * `Window*`. Convert `Window*` to `Window` because that's what
816 * dri2_x11_create_window_surface() expects.
818 return (void *)(* (Window
*) native_window
);
821 return native_window
;
824 static EGLSurface EGLAPIENTRY
825 eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy
, EGLConfig config
,
827 const EGLint
*attrib_list
)
829 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
831 native_window
= fixupNativeWindow(disp
, native_window
);
833 return _eglCreateWindowSurfaceCommon(disp
, config
, native_window
,
838 EGLSurface EGLAPIENTRY
839 eglCreatePlatformWindowSurface(EGLDisplay dpy
, EGLConfig config
,
841 const EGLAttrib
*attrib_list
)
843 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
845 EGLint
*int_attribs
= _eglConvertAttribsToInt(attrib_list
);
847 if (attrib_list
&& !int_attribs
)
848 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_NO_SURFACE
);
850 native_window
= fixupNativeWindow(disp
, native_window
);
851 surface
= _eglCreateWindowSurfaceCommon(disp
, config
, native_window
,
858 fixupNativePixmap(_EGLDisplay
*disp
, void *native_pixmap
)
860 #ifdef HAVE_X11_PLATFORM
861 /* The `native_pixmap` parameter for the X11 platform differs between
862 * eglCreatePixmapSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
863 * eglCreatePixmapSurface(), the type of `native_pixmap` is an Xlib
864 * `Pixmap`. In eglCreatePlatformPixmapSurfaceEXT(), the type is
865 * `Pixmap*`. Convert `Pixmap*` to `Pixmap` because that's what
866 * dri2_x11_create_pixmap_surface() expects.
868 if (disp
->Platform
== _EGL_PLATFORM_X11
&& native_pixmap
!= NULL
)
869 return (void *)(* (Pixmap
*) native_pixmap
);
871 return native_pixmap
;
875 _eglCreatePixmapSurfaceCommon(_EGLDisplay
*disp
, EGLConfig config
,
876 void *native_pixmap
, const EGLint
*attrib_list
)
878 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
883 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
884 surf
= drv
->API
.CreatePixmapSurface(drv
, disp
, conf
, native_pixmap
,
886 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
888 RETURN_EGL_EVAL(disp
, ret
);
892 EGLSurface EGLAPIENTRY
893 eglCreatePixmapSurface(EGLDisplay dpy
, EGLConfig config
,
894 EGLNativePixmapType pixmap
, const EGLint
*attrib_list
)
896 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
897 STATIC_ASSERT(sizeof(void*) == sizeof(pixmap
));
898 return _eglCreatePixmapSurfaceCommon(disp
, config
, (void*) pixmap
,
902 static EGLSurface EGLAPIENTRY
903 eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy
, EGLConfig config
,
905 const EGLint
*attrib_list
)
907 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
909 native_pixmap
= fixupNativePixmap(disp
, native_pixmap
);
910 return _eglCreatePixmapSurfaceCommon(disp
, config
, native_pixmap
,
915 EGLSurface EGLAPIENTRY
916 eglCreatePlatformPixmapSurface(EGLDisplay dpy
, EGLConfig config
,
918 const EGLAttrib
*attrib_list
)
920 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
922 EGLint
*int_attribs
= _eglConvertAttribsToInt(attrib_list
);
924 if (attrib_list
&& !int_attribs
)
925 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_NO_SURFACE
);
927 native_pixmap
= fixupNativePixmap(disp
, native_pixmap
);
928 surface
= _eglCreatePixmapSurfaceCommon(disp
, config
, native_pixmap
,
935 EGLSurface EGLAPIENTRY
936 eglCreatePbufferSurface(EGLDisplay dpy
, EGLConfig config
,
937 const EGLint
*attrib_list
)
939 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
940 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
945 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
947 surf
= drv
->API
.CreatePbufferSurface(drv
, disp
, conf
, attrib_list
);
948 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
950 RETURN_EGL_EVAL(disp
, ret
);
954 EGLBoolean EGLAPIENTRY
955 eglDestroySurface(EGLDisplay dpy
, EGLSurface surface
)
957 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
958 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
962 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
963 _eglUnlinkSurface(surf
);
964 ret
= drv
->API
.DestroySurface(drv
, disp
, surf
);
966 RETURN_EGL_EVAL(disp
, ret
);
969 EGLBoolean EGLAPIENTRY
970 eglQuerySurface(EGLDisplay dpy
, EGLSurface surface
,
971 EGLint attribute
, EGLint
*value
)
973 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
974 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
978 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
979 ret
= drv
->API
.QuerySurface(drv
, disp
, surf
, attribute
, value
);
981 RETURN_EGL_EVAL(disp
, ret
);
984 EGLBoolean EGLAPIENTRY
985 eglSurfaceAttrib(EGLDisplay dpy
, EGLSurface surface
,
986 EGLint attribute
, EGLint value
)
988 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
989 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
993 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
994 ret
= drv
->API
.SurfaceAttrib(drv
, disp
, surf
, attribute
, value
);
996 RETURN_EGL_EVAL(disp
, ret
);
1000 EGLBoolean EGLAPIENTRY
1001 eglBindTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
1003 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1004 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1008 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1009 ret
= drv
->API
.BindTexImage(drv
, disp
, surf
, buffer
);
1011 RETURN_EGL_EVAL(disp
, ret
);
1015 EGLBoolean EGLAPIENTRY
1016 eglReleaseTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
1018 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1019 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1023 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1024 ret
= drv
->API
.ReleaseTexImage(drv
, disp
, surf
, buffer
);
1026 RETURN_EGL_EVAL(disp
, ret
);
1030 EGLBoolean EGLAPIENTRY
1031 eglSwapInterval(EGLDisplay dpy
, EGLint interval
)
1033 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1034 _EGLContext
*ctx
= _eglGetCurrentContext();
1039 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1041 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1042 ctx
->Resource
.Display
!= disp
)
1043 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
1045 surf
= ctx
->DrawSurface
;
1046 if (_eglGetSurfaceHandle(surf
) == EGL_NO_SURFACE
)
1047 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1049 ret
= drv
->API
.SwapInterval(drv
, disp
, surf
, interval
);
1051 RETURN_EGL_EVAL(disp
, ret
);
1055 EGLBoolean EGLAPIENTRY
1056 eglSwapBuffers(EGLDisplay dpy
, EGLSurface surface
)
1058 _EGLContext
*ctx
= _eglGetCurrentContext();
1059 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1060 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1064 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1066 /* surface must be bound to current context in EGL 1.4 */
1067 #ifndef _EGL_BUILT_IN_DRIVER_HAIKU
1068 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1069 surf
!= ctx
->DrawSurface
)
1070 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1073 ret
= drv
->API
.SwapBuffers(drv
, disp
, surf
);
1075 RETURN_EGL_EVAL(disp
, ret
);
1079 static EGLBoolean EGLAPIENTRY
1080 eglSwapBuffersWithDamageEXT(EGLDisplay dpy
, EGLSurface surface
,
1081 EGLint
*rects
, EGLint n_rects
)
1083 _EGLContext
*ctx
= _eglGetCurrentContext();
1084 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1085 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1089 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1091 /* surface must be bound to current context in EGL 1.4 */
1092 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1093 surf
!= ctx
->DrawSurface
)
1094 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1096 if ((n_rects
> 0 && rects
== NULL
) || n_rects
< 0)
1097 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1099 ret
= drv
->API
.SwapBuffersWithDamageEXT(drv
, disp
, surf
, rects
, n_rects
);
1101 RETURN_EGL_EVAL(disp
, ret
);
1104 EGLBoolean EGLAPIENTRY
1105 eglCopyBuffers(EGLDisplay dpy
, EGLSurface surface
, EGLNativePixmapType target
)
1107 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1108 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1111 void *native_pixmap_ptr
;
1113 STATIC_ASSERT(sizeof(void*) == sizeof(target
));
1114 native_pixmap_ptr
= (void*) target
;
1116 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1117 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
1118 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_PIXMAP
, EGL_FALSE
);
1119 ret
= drv
->API
.CopyBuffers(drv
, disp
, surf
, native_pixmap_ptr
);
1121 RETURN_EGL_EVAL(disp
, ret
);
1126 _eglWaitClientCommon(void)
1128 _EGLContext
*ctx
= _eglGetCurrentContext();
1134 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1136 disp
= ctx
->Resource
.Display
;
1137 mtx_lock(&disp
->Mutex
);
1139 /* let bad current context imply bad current surface */
1140 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1141 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
1142 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
1144 /* a valid current context implies an initialized current display */
1145 assert(disp
->Initialized
);
1147 ret
= drv
->API
.WaitClient(drv
, disp
, ctx
);
1149 RETURN_EGL_EVAL(disp
, ret
);
1152 EGLBoolean EGLAPIENTRY
1155 return _eglWaitClientCommon();
1158 EGLBoolean EGLAPIENTRY
1161 /* Since we only support OpenGL and GLES, eglWaitGL is equivalent to eglWaitClient. */
1162 return _eglWaitClientCommon();
1166 EGLBoolean EGLAPIENTRY
1167 eglWaitNative(EGLint engine
)
1169 _EGLContext
*ctx
= _eglGetCurrentContext();
1175 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1177 disp
= ctx
->Resource
.Display
;
1178 mtx_lock(&disp
->Mutex
);
1180 /* let bad current context imply bad current surface */
1181 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1182 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
1183 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
1185 /* a valid current context implies an initialized current display */
1186 assert(disp
->Initialized
);
1188 ret
= drv
->API
.WaitNative(drv
, disp
, engine
);
1190 RETURN_EGL_EVAL(disp
, ret
);
1194 EGLDisplay EGLAPIENTRY
1195 eglGetCurrentDisplay(void)
1197 _EGLContext
*ctx
= _eglGetCurrentContext();
1200 ret
= (ctx
) ? _eglGetDisplayHandle(ctx
->Resource
.Display
) : EGL_NO_DISPLAY
;
1202 RETURN_EGL_SUCCESS(NULL
, ret
);
1206 EGLContext EGLAPIENTRY
1207 eglGetCurrentContext(void)
1209 _EGLContext
*ctx
= _eglGetCurrentContext();
1212 ret
= _eglGetContextHandle(ctx
);
1214 RETURN_EGL_SUCCESS(NULL
, ret
);
1218 EGLSurface EGLAPIENTRY
1219 eglGetCurrentSurface(EGLint readdraw
)
1221 _EGLContext
*ctx
= _eglGetCurrentContext();
1222 EGLint err
= EGL_SUCCESS
;
1227 RETURN_EGL_SUCCESS(NULL
, EGL_NO_SURFACE
);
1231 surf
= ctx
->DrawSurface
;
1234 surf
= ctx
->ReadSurface
;
1238 err
= EGL_BAD_PARAMETER
;
1242 ret
= _eglGetSurfaceHandle(surf
);
1244 RETURN_EGL_ERROR(NULL
, err
, ret
);
1251 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1252 EGLint e
= t
->LastError
;
1253 if (!_eglIsCurrentThreadDummy())
1254 t
->LastError
= EGL_SUCCESS
;
1264 * Specify the client API to use for subsequent calls including:
1265 * eglCreateContext()
1266 * eglGetCurrentContext()
1267 * eglGetCurrentDisplay()
1268 * eglGetCurrentSurface()
1269 * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT)
1272 * See section 3.7 "Rendering Context" in the EGL specification for details.
1274 EGLBoolean EGLAPIENTRY
1275 eglBindAPI(EGLenum api
)
1277 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1279 if (_eglIsCurrentThreadDummy())
1280 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_FALSE
);
1282 if (!_eglIsApiValid(api
))
1283 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1285 t
->CurrentAPI
= api
;
1287 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1292 * Return the last value set with eglBindAPI().
1297 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1300 /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
1301 ret
= t
->CurrentAPI
;
1303 RETURN_EGL_SUCCESS(NULL
, ret
);
1307 EGLSurface EGLAPIENTRY
1308 eglCreatePbufferFromClientBuffer(EGLDisplay dpy
, EGLenum buftype
,
1309 EGLClientBuffer buffer
, EGLConfig config
,
1310 const EGLint
*attrib_list
)
1312 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1313 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1318 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1320 surf
= drv
->API
.CreatePbufferFromClientBuffer(drv
, disp
, buftype
, buffer
,
1322 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1324 RETURN_EGL_EVAL(disp
, ret
);
1328 EGLBoolean EGLAPIENTRY
1329 eglReleaseThread(void)
1331 /* unbind current contexts */
1332 if (!_eglIsCurrentThreadDummy()) {
1333 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1335 _EGLContext
*ctx
= t
->CurrentContext
;
1337 _EGLDisplay
*disp
= ctx
->Resource
.Display
;
1340 mtx_lock(&disp
->Mutex
);
1342 (void) drv
->API
.MakeCurrent(drv
, disp
, NULL
, NULL
, NULL
);
1343 mtx_unlock(&disp
->Mutex
);
1347 _eglDestroyCurrentThread();
1349 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1354 _eglCreateImageCommon(_EGLDisplay
*disp
, EGLContext ctx
, EGLenum target
,
1355 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1357 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
1362 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1363 if (!disp
->Extensions
.KHR_image_base
)
1364 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1365 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
1366 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_IMAGE_KHR
);
1367 /* "If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid display,
1368 * <ctx> must be EGL_NO_CONTEXT..."
1370 if (ctx
!= EGL_NO_CONTEXT
&& target
== EGL_LINUX_DMA_BUF_EXT
)
1371 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_NO_IMAGE_KHR
);
1373 img
= drv
->API
.CreateImageKHR(drv
,
1374 disp
, context
, target
, buffer
, attr_list
);
1375 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1377 RETURN_EGL_EVAL(disp
, ret
);
1380 static EGLImage EGLAPIENTRY
1381 eglCreateImageKHR(EGLDisplay dpy
, EGLContext ctx
, EGLenum target
,
1382 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1384 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1385 return _eglCreateImageCommon(disp
, ctx
, target
, buffer
, attr_list
);
1389 EGLImage EGLAPIENTRY
1390 eglCreateImage(EGLDisplay dpy
, EGLContext ctx
, EGLenum target
,
1391 EGLClientBuffer buffer
, const EGLAttrib
*attr_list
)
1393 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1395 EGLint
*int_attribs
= _eglConvertAttribsToInt(attr_list
);
1397 if (attr_list
&& !int_attribs
)
1398 RETURN_EGL_ERROR(disp
, EGL_BAD_ALLOC
, EGL_NO_IMAGE
);
1400 image
= _eglCreateImageCommon(disp
, ctx
, target
, buffer
, int_attribs
);
1406 EGLBoolean EGLAPIENTRY
1407 eglDestroyImage(EGLDisplay dpy
, EGLImage image
)
1409 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1410 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1414 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1415 if (!disp
->Extensions
.KHR_image_base
)
1416 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1418 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1420 _eglUnlinkImage(img
);
1421 ret
= drv
->API
.DestroyImageKHR(drv
, disp
, img
);
1423 RETURN_EGL_EVAL(disp
, ret
);
1428 _eglCreateSync(_EGLDisplay
*disp
, EGLenum type
, const EGLint
*attrib_list
,
1429 const EGLAttrib
*attrib_list64
, EGLBoolean is64
,
1430 EGLenum invalid_type_error
)
1432 _EGLContext
*ctx
= _eglGetCurrentContext();
1437 _EGL_CHECK_DISPLAY(disp
, EGL_NO_SYNC_KHR
, drv
);
1439 if (!disp
->Extensions
.KHR_cl_event2
&& is64
) {
1440 /* There exist two EGLAttrib variants of eglCreateSync*:
1441 * eglCreateSync64KHR which requires EGL_KHR_cl_event2, and eglCreateSync
1442 * which requires EGL 1.5. Here we use the presence of EGL_KHR_cl_event2
1443 * support as a proxy for EGL 1.5 support, even though that's not
1444 * entirely correct (though _eglComputeVersion does the same).
1446 * The EGL spec provides no guidance on how to handle unsupported
1447 * functions. EGL_BAD_MATCH seems reasonable.
1449 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_NO_SYNC_KHR
);
1452 /* return an error if the client API doesn't support GL_OES_EGL_sync */
1453 if (!ctx
|| ctx
->Resource
.Display
!= disp
||
1454 ctx
->ClientAPI
!= EGL_OPENGL_ES_API
)
1455 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_NO_SYNC_KHR
);
1458 case EGL_SYNC_FENCE_KHR
:
1459 if (!disp
->Extensions
.KHR_fence_sync
)
1460 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1462 case EGL_SYNC_REUSABLE_KHR
:
1463 if (!disp
->Extensions
.KHR_reusable_sync
)
1464 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1466 case EGL_SYNC_CL_EVENT_KHR
:
1467 if (!disp
->Extensions
.KHR_cl_event2
)
1468 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1471 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1474 sync
= drv
->API
.CreateSyncKHR(drv
, disp
, type
, attrib_list
, attrib_list64
);
1475 ret
= (sync
) ? _eglLinkSync(sync
) : EGL_NO_SYNC_KHR
;
1477 RETURN_EGL_EVAL(disp
, ret
);
1481 static EGLSync EGLAPIENTRY
1482 eglCreateSyncKHR(EGLDisplay dpy
, EGLenum type
, const EGLint
*attrib_list
)
1484 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1485 return _eglCreateSync(disp
, type
, attrib_list
, NULL
, EGL_FALSE
,
1490 static EGLSync EGLAPIENTRY
1491 eglCreateSync64KHR(EGLDisplay dpy
, EGLenum type
, const EGLAttrib
*attrib_list
)
1493 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1494 return _eglCreateSync(disp
, type
, NULL
, attrib_list
, EGL_TRUE
,
1500 eglCreateSync(EGLDisplay dpy
, EGLenum type
, const EGLAttrib
*attrib_list
)
1502 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1503 return _eglCreateSync(disp
, type
, NULL
, attrib_list
, EGL_TRUE
,
1508 EGLBoolean EGLAPIENTRY
1509 eglDestroySync(EGLDisplay dpy
, EGLSync sync
)
1511 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1512 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1516 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1517 assert(disp
->Extensions
.KHR_reusable_sync
||
1518 disp
->Extensions
.KHR_fence_sync
);
1521 ret
= drv
->API
.DestroySyncKHR(drv
, disp
, s
);
1523 RETURN_EGL_EVAL(disp
, ret
);
1528 eglClientWaitSync(EGLDisplay dpy
, EGLSync sync
, EGLint flags
, EGLTime timeout
)
1530 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1531 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1535 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1536 assert(disp
->Extensions
.KHR_reusable_sync
||
1537 disp
->Extensions
.KHR_fence_sync
);
1539 if (s
->SyncStatus
== EGL_SIGNALED_KHR
)
1540 RETURN_EGL_EVAL(disp
, EGL_CONDITION_SATISFIED_KHR
);
1542 /* if sync type is EGL_SYNC_REUSABLE_KHR, dpy should be
1543 * unlocked here to allow other threads also to be able to
1544 * go into waiting state.
1547 if (s
->Type
== EGL_SYNC_REUSABLE_KHR
)
1548 _eglUnlockDisplay(dpy
);
1550 ret
= drv
->API
.ClientWaitSyncKHR(drv
, disp
, s
, flags
, timeout
);
1553 * 'disp' is already unlocked for reusable sync type,
1554 * so passing 'NULL' to bypass unlocking display.
1556 if (s
->Type
== EGL_SYNC_REUSABLE_KHR
)
1557 RETURN_EGL_EVAL(NULL
, ret
);
1559 RETURN_EGL_EVAL(disp
, ret
);
1564 _eglWaitSyncCommon(_EGLDisplay
*disp
, _EGLSync
*s
, EGLint flags
)
1566 _EGLContext
*ctx
= _eglGetCurrentContext();
1570 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1571 assert(disp
->Extensions
.KHR_wait_sync
);
1573 /* return an error if the client API doesn't support GL_OES_EGL_sync */
1574 if (ctx
== EGL_NO_CONTEXT
|| ctx
->ClientAPI
!= EGL_OPENGL_ES_API
)
1575 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_FALSE
);
1577 /* the API doesn't allow any flags yet */
1579 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1581 ret
= drv
->API
.WaitSyncKHR(drv
, disp
, s
);
1583 RETURN_EGL_EVAL(disp
, ret
);
1586 static EGLint EGLAPIENTRY
1587 eglWaitSyncKHR(EGLDisplay dpy
, EGLSync sync
, EGLint flags
)
1589 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1590 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1591 return _eglWaitSyncCommon(disp
, s
, flags
);
1595 EGLBoolean EGLAPIENTRY
1596 eglWaitSync(EGLDisplay dpy
, EGLSync sync
, EGLint flags
)
1598 /* The KHR version returns EGLint, while the core version returns
1599 * EGLBoolean. In both cases, the return values can only be EGL_FALSE and
1602 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1603 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1604 return _eglWaitSyncCommon(disp
, s
, flags
);
1608 static EGLBoolean EGLAPIENTRY
1609 eglSignalSyncKHR(EGLDisplay dpy
, EGLSync sync
, EGLenum mode
)
1611 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1612 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1616 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1617 assert(disp
->Extensions
.KHR_reusable_sync
);
1618 ret
= drv
->API
.SignalSyncKHR(drv
, disp
, s
, mode
);
1620 RETURN_EGL_EVAL(disp
, ret
);
1625 _eglGetSyncAttribCommon(_EGLDisplay
*disp
, _EGLSync
*s
, EGLint attribute
, EGLAttrib
*value
)
1630 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1631 assert(disp
->Extensions
.KHR_reusable_sync
||
1632 disp
->Extensions
.KHR_fence_sync
);
1633 ret
= drv
->API
.GetSyncAttrib(drv
, disp
, s
, attribute
, value
);
1635 RETURN_EGL_EVAL(disp
, ret
);
1638 EGLBoolean EGLAPIENTRY
1639 eglGetSyncAttrib(EGLDisplay dpy
, EGLSync sync
, EGLint attribute
, EGLAttrib
*value
)
1641 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1642 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1643 return _eglGetSyncAttribCommon(disp
, s
, attribute
, value
);
1647 static EGLBoolean EGLAPIENTRY
1648 eglGetSyncAttribKHR(EGLDisplay dpy
, EGLSync sync
, EGLint attribute
, EGLint
*value
)
1650 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1651 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1656 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1659 result
= _eglGetSyncAttribCommon(disp
, s
, attribute
, &attrib
);
1661 /* The EGL_KHR_fence_sync spec says this about eglGetSyncAttribKHR:
1663 * If any error occurs, <*value> is not modified.
1665 if (result
== EGL_FALSE
)
1673 static EGLBoolean EGLAPIENTRY
1674 eglSwapBuffersRegionNOK(EGLDisplay dpy
, EGLSurface surface
,
1675 EGLint numRects
, const EGLint
*rects
)
1677 _EGLContext
*ctx
= _eglGetCurrentContext();
1678 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1679 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1683 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1685 if (!disp
->Extensions
.NOK_swap_region
)
1686 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1688 /* surface must be bound to current context in EGL 1.4 */
1689 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1690 surf
!= ctx
->DrawSurface
)
1691 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1693 ret
= drv
->API
.SwapBuffersRegionNOK(drv
, disp
, surf
, numRects
, rects
);
1695 RETURN_EGL_EVAL(disp
, ret
);
1699 static EGLImage EGLAPIENTRY
1700 eglCreateDRMImageMESA(EGLDisplay dpy
, const EGLint
*attr_list
)
1702 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1707 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1708 if (!disp
->Extensions
.MESA_drm_image
)
1709 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1711 img
= drv
->API
.CreateDRMImageMESA(drv
, disp
, attr_list
);
1712 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1714 RETURN_EGL_EVAL(disp
, ret
);
1717 static EGLBoolean EGLAPIENTRY
1718 eglExportDRMImageMESA(EGLDisplay dpy
, EGLImage image
,
1719 EGLint
*name
, EGLint
*handle
, EGLint
*stride
)
1721 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1722 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1726 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1727 assert(disp
->Extensions
.MESA_drm_image
);
1730 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1732 ret
= drv
->API
.ExportDRMImageMESA(drv
, disp
, img
, name
, handle
, stride
);
1734 RETURN_EGL_EVAL(disp
, ret
);
1740 static EGLBoolean EGLAPIENTRY
1741 eglBindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1743 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1747 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1748 assert(disp
->Extensions
.WL_bind_wayland_display
);
1751 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1753 ret
= drv
->API
.BindWaylandDisplayWL(drv
, disp
, display
);
1755 RETURN_EGL_EVAL(disp
, ret
);
1758 static EGLBoolean EGLAPIENTRY
1759 eglUnbindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1761 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1765 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1766 assert(disp
->Extensions
.WL_bind_wayland_display
);
1769 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1771 ret
= drv
->API
.UnbindWaylandDisplayWL(drv
, disp
, display
);
1773 RETURN_EGL_EVAL(disp
, ret
);
1776 static EGLBoolean EGLAPIENTRY
1777 eglQueryWaylandBufferWL(EGLDisplay dpy
, struct wl_resource
*buffer
,
1778 EGLint attribute
, EGLint
*value
)
1780 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1784 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1785 assert(disp
->Extensions
.WL_bind_wayland_display
);
1788 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1790 ret
= drv
->API
.QueryWaylandBufferWL(drv
, disp
, buffer
, attribute
, value
);
1792 RETURN_EGL_EVAL(disp
, ret
);
1796 static struct wl_buffer
* EGLAPIENTRY
1797 eglCreateWaylandBufferFromImageWL(EGLDisplay dpy
, EGLImage image
)
1799 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1802 struct wl_buffer
*ret
;
1804 _EGL_CHECK_DISPLAY(disp
, NULL
, drv
);
1805 assert(disp
->Extensions
.WL_create_wayland_buffer_from_image
);
1807 img
= _eglLookupImage(image
, disp
);
1810 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, NULL
);
1812 ret
= drv
->API
.CreateWaylandBufferFromImageWL(drv
, disp
, img
);
1814 RETURN_EGL_EVAL(disp
, ret
);
1817 static EGLBoolean EGLAPIENTRY
1818 eglPostSubBufferNV(EGLDisplay dpy
, EGLSurface surface
,
1819 EGLint x
, EGLint y
, EGLint width
, EGLint height
)
1821 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1822 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1826 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1828 if (!disp
->Extensions
.NV_post_sub_buffer
)
1829 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1831 ret
= drv
->API
.PostSubBufferNV(drv
, disp
, surf
, x
, y
, width
, height
);
1833 RETURN_EGL_EVAL(disp
, ret
);
1836 static EGLBoolean EGLAPIENTRY
1837 eglGetSyncValuesCHROMIUM(EGLDisplay display
, EGLSurface surface
,
1838 EGLuint64KHR
*ust
, EGLuint64KHR
*msc
,
1841 _EGLDisplay
*disp
= _eglLockDisplay(display
);
1842 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1846 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1847 if (!disp
->Extensions
.CHROMIUM_sync_control
)
1848 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1850 if (!ust
|| !msc
|| !sbc
)
1851 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1853 ret
= drv
->API
.GetSyncValuesCHROMIUM(disp
, surf
, ust
, msc
, sbc
);
1855 RETURN_EGL_EVAL(disp
, ret
);
1858 static EGLBoolean EGLAPIENTRY
1859 eglExportDMABUFImageQueryMESA(EGLDisplay dpy
, EGLImage image
,
1860 EGLint
*fourcc
, EGLint
*nplanes
,
1861 EGLuint64KHR
*modifiers
)
1863 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1864 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1868 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1869 assert(disp
->Extensions
.MESA_image_dma_buf_export
);
1872 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1874 ret
= drv
->API
.ExportDMABUFImageQueryMESA(drv
, disp
, img
, fourcc
, nplanes
,
1877 RETURN_EGL_EVAL(disp
, ret
);
1880 static EGLBoolean EGLAPIENTRY
1881 eglExportDMABUFImageMESA(EGLDisplay dpy
, EGLImage image
,
1882 int *fds
, EGLint
*strides
, EGLint
*offsets
)
1884 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1885 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1889 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1890 assert(disp
->Extensions
.MESA_image_dma_buf_export
);
1893 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1895 ret
= drv
->API
.ExportDMABUFImageMESA(drv
, disp
, img
, fds
, strides
, offsets
);
1897 RETURN_EGL_EVAL(disp
, ret
);
1900 __eglMustCastToProperFunctionPointerType EGLAPIENTRY
1901 eglGetProcAddress(const char *procname
)
1903 static const struct {
1906 } egl_functions
[] = {
1907 /* core functions queryable in the presence of
1908 * EGL_KHR_get_all_proc_addresses or EGL 1.5
1910 /* alphabetical order */
1911 { "eglBindAPI", (_EGLProc
) eglBindAPI
},
1912 { "eglBindTexImage", (_EGLProc
) eglBindTexImage
},
1913 { "eglChooseConfig", (_EGLProc
) eglChooseConfig
},
1914 { "eglCopyBuffers", (_EGLProc
) eglCopyBuffers
},
1915 { "eglCreateContext", (_EGLProc
) eglCreateContext
},
1916 { "eglCreatePbufferFromClientBuffer", (_EGLProc
) eglCreatePbufferFromClientBuffer
},
1917 { "eglCreatePbufferSurface", (_EGLProc
) eglCreatePbufferSurface
},
1918 { "eglCreatePixmapSurface", (_EGLProc
) eglCreatePixmapSurface
},
1919 { "eglCreateWindowSurface", (_EGLProc
) eglCreateWindowSurface
},
1920 { "eglDestroyContext", (_EGLProc
) eglDestroyContext
},
1921 { "eglDestroySurface", (_EGLProc
) eglDestroySurface
},
1922 { "eglGetConfigAttrib", (_EGLProc
) eglGetConfigAttrib
},
1923 { "eglGetConfigs", (_EGLProc
) eglGetConfigs
},
1924 { "eglGetCurrentContext", (_EGLProc
) eglGetCurrentContext
},
1925 { "eglGetCurrentDisplay", (_EGLProc
) eglGetCurrentDisplay
},
1926 { "eglGetCurrentSurface", (_EGLProc
) eglGetCurrentSurface
},
1927 { "eglGetDisplay", (_EGLProc
) eglGetDisplay
},
1928 { "eglGetError", (_EGLProc
) eglGetError
},
1929 { "eglGetProcAddress", (_EGLProc
) eglGetProcAddress
},
1930 { "eglInitialize", (_EGLProc
) eglInitialize
},
1931 { "eglMakeCurrent", (_EGLProc
) eglMakeCurrent
},
1932 { "eglQueryAPI", (_EGLProc
) eglQueryAPI
},
1933 { "eglQueryContext", (_EGLProc
) eglQueryContext
},
1934 { "eglQueryString", (_EGLProc
) eglQueryString
},
1935 { "eglQuerySurface", (_EGLProc
) eglQuerySurface
},
1936 { "eglReleaseTexImage", (_EGLProc
) eglReleaseTexImage
},
1937 { "eglReleaseThread", (_EGLProc
) eglReleaseThread
},
1938 { "eglSurfaceAttrib", (_EGLProc
) eglSurfaceAttrib
},
1939 { "eglSwapBuffers", (_EGLProc
) eglSwapBuffers
},
1940 { "eglSwapInterval", (_EGLProc
) eglSwapInterval
},
1941 { "eglTerminate", (_EGLProc
) eglTerminate
},
1942 { "eglWaitClient", (_EGLProc
) eglWaitClient
},
1943 { "eglWaitGL", (_EGLProc
) eglWaitGL
},
1944 { "eglWaitNative", (_EGLProc
) eglWaitNative
},
1945 { "eglCreateSync", (_EGLProc
) eglCreateSync
},
1946 { "eglDestroySync", (_EGLProc
) eglDestroySync
},
1947 { "eglClientWaitSync", (_EGLProc
) eglClientWaitSync
},
1948 { "eglGetSyncAttrib", (_EGLProc
) eglGetSyncAttrib
},
1949 { "eglWaitSync", (_EGLProc
) eglWaitSync
},
1950 { "eglCreateImage", (_EGLProc
) eglCreateImage
},
1951 { "eglDestroyImage", (_EGLProc
) eglDestroyImage
},
1952 { "eglGetPlatformDisplay", (_EGLProc
) eglGetPlatformDisplay
},
1953 { "eglCreatePlatformWindowSurface", (_EGLProc
) eglCreatePlatformWindowSurface
},
1954 { "eglCreatePlatformPixmapSurface", (_EGLProc
) eglCreatePlatformPixmapSurface
},
1955 { "eglCreateImageKHR", (_EGLProc
) eglCreateImageKHR
},
1956 { "eglDestroyImageKHR", (_EGLProc
) eglDestroyImage
},
1957 { "eglCreateSyncKHR", (_EGLProc
) eglCreateSyncKHR
},
1958 { "eglCreateSync64KHR", (_EGLProc
) eglCreateSync64KHR
},
1959 { "eglDestroySyncKHR", (_EGLProc
) eglDestroySync
},
1960 { "eglClientWaitSyncKHR", (_EGLProc
) eglClientWaitSync
},
1961 { "eglWaitSyncKHR", (_EGLProc
) eglWaitSyncKHR
},
1962 { "eglSignalSyncKHR", (_EGLProc
) eglSignalSyncKHR
},
1963 { "eglGetSyncAttribKHR", (_EGLProc
) eglGetSyncAttribKHR
},
1964 { "eglSwapBuffersRegionNOK", (_EGLProc
) eglSwapBuffersRegionNOK
},
1965 { "eglCreateDRMImageMESA", (_EGLProc
) eglCreateDRMImageMESA
},
1966 { "eglExportDRMImageMESA", (_EGLProc
) eglExportDRMImageMESA
},
1967 { "eglBindWaylandDisplayWL", (_EGLProc
) eglBindWaylandDisplayWL
},
1968 { "eglUnbindWaylandDisplayWL", (_EGLProc
) eglUnbindWaylandDisplayWL
},
1969 { "eglQueryWaylandBufferWL", (_EGLProc
) eglQueryWaylandBufferWL
},
1970 { "eglCreateWaylandBufferFromImageWL", (_EGLProc
) eglCreateWaylandBufferFromImageWL
},
1971 { "eglPostSubBufferNV", (_EGLProc
) eglPostSubBufferNV
},
1972 { "eglSwapBuffersWithDamageEXT", (_EGLProc
) eglSwapBuffersWithDamageEXT
},
1973 { "eglGetPlatformDisplayEXT", (_EGLProc
) eglGetPlatformDisplayEXT
},
1974 { "eglCreatePlatformWindowSurfaceEXT", (_EGLProc
) eglCreatePlatformWindowSurfaceEXT
},
1975 { "eglCreatePlatformPixmapSurfaceEXT", (_EGLProc
) eglCreatePlatformPixmapSurfaceEXT
},
1976 { "eglGetSyncValuesCHROMIUM", (_EGLProc
) eglGetSyncValuesCHROMIUM
},
1977 { "eglExportDMABUFImageQueryMESA", (_EGLProc
) eglExportDMABUFImageQueryMESA
},
1978 { "eglExportDMABUFImageMESA", (_EGLProc
) eglExportDMABUFImageMESA
},
1985 RETURN_EGL_SUCCESS(NULL
, NULL
);
1988 if (strncmp(procname
, "egl", 3) == 0) {
1989 for (i
= 0; egl_functions
[i
].name
; i
++) {
1990 if (strcmp(egl_functions
[i
].name
, procname
) == 0) {
1991 ret
= egl_functions
[i
].function
;
1997 ret
= _eglGetDriverProc(procname
);
1999 RETURN_EGL_SUCCESS(NULL
, ret
);
2003 _eglLockDisplayInterop(EGLDisplay dpy
, EGLContext context
,
2004 _EGLDisplay
**disp
, _EGLDriver
**drv
,
2008 *disp
= _eglLockDisplay(dpy
);
2009 if (!*disp
|| !(*disp
)->Initialized
|| !(*disp
)->Driver
) {
2011 _eglUnlockDisplay(*disp
);
2012 return MESA_GLINTEROP_INVALID_DISPLAY
;
2015 *drv
= (*disp
)->Driver
;
2017 *ctx
= _eglLookupContext(context
, *disp
);
2019 ((*ctx
)->ClientAPI
!= EGL_OPENGL_API
&&
2020 (*ctx
)->ClientAPI
!= EGL_OPENGL_ES_API
)) {
2021 _eglUnlockDisplay(*disp
);
2022 return MESA_GLINTEROP_INVALID_CONTEXT
;
2025 return MESA_GLINTEROP_SUCCESS
;
2029 MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy
, EGLContext context
,
2030 struct mesa_glinterop_device_info
*out
)
2037 ret
= _eglLockDisplayInterop(dpy
, context
, &disp
, &drv
, &ctx
);
2038 if (ret
!= MESA_GLINTEROP_SUCCESS
)
2041 if (drv
->API
.GLInteropQueryDeviceInfo
)
2042 ret
= drv
->API
.GLInteropQueryDeviceInfo(disp
, ctx
, out
);
2044 ret
= MESA_GLINTEROP_UNSUPPORTED
;
2046 _eglUnlockDisplay(disp
);
2051 MesaGLInteropEGLExportObject(EGLDisplay dpy
, EGLContext context
,
2052 struct mesa_glinterop_export_in
*in
,
2053 struct mesa_glinterop_export_out
*out
)
2060 ret
= _eglLockDisplayInterop(dpy
, context
, &disp
, &drv
, &ctx
);
2061 if (ret
!= MESA_GLINTEROP_SUCCESS
)
2064 if (drv
->API
.GLInteropExportObject
)
2065 ret
= drv
->API
.GLInteropExportObject(disp
, ctx
, in
, out
);
2067 ret
= MESA_GLINTEROP_UNSUPPORTED
;
2069 _eglUnlockDisplay(disp
);