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 _eglConvertAttribsToInt(const EGLAttrib
*attr_list
)
257 EGLint
*int_attribs
= NULL
;
259 /* Convert attributes from EGLAttrib[] to EGLint[] */
263 while (attr_list
[size
] != EGL_NONE
)
266 size
+= 1; /* add space for EGL_NONE */
268 int_attribs
= calloc(size
, sizeof(int_attribs
[0]));
272 for (i
= 0; i
< size
; i
++)
273 int_attribs
[i
] = attr_list
[i
];
280 * This is typically the first EGL function that an application calls.
281 * It associates a private _EGLDisplay object to the native display.
283 EGLDisplay EGLAPIENTRY
284 eglGetDisplay(EGLNativeDisplayType nativeDisplay
)
286 _EGLPlatformType plat
;
288 void *native_display_ptr
;
290 STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay
));
291 native_display_ptr
= (void*) nativeDisplay
;
293 plat
= _eglGetNativePlatform(native_display_ptr
);
294 dpy
= _eglFindDisplay(plat
, native_display_ptr
);
295 return _eglGetDisplayHandle(dpy
);
298 static EGLDisplay EGLAPIENTRY
299 eglGetPlatformDisplayEXT(EGLenum platform
, void *native_display
,
300 const EGLint
*attrib_list
)
305 #ifdef HAVE_X11_PLATFORM
306 case EGL_PLATFORM_X11_EXT
:
307 dpy
= _eglGetX11Display((Display
*) native_display
, attrib_list
);
310 #ifdef HAVE_DRM_PLATFORM
311 case EGL_PLATFORM_GBM_MESA
:
312 dpy
= _eglGetGbmDisplay((struct gbm_device
*) native_display
,
316 #ifdef HAVE_WAYLAND_PLATFORM
317 case EGL_PLATFORM_WAYLAND_EXT
:
318 dpy
= _eglGetWaylandDisplay((struct wl_display
*) native_display
,
323 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, NULL
);
326 return _eglGetDisplayHandle(dpy
);
329 EGLDisplay EGLAPIENTRY
330 eglGetPlatformDisplay(EGLenum platform
, void *native_display
,
331 const EGLAttrib
*attrib_list
)
334 EGLint
*int_attribs
= _eglConvertAttribsToInt(attrib_list
);
336 if (attrib_list
&& !int_attribs
)
337 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, NULL
);
339 display
= eglGetPlatformDisplayEXT(platform
, native_display
, int_attribs
);
345 * Copy the extension into the string and update the string pointer.
348 _eglAppendExtension(char **str
, const char *ext
)
351 size_t len
= strlen(ext
);
368 * Examine the individual extension enable/disable flags and recompute
369 * the driver's Extensions string.
372 _eglCreateExtensionsString(_EGLDisplay
*dpy
)
374 #define _EGL_CHECK_EXTENSION(ext) \
376 if (dpy->Extensions.ext) { \
377 _eglAppendExtension(&exts, "EGL_" #ext); \
378 assert(exts <= dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN); \
382 char *exts
= dpy
->ExtensionsString
;
384 /* Please keep these sorted alphabetically. */
385 _EGL_CHECK_EXTENSION(ANDROID_framebuffer_target
);
386 _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer
);
387 _EGL_CHECK_EXTENSION(ANDROID_recordable
);
389 _EGL_CHECK_EXTENSION(CHROMIUM_sync_control
);
391 _EGL_CHECK_EXTENSION(EXT_buffer_age
);
392 _EGL_CHECK_EXTENSION(EXT_create_context_robustness
);
393 _EGL_CHECK_EXTENSION(EXT_image_dma_buf_import
);
394 _EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage
);
396 _EGL_CHECK_EXTENSION(KHR_cl_event2
);
397 _EGL_CHECK_EXTENSION(KHR_create_context
);
398 _EGL_CHECK_EXTENSION(KHR_fence_sync
);
399 _EGL_CHECK_EXTENSION(KHR_get_all_proc_addresses
);
400 _EGL_CHECK_EXTENSION(KHR_gl_colorspace
);
401 _EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image
);
402 _EGL_CHECK_EXTENSION(KHR_gl_texture_2D_image
);
403 _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image
);
404 _EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image
);
405 if (dpy
->Extensions
.KHR_image_base
&& dpy
->Extensions
.KHR_image_pixmap
)
406 _eglAppendExtension(&exts
, "EGL_KHR_image");
407 _EGL_CHECK_EXTENSION(KHR_image_base
);
408 _EGL_CHECK_EXTENSION(KHR_image_pixmap
);
409 _EGL_CHECK_EXTENSION(KHR_no_config_context
);
410 _EGL_CHECK_EXTENSION(KHR_reusable_sync
);
411 _EGL_CHECK_EXTENSION(KHR_surfaceless_context
);
412 _EGL_CHECK_EXTENSION(KHR_wait_sync
);
414 if (dpy
->Extensions
.KHR_no_config_context
)
415 _eglAppendExtension(&exts
, "EGL_MESA_configless_context");
416 _EGL_CHECK_EXTENSION(MESA_drm_image
);
417 _EGL_CHECK_EXTENSION(MESA_image_dma_buf_export
);
419 _EGL_CHECK_EXTENSION(NOK_swap_region
);
420 _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap
);
422 _EGL_CHECK_EXTENSION(NV_post_sub_buffer
);
424 _EGL_CHECK_EXTENSION(WL_bind_wayland_display
);
425 _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image
);
427 #undef _EGL_CHECK_EXTENSION
431 _eglCreateAPIsString(_EGLDisplay
*dpy
)
433 if (dpy
->ClientAPIs
& EGL_OPENGL_BIT
)
434 strcat(dpy
->ClientAPIsString
, "OpenGL ");
436 if (dpy
->ClientAPIs
& EGL_OPENGL_ES_BIT
||
437 dpy
->ClientAPIs
& EGL_OPENGL_ES2_BIT
||
438 dpy
->ClientAPIs
& EGL_OPENGL_ES3_BIT_KHR
) {
439 strcat(dpy
->ClientAPIsString
, "OpenGL_ES ");
442 if (dpy
->ClientAPIs
& EGL_OPENVG_BIT
)
443 strcat(dpy
->ClientAPIsString
, "OpenVG ");
445 assert(strlen(dpy
->ClientAPIsString
) < sizeof(dpy
->ClientAPIsString
));
449 _eglComputeVersion(_EGLDisplay
*disp
)
453 if (disp
->Extensions
.KHR_fence_sync
&&
454 disp
->Extensions
.KHR_cl_event2
&&
455 disp
->Extensions
.KHR_wait_sync
&&
456 disp
->Extensions
.KHR_image_base
&&
457 disp
->Extensions
.KHR_gl_texture_2D_image
&&
458 disp
->Extensions
.KHR_gl_texture_3D_image
&&
459 disp
->Extensions
.KHR_gl_texture_cubemap_image
&&
460 disp
->Extensions
.KHR_gl_renderbuffer_image
&&
461 disp
->Extensions
.KHR_create_context
&&
462 disp
->Extensions
.EXT_create_context_robustness
&&
463 disp
->Extensions
.KHR_get_all_proc_addresses
&&
464 disp
->Extensions
.KHR_gl_colorspace
&&
465 disp
->Extensions
.KHR_surfaceless_context
)
470 * This is typically the second EGL function that an application calls.
471 * Here we load/initialize the actual hardware driver.
473 EGLBoolean EGLAPIENTRY
474 eglInitialize(EGLDisplay dpy
, EGLint
*major
, EGLint
*minor
)
476 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
479 RETURN_EGL_ERROR(NULL
, EGL_BAD_DISPLAY
, EGL_FALSE
);
481 if (!disp
->Initialized
) {
482 if (!_eglMatchDriver(disp
, EGL_FALSE
))
483 RETURN_EGL_ERROR(disp
, EGL_NOT_INITIALIZED
, EGL_FALSE
);
485 /* limit to APIs supported by core */
486 disp
->ClientAPIs
&= _EGL_API_ALL_BITS
;
488 /* EGL_KHR_get_all_proc_addresses is a corner-case extension. The spec
489 * classifies it as an EGL display extension, though conceptually it's an
490 * EGL client extension.
492 * From the EGL_KHR_get_all_proc_addresses spec:
494 * The EGL implementation must expose the name
495 * EGL_KHR_client_get_all_proc_addresses if and only if it exposes
496 * EGL_KHR_get_all_proc_addresses and supports
497 * EGL_EXT_client_extensions.
499 * Mesa unconditionally exposes both client extensions mentioned above,
500 * so the spec requires that each EGLDisplay unconditionally expose
501 * EGL_KHR_get_all_proc_addresses also.
503 disp
->Extensions
.KHR_get_all_proc_addresses
= EGL_TRUE
;
505 _eglComputeVersion(disp
);
506 _eglCreateExtensionsString(disp
);
507 _eglCreateAPIsString(disp
);
508 snprintf(disp
->VersionString
, sizeof(disp
->VersionString
),
509 "%d.%d (%s)", disp
->Version
/ 10, disp
->Version
% 10,
513 /* Update applications version of major and minor if not NULL */
514 if ((major
!= NULL
) && (minor
!= NULL
)) {
515 *major
= disp
->Version
/ 10;
516 *minor
= disp
->Version
% 10;
519 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
523 EGLBoolean EGLAPIENTRY
524 eglTerminate(EGLDisplay dpy
)
526 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
529 RETURN_EGL_ERROR(NULL
, EGL_BAD_DISPLAY
, EGL_FALSE
);
531 if (disp
->Initialized
) {
532 _EGLDriver
*drv
= disp
->Driver
;
534 drv
->API
.Terminate(drv
, disp
);
535 /* do not reset disp->Driver */
536 disp
->ClientAPIsString
[0] = 0;
537 disp
->Initialized
= EGL_FALSE
;
540 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
544 const char * EGLAPIENTRY
545 eglQueryString(EGLDisplay dpy
, EGLint name
)
550 if (dpy
== EGL_NO_DISPLAY
&& name
== EGL_EXTENSIONS
) {
551 RETURN_EGL_SUCCESS(NULL
, _eglGlobal
.ClientExtensionString
);
554 disp
= _eglLockDisplay(dpy
);
555 _EGL_CHECK_DISPLAY(disp
, NULL
, drv
);
559 RETURN_EGL_SUCCESS(disp
, _EGL_VENDOR_STRING
);
561 RETURN_EGL_SUCCESS(disp
, disp
->VersionString
);
563 RETURN_EGL_SUCCESS(disp
, disp
->ExtensionsString
);
564 case EGL_CLIENT_APIS
:
565 RETURN_EGL_SUCCESS(disp
, disp
->ClientAPIsString
);
567 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, NULL
);
572 EGLBoolean EGLAPIENTRY
573 eglGetConfigs(EGLDisplay dpy
, EGLConfig
*configs
,
574 EGLint config_size
, EGLint
*num_config
)
576 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
580 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
581 ret
= drv
->API
.GetConfigs(drv
, disp
, configs
, config_size
, num_config
);
583 RETURN_EGL_EVAL(disp
, ret
);
587 EGLBoolean EGLAPIENTRY
588 eglChooseConfig(EGLDisplay dpy
, const EGLint
*attrib_list
, EGLConfig
*configs
,
589 EGLint config_size
, EGLint
*num_config
)
591 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
595 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
596 ret
= drv
->API
.ChooseConfig(drv
, disp
, attrib_list
, configs
,
597 config_size
, num_config
);
599 RETURN_EGL_EVAL(disp
, ret
);
603 EGLBoolean EGLAPIENTRY
604 eglGetConfigAttrib(EGLDisplay dpy
, EGLConfig config
,
605 EGLint attribute
, EGLint
*value
)
607 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
608 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
612 _EGL_CHECK_CONFIG(disp
, conf
, EGL_FALSE
, drv
);
613 ret
= drv
->API
.GetConfigAttrib(drv
, disp
, conf
, attribute
, value
);
615 RETURN_EGL_EVAL(disp
, ret
);
619 EGLContext EGLAPIENTRY
620 eglCreateContext(EGLDisplay dpy
, EGLConfig config
, EGLContext share_list
,
621 const EGLint
*attrib_list
)
623 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
624 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
625 _EGLContext
*share
= _eglLookupContext(share_list
, disp
);
627 _EGLContext
*context
;
630 _EGL_CHECK_DISPLAY(disp
, EGL_NO_CONTEXT
, drv
);
632 if (!config
&& !disp
->Extensions
.KHR_no_config_context
)
633 RETURN_EGL_ERROR(disp
, EGL_BAD_CONFIG
, EGL_NO_CONTEXT
);
635 if (!share
&& share_list
!= EGL_NO_CONTEXT
)
636 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_CONTEXT
);
638 context
= drv
->API
.CreateContext(drv
, disp
, conf
, share
, attrib_list
);
639 ret
= (context
) ? _eglLinkContext(context
) : EGL_NO_CONTEXT
;
641 RETURN_EGL_EVAL(disp
, ret
);
645 EGLBoolean EGLAPIENTRY
646 eglDestroyContext(EGLDisplay dpy
, EGLContext ctx
)
648 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
649 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
653 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
654 _eglUnlinkContext(context
);
655 ret
= drv
->API
.DestroyContext(drv
, disp
, context
);
657 RETURN_EGL_EVAL(disp
, ret
);
661 EGLBoolean EGLAPIENTRY
662 eglMakeCurrent(EGLDisplay dpy
, EGLSurface draw
, EGLSurface read
,
665 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
666 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
667 _EGLSurface
*draw_surf
= _eglLookupSurface(draw
, disp
);
668 _EGLSurface
*read_surf
= _eglLookupSurface(read
, disp
);
673 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
676 /* display is allowed to be uninitialized under certain condition */
677 if (!disp
->Initialized
) {
678 if (draw
!= EGL_NO_SURFACE
|| read
!= EGL_NO_SURFACE
||
679 ctx
!= EGL_NO_CONTEXT
)
680 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
683 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
685 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
686 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
687 if (!draw_surf
|| !read_surf
) {
688 /* From the EGL 1.4 (20130211) spec:
690 * To release the current context without assigning a new one, set ctx
691 * to EGL_NO_CONTEXT and set draw and read to EGL_NO_SURFACE.
693 if (!disp
->Extensions
.KHR_surfaceless_context
&& ctx
!= EGL_NO_CONTEXT
)
694 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
696 if ((!draw_surf
&& draw
!= EGL_NO_SURFACE
) ||
697 (!read_surf
&& read
!= EGL_NO_SURFACE
))
698 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
699 if (draw_surf
|| read_surf
)
700 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_FALSE
);
703 ret
= drv
->API
.MakeCurrent(drv
, disp
, draw_surf
, read_surf
, context
);
705 RETURN_EGL_EVAL(disp
, ret
);
709 EGLBoolean EGLAPIENTRY
710 eglQueryContext(EGLDisplay dpy
, EGLContext ctx
,
711 EGLint attribute
, EGLint
*value
)
713 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
714 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
718 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
719 ret
= drv
->API
.QueryContext(drv
, disp
, context
, attribute
, value
);
721 RETURN_EGL_EVAL(disp
, ret
);
726 _eglCreateWindowSurfaceCommon(_EGLDisplay
*disp
, EGLConfig config
,
727 void *native_window
, const EGLint
*attrib_list
)
729 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
734 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
736 if (native_window
== NULL
)
737 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_WINDOW
, EGL_NO_SURFACE
);
739 surf
= drv
->API
.CreateWindowSurface(drv
, disp
, conf
, native_window
,
741 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
743 RETURN_EGL_EVAL(disp
, ret
);
747 EGLSurface EGLAPIENTRY
748 eglCreateWindowSurface(EGLDisplay dpy
, EGLConfig config
,
749 EGLNativeWindowType window
, const EGLint
*attrib_list
)
751 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
752 STATIC_ASSERT(sizeof(void*) == sizeof(window
));
753 return _eglCreateWindowSurfaceCommon(disp
, config
, (void*) window
,
758 static EGLSurface EGLAPIENTRY
759 eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy
, EGLConfig config
,
761 const EGLint
*attrib_list
)
763 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
765 #ifdef HAVE_X11_PLATFORM
766 if (disp
->Platform
== _EGL_PLATFORM_X11
&& native_window
!= NULL
) {
767 /* The `native_window` parameter for the X11 platform differs between
768 * eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
769 * eglCreateWindowSurface(), the type of `native_window` is an Xlib
770 * `Window`. In eglCreatePlatformWindowSurfaceEXT(), the type is
771 * `Window*`. Convert `Window*` to `Window` because that's what
772 * dri2_x11_create_window_surface() expects.
774 native_window
= (void*) (* (Window
*) native_window
);
778 return _eglCreateWindowSurfaceCommon(disp
, config
, native_window
,
783 EGLSurface EGLAPIENTRY
784 eglCreatePlatformWindowSurface(EGLDisplay dpy
, EGLConfig config
,
786 const EGLAttrib
*attrib_list
)
789 EGLint
*int_attribs
= _eglConvertAttribsToInt(attrib_list
);
791 if (attrib_list
&& !int_attribs
)
792 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_NO_SURFACE
);
794 surface
= eglCreatePlatformWindowSurfaceEXT(dpy
, config
, native_window
,
802 _eglCreatePixmapSurfaceCommon(_EGLDisplay
*disp
, EGLConfig config
,
803 void *native_pixmap
, const EGLint
*attrib_list
)
805 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
810 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
811 surf
= drv
->API
.CreatePixmapSurface(drv
, disp
, conf
, native_pixmap
,
813 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
815 RETURN_EGL_EVAL(disp
, ret
);
819 EGLSurface EGLAPIENTRY
820 eglCreatePixmapSurface(EGLDisplay dpy
, EGLConfig config
,
821 EGLNativePixmapType pixmap
, const EGLint
*attrib_list
)
823 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
824 STATIC_ASSERT(sizeof(void*) == sizeof(pixmap
));
825 return _eglCreatePixmapSurfaceCommon(disp
, config
, (void*) pixmap
,
829 static EGLSurface EGLAPIENTRY
830 eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy
, EGLConfig config
,
832 const EGLint
*attrib_list
)
834 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
836 #ifdef HAVE_X11_PLATFORM
837 /* The `native_pixmap` parameter for the X11 platform differs between
838 * eglCreatePixmapSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
839 * eglCreatePixmapSurface(), the type of `native_pixmap` is an Xlib
840 * `Pixmap`. In eglCreatePlatformPixmapSurfaceEXT(), the type is
841 * `Pixmap*`. Convert `Pixmap*` to `Pixmap` because that's what
842 * dri2_x11_create_pixmap_surface() expects.
844 if (disp
->Platform
== _EGL_PLATFORM_X11
&& native_pixmap
!= NULL
) {
845 native_pixmap
= (void*) (* (Pixmap
*) native_pixmap
);
849 return _eglCreatePixmapSurfaceCommon(disp
, config
, native_pixmap
,
854 EGLSurface EGLAPIENTRY
855 eglCreatePlatformPixmapSurface(EGLDisplay dpy
, EGLConfig config
,
857 const EGLAttrib
*attrib_list
)
860 EGLint
*int_attribs
= _eglConvertAttribsToInt(attrib_list
);
862 if (attrib_list
&& !int_attribs
)
863 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_NO_SURFACE
);
865 surface
= eglCreatePlatformPixmapSurfaceEXT(dpy
, config
, native_pixmap
,
872 EGLSurface EGLAPIENTRY
873 eglCreatePbufferSurface(EGLDisplay dpy
, EGLConfig config
,
874 const EGLint
*attrib_list
)
876 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
877 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
882 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
884 surf
= drv
->API
.CreatePbufferSurface(drv
, disp
, conf
, attrib_list
);
885 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
887 RETURN_EGL_EVAL(disp
, ret
);
891 EGLBoolean EGLAPIENTRY
892 eglDestroySurface(EGLDisplay dpy
, EGLSurface surface
)
894 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
895 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
899 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
900 _eglUnlinkSurface(surf
);
901 ret
= drv
->API
.DestroySurface(drv
, disp
, surf
);
903 RETURN_EGL_EVAL(disp
, ret
);
906 EGLBoolean EGLAPIENTRY
907 eglQuerySurface(EGLDisplay dpy
, EGLSurface surface
,
908 EGLint attribute
, EGLint
*value
)
910 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
911 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
915 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
916 ret
= drv
->API
.QuerySurface(drv
, disp
, surf
, attribute
, value
);
918 RETURN_EGL_EVAL(disp
, ret
);
921 EGLBoolean EGLAPIENTRY
922 eglSurfaceAttrib(EGLDisplay dpy
, EGLSurface surface
,
923 EGLint attribute
, EGLint value
)
925 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
926 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
930 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
931 ret
= drv
->API
.SurfaceAttrib(drv
, disp
, surf
, attribute
, value
);
933 RETURN_EGL_EVAL(disp
, ret
);
937 EGLBoolean EGLAPIENTRY
938 eglBindTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
940 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
941 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
945 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
946 ret
= drv
->API
.BindTexImage(drv
, disp
, surf
, buffer
);
948 RETURN_EGL_EVAL(disp
, ret
);
952 EGLBoolean EGLAPIENTRY
953 eglReleaseTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
955 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
956 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
960 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
961 ret
= drv
->API
.ReleaseTexImage(drv
, disp
, surf
, buffer
);
963 RETURN_EGL_EVAL(disp
, ret
);
967 EGLBoolean EGLAPIENTRY
968 eglSwapInterval(EGLDisplay dpy
, EGLint interval
)
970 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
971 _EGLContext
*ctx
= _eglGetCurrentContext();
976 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
978 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
979 ctx
->Resource
.Display
!= disp
)
980 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
982 surf
= ctx
->DrawSurface
;
983 if (_eglGetSurfaceHandle(surf
) == EGL_NO_SURFACE
)
984 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
986 ret
= drv
->API
.SwapInterval(drv
, disp
, surf
, interval
);
988 RETURN_EGL_EVAL(disp
, ret
);
992 EGLBoolean EGLAPIENTRY
993 eglSwapBuffers(EGLDisplay dpy
, EGLSurface surface
)
995 _EGLContext
*ctx
= _eglGetCurrentContext();
996 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
997 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1001 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1003 /* surface must be bound to current context in EGL 1.4 */
1004 #ifndef _EGL_BUILT_IN_DRIVER_HAIKU
1005 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1006 surf
!= ctx
->DrawSurface
)
1007 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1010 ret
= drv
->API
.SwapBuffers(drv
, disp
, surf
);
1012 RETURN_EGL_EVAL(disp
, ret
);
1016 static EGLBoolean EGLAPIENTRY
1017 eglSwapBuffersWithDamageEXT(EGLDisplay dpy
, EGLSurface surface
,
1018 EGLint
*rects
, EGLint n_rects
)
1020 _EGLContext
*ctx
= _eglGetCurrentContext();
1021 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1022 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1026 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1028 /* surface must be bound to current context in EGL 1.4 */
1029 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1030 surf
!= ctx
->DrawSurface
)
1031 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1033 if ((n_rects
> 0 && rects
== NULL
) || n_rects
< 0)
1034 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1036 ret
= drv
->API
.SwapBuffersWithDamageEXT(drv
, disp
, surf
, rects
, n_rects
);
1038 RETURN_EGL_EVAL(disp
, ret
);
1041 EGLBoolean EGLAPIENTRY
1042 eglCopyBuffers(EGLDisplay dpy
, EGLSurface surface
, EGLNativePixmapType target
)
1044 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1045 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1048 void *native_pixmap_ptr
;
1050 STATIC_ASSERT(sizeof(void*) == sizeof(target
));
1051 native_pixmap_ptr
= (void*) target
;
1053 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1054 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
1055 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_PIXMAP
, EGL_FALSE
);
1056 ret
= drv
->API
.CopyBuffers(drv
, disp
, surf
, native_pixmap_ptr
);
1058 RETURN_EGL_EVAL(disp
, ret
);
1062 EGLBoolean EGLAPIENTRY
1065 _EGLContext
*ctx
= _eglGetCurrentContext();
1071 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1073 disp
= ctx
->Resource
.Display
;
1074 mtx_lock(&disp
->Mutex
);
1076 /* let bad current context imply bad current surface */
1077 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1078 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
1079 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
1081 /* a valid current context implies an initialized current display */
1082 assert(disp
->Initialized
);
1084 ret
= drv
->API
.WaitClient(drv
, disp
, ctx
);
1086 RETURN_EGL_EVAL(disp
, ret
);
1090 EGLBoolean EGLAPIENTRY
1093 /* Since we only support OpenGL and GLES, eglWaitGL is equivalent to eglWaitClient. */
1094 return eglWaitClient();
1098 EGLBoolean EGLAPIENTRY
1099 eglWaitNative(EGLint engine
)
1101 _EGLContext
*ctx
= _eglGetCurrentContext();
1107 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1109 disp
= ctx
->Resource
.Display
;
1110 mtx_lock(&disp
->Mutex
);
1112 /* let bad current context imply bad current surface */
1113 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1114 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
1115 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
1117 /* a valid current context implies an initialized current display */
1118 assert(disp
->Initialized
);
1120 ret
= drv
->API
.WaitNative(drv
, disp
, engine
);
1122 RETURN_EGL_EVAL(disp
, ret
);
1126 EGLDisplay EGLAPIENTRY
1127 eglGetCurrentDisplay(void)
1129 _EGLContext
*ctx
= _eglGetCurrentContext();
1132 ret
= (ctx
) ? _eglGetDisplayHandle(ctx
->Resource
.Display
) : EGL_NO_DISPLAY
;
1134 RETURN_EGL_SUCCESS(NULL
, ret
);
1138 EGLContext EGLAPIENTRY
1139 eglGetCurrentContext(void)
1141 _EGLContext
*ctx
= _eglGetCurrentContext();
1144 ret
= _eglGetContextHandle(ctx
);
1146 RETURN_EGL_SUCCESS(NULL
, ret
);
1150 EGLSurface EGLAPIENTRY
1151 eglGetCurrentSurface(EGLint readdraw
)
1153 _EGLContext
*ctx
= _eglGetCurrentContext();
1154 EGLint err
= EGL_SUCCESS
;
1159 RETURN_EGL_SUCCESS(NULL
, EGL_NO_SURFACE
);
1163 surf
= ctx
->DrawSurface
;
1166 surf
= ctx
->ReadSurface
;
1170 err
= EGL_BAD_PARAMETER
;
1174 ret
= _eglGetSurfaceHandle(surf
);
1176 RETURN_EGL_ERROR(NULL
, err
, ret
);
1183 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1184 EGLint e
= t
->LastError
;
1185 if (!_eglIsCurrentThreadDummy())
1186 t
->LastError
= EGL_SUCCESS
;
1196 * Specify the client API to use for subsequent calls including:
1197 * eglCreateContext()
1198 * eglGetCurrentContext()
1199 * eglGetCurrentDisplay()
1200 * eglGetCurrentSurface()
1201 * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT)
1204 * See section 3.7 "Rendering Context" in the EGL specification for details.
1206 EGLBoolean EGLAPIENTRY
1207 eglBindAPI(EGLenum api
)
1209 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1211 if (_eglIsCurrentThreadDummy())
1212 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_FALSE
);
1214 if (!_eglIsApiValid(api
))
1215 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1217 t
->CurrentAPI
= api
;
1219 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1224 * Return the last value set with eglBindAPI().
1229 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1232 /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
1233 ret
= t
->CurrentAPI
;
1235 RETURN_EGL_SUCCESS(NULL
, ret
);
1239 EGLSurface EGLAPIENTRY
1240 eglCreatePbufferFromClientBuffer(EGLDisplay dpy
, EGLenum buftype
,
1241 EGLClientBuffer buffer
, EGLConfig config
,
1242 const EGLint
*attrib_list
)
1244 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1245 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1250 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1252 surf
= drv
->API
.CreatePbufferFromClientBuffer(drv
, disp
, buftype
, buffer
,
1254 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1256 RETURN_EGL_EVAL(disp
, ret
);
1260 EGLBoolean EGLAPIENTRY
1261 eglReleaseThread(void)
1263 /* unbind current contexts */
1264 if (!_eglIsCurrentThreadDummy()) {
1265 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1267 _EGLContext
*ctx
= t
->CurrentContext
;
1269 _EGLDisplay
*disp
= ctx
->Resource
.Display
;
1272 mtx_lock(&disp
->Mutex
);
1274 (void) drv
->API
.MakeCurrent(drv
, disp
, NULL
, NULL
, NULL
);
1275 mtx_unlock(&disp
->Mutex
);
1279 _eglDestroyCurrentThread();
1281 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1285 static EGLImage EGLAPIENTRY
1286 eglCreateImageKHR(EGLDisplay dpy
, EGLContext ctx
, EGLenum target
,
1287 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1289 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1290 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
1295 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1296 if (!disp
->Extensions
.KHR_image_base
)
1297 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1298 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
1299 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_IMAGE_KHR
);
1300 /* "If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid display,
1301 * <ctx> must be EGL_NO_CONTEXT..."
1303 if (ctx
!= EGL_NO_CONTEXT
&& target
== EGL_LINUX_DMA_BUF_EXT
)
1304 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_NO_IMAGE_KHR
);
1306 img
= drv
->API
.CreateImageKHR(drv
,
1307 disp
, context
, target
, buffer
, attr_list
);
1308 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1310 RETURN_EGL_EVAL(disp
, ret
);
1314 EGLImage EGLAPIENTRY
1315 eglCreateImage(EGLDisplay dpy
, EGLContext ctx
, EGLenum target
,
1316 EGLClientBuffer buffer
, const EGLAttrib
*attr_list
)
1319 EGLint
*int_attribs
= _eglConvertAttribsToInt(attr_list
);
1321 if (attr_list
&& !int_attribs
)
1322 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_NO_IMAGE
);
1324 image
= eglCreateImageKHR(dpy
, ctx
, target
, buffer
, int_attribs
);
1330 EGLBoolean EGLAPIENTRY
1331 eglDestroyImage(EGLDisplay dpy
, EGLImage image
)
1333 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1334 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1338 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1339 if (!disp
->Extensions
.KHR_image_base
)
1340 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1342 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1344 _eglUnlinkImage(img
);
1345 ret
= drv
->API
.DestroyImageKHR(drv
, disp
, img
);
1347 RETURN_EGL_EVAL(disp
, ret
);
1352 _eglCreateSync(EGLDisplay dpy
, EGLenum type
, const EGLint
*attrib_list
,
1353 const EGLAttrib
*attrib_list64
, EGLBoolean is64
,
1354 EGLenum invalid_type_error
)
1356 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1357 _EGLContext
*ctx
= _eglGetCurrentContext();
1362 _EGL_CHECK_DISPLAY(disp
, EGL_NO_SYNC_KHR
, drv
);
1364 if (!disp
->Extensions
.KHR_cl_event2
&& is64
)
1365 RETURN_EGL_EVAL(disp
, EGL_NO_SYNC_KHR
);
1367 /* return an error if the client API doesn't support GL_OES_EGL_sync */
1368 if (!ctx
|| ctx
->Resource
.Display
!= dpy
||
1369 ctx
->ClientAPI
!= EGL_OPENGL_ES_API
)
1370 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_NO_SYNC_KHR
);
1373 case EGL_SYNC_FENCE_KHR
:
1374 if (!disp
->Extensions
.KHR_fence_sync
)
1375 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1377 case EGL_SYNC_REUSABLE_KHR
:
1378 if (!disp
->Extensions
.KHR_reusable_sync
)
1379 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1381 case EGL_SYNC_CL_EVENT_KHR
:
1382 if (!disp
->Extensions
.KHR_cl_event2
)
1383 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1386 RETURN_EGL_ERROR(disp
, invalid_type_error
, EGL_NO_SYNC_KHR
);
1389 sync
= drv
->API
.CreateSyncKHR(drv
, disp
, type
, attrib_list
, attrib_list64
);
1390 ret
= (sync
) ? _eglLinkSync(sync
) : EGL_NO_SYNC_KHR
;
1392 RETURN_EGL_EVAL(disp
, ret
);
1396 static EGLSync EGLAPIENTRY
1397 eglCreateSyncKHR(EGLDisplay dpy
, EGLenum type
, const EGLint
*attrib_list
)
1399 return _eglCreateSync(dpy
, type
, attrib_list
, NULL
, EGL_FALSE
,
1404 static EGLSync EGLAPIENTRY
1405 eglCreateSync64KHR(EGLDisplay dpy
, EGLenum type
, const EGLAttrib
*attrib_list
)
1407 return _eglCreateSync(dpy
, type
, NULL
, attrib_list
, EGL_TRUE
,
1413 eglCreateSync(EGLDisplay dpy
, EGLenum type
, const EGLAttrib
*attrib_list
)
1415 return _eglCreateSync(dpy
, type
, NULL
, attrib_list
, EGL_TRUE
,
1420 EGLBoolean EGLAPIENTRY
1421 eglDestroySync(EGLDisplay dpy
, EGLSync sync
)
1423 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1424 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1428 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1429 assert(disp
->Extensions
.KHR_reusable_sync
||
1430 disp
->Extensions
.KHR_fence_sync
);
1433 ret
= drv
->API
.DestroySyncKHR(drv
, disp
, s
);
1435 RETURN_EGL_EVAL(disp
, ret
);
1440 eglClientWaitSync(EGLDisplay dpy
, EGLSync sync
, EGLint flags
, EGLTime timeout
)
1442 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1443 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1447 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1448 assert(disp
->Extensions
.KHR_reusable_sync
||
1449 disp
->Extensions
.KHR_fence_sync
);
1451 if (s
->SyncStatus
== EGL_SIGNALED_KHR
)
1452 RETURN_EGL_EVAL(disp
, EGL_CONDITION_SATISFIED_KHR
);
1454 /* if sync type is EGL_SYNC_REUSABLE_KHR, dpy should be
1455 * unlocked here to allow other threads also to be able to
1456 * go into waiting state.
1459 if (s
->Type
== EGL_SYNC_REUSABLE_KHR
)
1460 _eglUnlockDisplay(dpy
);
1462 ret
= drv
->API
.ClientWaitSyncKHR(drv
, disp
, s
, flags
, timeout
);
1465 * 'disp' is already unlocked for reusable sync type,
1466 * so passing 'NULL' to bypass unlocking display.
1468 if (s
->Type
== EGL_SYNC_REUSABLE_KHR
)
1469 RETURN_EGL_EVAL(NULL
, ret
);
1471 RETURN_EGL_EVAL(disp
, ret
);
1475 static EGLint EGLAPIENTRY
1476 eglWaitSyncKHR(EGLDisplay dpy
, EGLSync sync
, EGLint flags
)
1478 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1479 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1480 _EGLContext
*ctx
= _eglGetCurrentContext();
1484 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1485 assert(disp
->Extensions
.KHR_wait_sync
);
1487 /* return an error if the client API doesn't support GL_OES_EGL_sync */
1488 if (ctx
== EGL_NO_CONTEXT
|| ctx
->ClientAPI
!= EGL_OPENGL_ES_API
)
1489 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_FALSE
);
1491 /* the API doesn't allow any flags yet */
1493 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1495 ret
= drv
->API
.WaitSyncKHR(drv
, disp
, s
);
1497 RETURN_EGL_EVAL(disp
, ret
);
1501 EGLBoolean EGLAPIENTRY
1502 eglWaitSync(EGLDisplay dpy
, EGLSync sync
, EGLint flags
)
1504 /* The KHR version returns EGLint, while the core version returns
1505 * EGLBoolean. In both cases, the return values can only be EGL_FALSE and
1508 return eglWaitSyncKHR(dpy
, sync
, flags
);
1512 static EGLBoolean EGLAPIENTRY
1513 eglSignalSyncKHR(EGLDisplay dpy
, EGLSync sync
, EGLenum mode
)
1515 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1516 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1520 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1521 assert(disp
->Extensions
.KHR_reusable_sync
);
1522 ret
= drv
->API
.SignalSyncKHR(drv
, disp
, s
, mode
);
1524 RETURN_EGL_EVAL(disp
, ret
);
1528 EGLBoolean EGLAPIENTRY
1529 eglGetSyncAttrib(EGLDisplay dpy
, EGLSync sync
, EGLint attribute
, EGLAttrib
*value
)
1531 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1532 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1536 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1537 assert(disp
->Extensions
.KHR_reusable_sync
||
1538 disp
->Extensions
.KHR_fence_sync
);
1539 ret
= drv
->API
.GetSyncAttrib(drv
, disp
, s
, attribute
, value
);
1541 RETURN_EGL_EVAL(disp
, ret
);
1545 static EGLBoolean EGLAPIENTRY
1546 eglGetSyncAttribKHR(EGLDisplay dpy
, EGLSync sync
, EGLint attribute
, EGLint
*value
)
1552 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1555 result
= eglGetSyncAttrib(dpy
, sync
, attribute
, &attrib
);
1557 /* The EGL_KHR_fence_sync spec says this about eglGetSyncAttribKHR:
1559 * If any error occurs, <*value> is not modified.
1561 if (result
== EGL_FALSE
)
1569 static EGLBoolean EGLAPIENTRY
1570 eglSwapBuffersRegionNOK(EGLDisplay dpy
, EGLSurface surface
,
1571 EGLint numRects
, const EGLint
*rects
)
1573 _EGLContext
*ctx
= _eglGetCurrentContext();
1574 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1575 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1579 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1581 if (!disp
->Extensions
.NOK_swap_region
)
1582 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1584 /* surface must be bound to current context in EGL 1.4 */
1585 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1586 surf
!= ctx
->DrawSurface
)
1587 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1589 ret
= drv
->API
.SwapBuffersRegionNOK(drv
, disp
, surf
, numRects
, rects
);
1591 RETURN_EGL_EVAL(disp
, ret
);
1595 static EGLImage EGLAPIENTRY
1596 eglCreateDRMImageMESA(EGLDisplay dpy
, const EGLint
*attr_list
)
1598 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1603 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1604 if (!disp
->Extensions
.MESA_drm_image
)
1605 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1607 img
= drv
->API
.CreateDRMImageMESA(drv
, disp
, attr_list
);
1608 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1610 RETURN_EGL_EVAL(disp
, ret
);
1613 static EGLBoolean EGLAPIENTRY
1614 eglExportDRMImageMESA(EGLDisplay dpy
, EGLImage image
,
1615 EGLint
*name
, EGLint
*handle
, EGLint
*stride
)
1617 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1618 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1622 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1623 assert(disp
->Extensions
.MESA_drm_image
);
1626 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1628 ret
= drv
->API
.ExportDRMImageMESA(drv
, disp
, img
, name
, handle
, stride
);
1630 RETURN_EGL_EVAL(disp
, ret
);
1636 static EGLBoolean EGLAPIENTRY
1637 eglBindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1639 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1643 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1644 assert(disp
->Extensions
.WL_bind_wayland_display
);
1647 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1649 ret
= drv
->API
.BindWaylandDisplayWL(drv
, disp
, display
);
1651 RETURN_EGL_EVAL(disp
, ret
);
1654 static EGLBoolean EGLAPIENTRY
1655 eglUnbindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1657 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1661 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1662 assert(disp
->Extensions
.WL_bind_wayland_display
);
1665 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1667 ret
= drv
->API
.UnbindWaylandDisplayWL(drv
, disp
, display
);
1669 RETURN_EGL_EVAL(disp
, ret
);
1672 static EGLBoolean EGLAPIENTRY
1673 eglQueryWaylandBufferWL(EGLDisplay dpy
, struct wl_resource
*buffer
,
1674 EGLint attribute
, EGLint
*value
)
1676 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1680 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1681 assert(disp
->Extensions
.WL_bind_wayland_display
);
1684 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1686 ret
= drv
->API
.QueryWaylandBufferWL(drv
, disp
, buffer
, attribute
, value
);
1688 RETURN_EGL_EVAL(disp
, ret
);
1692 static struct wl_buffer
* EGLAPIENTRY
1693 eglCreateWaylandBufferFromImageWL(EGLDisplay dpy
, EGLImage image
)
1695 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1698 struct wl_buffer
*ret
;
1700 _EGL_CHECK_DISPLAY(disp
, NULL
, drv
);
1701 assert(disp
->Extensions
.WL_create_wayland_buffer_from_image
);
1703 img
= _eglLookupImage(image
, disp
);
1706 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, NULL
);
1708 ret
= drv
->API
.CreateWaylandBufferFromImageWL(drv
, disp
, img
);
1710 RETURN_EGL_EVAL(disp
, ret
);
1713 static EGLBoolean EGLAPIENTRY
1714 eglPostSubBufferNV(EGLDisplay dpy
, EGLSurface surface
,
1715 EGLint x
, EGLint y
, EGLint width
, EGLint height
)
1717 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1718 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1722 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1724 if (!disp
->Extensions
.NV_post_sub_buffer
)
1725 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1727 ret
= drv
->API
.PostSubBufferNV(drv
, disp
, surf
, x
, y
, width
, height
);
1729 RETURN_EGL_EVAL(disp
, ret
);
1732 static EGLBoolean EGLAPIENTRY
1733 eglGetSyncValuesCHROMIUM(EGLDisplay display
, EGLSurface surface
,
1734 EGLuint64KHR
*ust
, EGLuint64KHR
*msc
,
1737 _EGLDisplay
*disp
= _eglLockDisplay(display
);
1738 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1742 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1743 if (!disp
->Extensions
.CHROMIUM_sync_control
)
1744 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1746 if (!ust
|| !msc
|| !sbc
)
1747 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1749 ret
= drv
->API
.GetSyncValuesCHROMIUM(disp
, surf
, ust
, msc
, sbc
);
1751 RETURN_EGL_EVAL(disp
, ret
);
1754 static EGLBoolean EGLAPIENTRY
1755 eglExportDMABUFImageQueryMESA(EGLDisplay dpy
, EGLImage image
,
1756 EGLint
*fourcc
, EGLint
*nplanes
,
1757 EGLuint64KHR
*modifiers
)
1759 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1760 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1764 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1765 assert(disp
->Extensions
.MESA_image_dma_buf_export
);
1768 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1770 ret
= drv
->API
.ExportDMABUFImageQueryMESA(drv
, disp
, img
, fourcc
, nplanes
,
1773 RETURN_EGL_EVAL(disp
, ret
);
1776 static EGLBoolean EGLAPIENTRY
1777 eglExportDMABUFImageMESA(EGLDisplay dpy
, EGLImage image
,
1778 int *fds
, EGLint
*strides
, EGLint
*offsets
)
1780 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1781 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1785 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1786 assert(disp
->Extensions
.MESA_image_dma_buf_export
);
1789 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1791 ret
= drv
->API
.ExportDMABUFImageMESA(drv
, disp
, img
, fds
, strides
, offsets
);
1793 RETURN_EGL_EVAL(disp
, ret
);
1796 __eglMustCastToProperFunctionPointerType EGLAPIENTRY
1797 eglGetProcAddress(const char *procname
)
1799 static const struct {
1802 } egl_functions
[] = {
1803 /* core functions queryable in the presence of
1804 * EGL_KHR_get_all_proc_addresses or EGL 1.5
1806 /* alphabetical order */
1807 { "eglBindAPI", (_EGLProc
) eglBindAPI
},
1808 { "eglBindTexImage", (_EGLProc
) eglBindTexImage
},
1809 { "eglChooseConfig", (_EGLProc
) eglChooseConfig
},
1810 { "eglCopyBuffers", (_EGLProc
) eglCopyBuffers
},
1811 { "eglCreateContext", (_EGLProc
) eglCreateContext
},
1812 { "eglCreatePbufferFromClientBuffer", (_EGLProc
) eglCreatePbufferFromClientBuffer
},
1813 { "eglCreatePbufferSurface", (_EGLProc
) eglCreatePbufferSurface
},
1814 { "eglCreatePixmapSurface", (_EGLProc
) eglCreatePixmapSurface
},
1815 { "eglCreateWindowSurface", (_EGLProc
) eglCreateWindowSurface
},
1816 { "eglDestroyContext", (_EGLProc
) eglDestroyContext
},
1817 { "eglDestroySurface", (_EGLProc
) eglDestroySurface
},
1818 { "eglGetConfigAttrib", (_EGLProc
) eglGetConfigAttrib
},
1819 { "eglGetConfigs", (_EGLProc
) eglGetConfigs
},
1820 { "eglGetCurrentContext", (_EGLProc
) eglGetCurrentContext
},
1821 { "eglGetCurrentDisplay", (_EGLProc
) eglGetCurrentDisplay
},
1822 { "eglGetCurrentSurface", (_EGLProc
) eglGetCurrentSurface
},
1823 { "eglGetDisplay", (_EGLProc
) eglGetDisplay
},
1824 { "eglGetError", (_EGLProc
) eglGetError
},
1825 { "eglGetProcAddress", (_EGLProc
) eglGetProcAddress
},
1826 { "eglInitialize", (_EGLProc
) eglInitialize
},
1827 { "eglMakeCurrent", (_EGLProc
) eglMakeCurrent
},
1828 { "eglQueryAPI", (_EGLProc
) eglQueryAPI
},
1829 { "eglQueryContext", (_EGLProc
) eglQueryContext
},
1830 { "eglQueryString", (_EGLProc
) eglQueryString
},
1831 { "eglQuerySurface", (_EGLProc
) eglQuerySurface
},
1832 { "eglReleaseTexImage", (_EGLProc
) eglReleaseTexImage
},
1833 { "eglReleaseThread", (_EGLProc
) eglReleaseThread
},
1834 { "eglSurfaceAttrib", (_EGLProc
) eglSurfaceAttrib
},
1835 { "eglSwapBuffers", (_EGLProc
) eglSwapBuffers
},
1836 { "eglSwapInterval", (_EGLProc
) eglSwapInterval
},
1837 { "eglTerminate", (_EGLProc
) eglTerminate
},
1838 { "eglWaitClient", (_EGLProc
) eglWaitClient
},
1839 { "eglWaitGL", (_EGLProc
) eglWaitGL
},
1840 { "eglWaitNative", (_EGLProc
) eglWaitNative
},
1841 { "eglCreateSync", (_EGLProc
) eglCreateSync
},
1842 { "eglDestroySync", (_EGLProc
) eglDestroySync
},
1843 { "eglClientWaitSync", (_EGLProc
) eglClientWaitSync
},
1844 { "eglGetSyncAttrib", (_EGLProc
) eglGetSyncAttrib
},
1845 { "eglWaitSync", (_EGLProc
) eglWaitSync
},
1846 { "eglCreateImage", (_EGLProc
) eglCreateImage
},
1847 { "eglDestroyImage", (_EGLProc
) eglDestroyImage
},
1848 { "eglGetPlatformDisplay", (_EGLProc
) eglGetPlatformDisplay
},
1849 { "eglCreatePlatformWindowSurface", (_EGLProc
) eglCreatePlatformWindowSurface
},
1850 { "eglCreatePlatformPixmapSurface", (_EGLProc
) eglCreatePlatformPixmapSurface
},
1851 { "eglCreateImageKHR", (_EGLProc
) eglCreateImageKHR
},
1852 { "eglDestroyImageKHR", (_EGLProc
) eglDestroyImage
},
1853 { "eglCreateSyncKHR", (_EGLProc
) eglCreateSyncKHR
},
1854 { "eglCreateSync64KHR", (_EGLProc
) eglCreateSync64KHR
},
1855 { "eglDestroySyncKHR", (_EGLProc
) eglDestroySync
},
1856 { "eglClientWaitSyncKHR", (_EGLProc
) eglClientWaitSync
},
1857 { "eglWaitSyncKHR", (_EGLProc
) eglWaitSyncKHR
},
1858 { "eglSignalSyncKHR", (_EGLProc
) eglSignalSyncKHR
},
1859 { "eglGetSyncAttribKHR", (_EGLProc
) eglGetSyncAttribKHR
},
1860 { "eglSwapBuffersRegionNOK", (_EGLProc
) eglSwapBuffersRegionNOK
},
1861 { "eglCreateDRMImageMESA", (_EGLProc
) eglCreateDRMImageMESA
},
1862 { "eglExportDRMImageMESA", (_EGLProc
) eglExportDRMImageMESA
},
1863 { "eglBindWaylandDisplayWL", (_EGLProc
) eglBindWaylandDisplayWL
},
1864 { "eglUnbindWaylandDisplayWL", (_EGLProc
) eglUnbindWaylandDisplayWL
},
1865 { "eglQueryWaylandBufferWL", (_EGLProc
) eglQueryWaylandBufferWL
},
1866 { "eglCreateWaylandBufferFromImageWL", (_EGLProc
) eglCreateWaylandBufferFromImageWL
},
1867 { "eglPostSubBufferNV", (_EGLProc
) eglPostSubBufferNV
},
1868 { "eglSwapBuffersWithDamageEXT", (_EGLProc
) eglSwapBuffersWithDamageEXT
},
1869 { "eglGetPlatformDisplayEXT", (_EGLProc
) eglGetPlatformDisplayEXT
},
1870 { "eglCreatePlatformWindowSurfaceEXT", (_EGLProc
) eglCreatePlatformWindowSurfaceEXT
},
1871 { "eglCreatePlatformPixmapSurfaceEXT", (_EGLProc
) eglCreatePlatformPixmapSurfaceEXT
},
1872 { "eglGetSyncValuesCHROMIUM", (_EGLProc
) eglGetSyncValuesCHROMIUM
},
1873 { "eglExportDMABUFImageQueryMESA", (_EGLProc
) eglExportDMABUFImageQueryMESA
},
1874 { "eglExportDMABUFImageMESA", (_EGLProc
) eglExportDMABUFImageMESA
},
1881 RETURN_EGL_SUCCESS(NULL
, NULL
);
1884 if (strncmp(procname
, "egl", 3) == 0) {
1885 for (i
= 0; egl_functions
[i
].name
; i
++) {
1886 if (strcmp(egl_functions
[i
].name
, procname
) == 0) {
1887 ret
= egl_functions
[i
].function
;
1893 ret
= _eglGetDriverProc(procname
);
1895 RETURN_EGL_SUCCESS(NULL
, ret
);
1899 _eglLockDisplayInterop(EGLDisplay dpy
, EGLContext context
,
1900 _EGLDisplay
**disp
, _EGLDriver
**drv
,
1904 *disp
= _eglLockDisplay(dpy
);
1905 if (!*disp
|| !(*disp
)->Initialized
|| !(*disp
)->Driver
) {
1907 _eglUnlockDisplay(*disp
);
1908 return MESA_GLINTEROP_INVALID_DISPLAY
;
1911 *drv
= (*disp
)->Driver
;
1913 *ctx
= _eglLookupContext(context
, *disp
);
1915 ((*ctx
)->ClientAPI
!= EGL_OPENGL_API
&&
1916 (*ctx
)->ClientAPI
!= EGL_OPENGL_ES_API
)) {
1917 _eglUnlockDisplay(*disp
);
1918 return MESA_GLINTEROP_INVALID_CONTEXT
;
1921 return MESA_GLINTEROP_SUCCESS
;
1925 MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy
, EGLContext context
,
1926 struct mesa_glinterop_device_info
*out
)
1933 ret
= _eglLockDisplayInterop(dpy
, context
, &disp
, &drv
, &ctx
);
1934 if (ret
!= MESA_GLINTEROP_SUCCESS
)
1937 if (drv
->API
.GLInteropQueryDeviceInfo
)
1938 ret
= drv
->API
.GLInteropQueryDeviceInfo(disp
, ctx
, out
);
1940 ret
= MESA_GLINTEROP_UNSUPPORTED
;
1942 _eglUnlockDisplay(disp
);
1947 MesaGLInteropEGLExportObject(EGLDisplay dpy
, EGLContext context
,
1948 struct mesa_glinterop_export_in
*in
,
1949 struct mesa_glinterop_export_out
*out
)
1956 ret
= _eglLockDisplayInterop(dpy
, context
, &disp
, &drv
, &ctx
);
1957 if (ret
!= MESA_GLINTEROP_SUCCESS
)
1960 if (drv
->API
.GLInteropExportObject
)
1961 ret
= drv
->API
.GLInteropExportObject(disp
, ctx
, in
, out
);
1963 ret
= MESA_GLINTEROP_UNSUPPORTED
;
1965 _eglUnlockDisplay(disp
);