diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2018-01-08 05:41:34 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2018-01-08 05:41:34 +0000 |
commit | c00801de923e125863aaf8180439d59d610b2517 (patch) | |
tree | e2896aa2785f3cf2151aeeb3c95fb5cc09a2fe02 /lib/mesa/src/egl/main | |
parent | be30e6efb92db21299b936c0e068e7088941e9c9 (diff) |
Revert to Mesa 13.0.6 again.
Corruption has again been reported on Intel hardware running Xorg with
the modesetting driver (which uses OpenGL based acceleration instead of
SNA acceleration the intel driver defaults to).
Reported in various forms on Sandy Bridge (X220), Ivy Bridge (X230) and
Haswell (X240). Confirmed to not occur with the intel driver but the
xserver was changed to default to the modesetting driver on >= gen4
hardware (except Ironlake).
One means of triggering this is to open a large pdf with xpdf on an
idle machine and highlight a section of the document.
There have been reports of gpu hangs on gen4 intel hardware
(T500 with GM45, X61 with 965GM) when starting Xorg as well.
Diffstat (limited to 'lib/mesa/src/egl/main')
23 files changed, 532 insertions, 1199 deletions
diff --git a/lib/mesa/src/egl/main/50_mesa.json b/lib/mesa/src/egl/main/50_mesa.json deleted file mode 100644 index 8aaaa100f..000000000 --- a/lib/mesa/src/egl/main/50_mesa.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file_format_version" : "1.0.0", - "ICD" : { - "library_path" : "libEGL_mesa.so.0" - } -} diff --git a/lib/mesa/src/egl/main/eglapi.c b/lib/mesa/src/egl/main/eglapi.c index 16ae74145..d93f26cbc 100644 --- a/lib/mesa/src/egl/main/eglapi.c +++ b/lib/mesa/src/egl/main/eglapi.c @@ -89,7 +89,7 @@ #include "c99_compat.h" #include "c11/threads.h" #include "GL/mesa_glinterop.h" -#include "util/macros.h" +#include "eglcompiler.h" #include "eglglobals.h" #include "eglcontext.h" @@ -157,12 +157,6 @@ _EGL_CHECK_OBJECT(disp, Sync, s, ret, drv) -struct _egl_entrypoint { - const char *name; - _EGLProc function; -}; - - static inline _EGLDriver * _eglCheckDisplay(_EGLDisplay *disp, const char *msg) { @@ -294,7 +288,7 @@ _eglSetFuncName(const char *funcName, _EGLDisplay *disp, EGLenum objectType, _EG * Return an EGL error code. The output parameter out_attrib_list is modified * only on success. */ -static EGLint +EGLint _eglConvertIntsToAttribs(const EGLint *int_list, EGLAttrib **out_attrib_list) { size_t len = 0; @@ -480,7 +474,6 @@ _eglCreateExtensionsString(_EGLDisplay *dpy) /* Please keep these sorted alphabetically. */ _EGL_CHECK_EXTENSION(ANDROID_framebuffer_target); _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer); - _EGL_CHECK_EXTENSION(ANDROID_native_fence_sync); _EGL_CHECK_EXTENSION(ANDROID_recordable); _EGL_CHECK_EXTENSION(CHROMIUM_sync_control); @@ -488,13 +481,10 @@ _eglCreateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(EXT_buffer_age); _EGL_CHECK_EXTENSION(EXT_create_context_robustness); _EGL_CHECK_EXTENSION(EXT_image_dma_buf_import); - _EGL_CHECK_EXTENSION(EXT_image_dma_buf_import_modifiers); _EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage); _EGL_CHECK_EXTENSION(KHR_cl_event2); - _EGL_CHECK_EXTENSION(KHR_config_attribs); _EGL_CHECK_EXTENSION(KHR_create_context); - _EGL_CHECK_EXTENSION(KHR_create_context_no_error); _EGL_CHECK_EXTENSION(KHR_fence_sync); _EGL_CHECK_EXTENSION(KHR_get_all_proc_addresses); _EGL_CHECK_EXTENSION(KHR_gl_colorspace); @@ -507,7 +497,6 @@ _eglCreateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(KHR_image_base); _EGL_CHECK_EXTENSION(KHR_image_pixmap); _EGL_CHECK_EXTENSION(KHR_no_config_context); - _EGL_CHECK_EXTENSION(KHR_partial_update); _EGL_CHECK_EXTENSION(KHR_reusable_sync); _EGL_CHECK_EXTENSION(KHR_surfaceless_context); if (dpy->Extensions.EXT_swap_buffers_with_damage) @@ -607,11 +596,6 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) */ disp->Extensions.KHR_get_all_proc_addresses = EGL_TRUE; - /* Extensions is used to provide EGL 1.3 functionality for 1.2 aware - * programs. It is driver agnostic and handled in the main EGL code. - */ - disp->Extensions.KHR_config_attribs = EGL_TRUE; - _eglComputeVersion(disp); _eglCreateExtensionsString(disp); _eglCreateAPIsString(disp); @@ -660,11 +644,7 @@ eglQueryString(EGLDisplay dpy, EGLint name) _EGLDriver *drv; if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) { - const char *ret = _eglGetClientExtensionString(); - if (ret != NULL) - RETURN_EGL_SUCCESS(NULL, ret); - else - RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, NULL); + RETURN_EGL_SUCCESS(NULL, _eglGlobal.ClientExtensionString); } disp = _eglLockDisplay(dpy); @@ -831,14 +811,6 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE); } - /* If a native window underlying either draw or read is no longer valid, - * an EGL_BAD_NATIVE_WINDOW error is generated. - */ - if (draw_surf && draw_surf->Lost) - RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE); - if (read_surf && read_surf->Lost) - RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE); - ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context); RETURN_EGL_EVAL(disp, ret); @@ -920,10 +892,10 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, } static void * -_fixupNativeWindow(_EGLDisplay *disp, void *native_window) +fixupNativeWindow(_EGLDisplay *disp, void *native_window) { #ifdef HAVE_X11_PLATFORM - if (disp && disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) { + if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) { /* The `native_window` parameter for the X11 platform differs between * eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In * eglCreateWindowSurface(), the type of `native_window` is an Xlib @@ -944,7 +916,7 @@ eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, { _EGLDisplay *disp = _eglLockDisplay(dpy); - native_window = _fixupNativeWindow(disp, native_window); + native_window = fixupNativeWindow(disp, native_window); _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE); return _eglCreateWindowSurfaceCommon(disp, config, native_window, @@ -967,7 +939,7 @@ eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, if (attrib_list && !int_attribs) RETURN_EGL_ERROR(disp, EGL_BAD_ALLOC, EGL_NO_SURFACE); - native_window = _fixupNativeWindow(disp, native_window); + native_window = fixupNativeWindow(disp, native_window); surface = _eglCreateWindowSurfaceCommon(disp, config, native_window, int_attribs); free(int_attribs); @@ -975,7 +947,7 @@ eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, } static void * -_fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap) +fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap) { #ifdef HAVE_X11_PLATFORM /* The `native_pixmap` parameter for the X11 platform differs between @@ -985,7 +957,7 @@ _fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap) * `Pixmap*`. Convert `Pixmap*` to `Pixmap` because that's what * dri2_x11_create_pixmap_surface() expects. */ - if (disp && disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL) + if (disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL) return (void *)(* (Pixmap*) native_pixmap); #endif return native_pixmap; @@ -1049,7 +1021,7 @@ eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, _EGLDisplay *disp = _eglLockDisplay(dpy); _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE); - native_pixmap = _fixupNativePixmap(disp, native_pixmap); + native_pixmap = fixupNativePixmap(disp, native_pixmap); return _eglCreatePixmapSurfaceCommon(disp, config, native_pixmap, attrib_list); } @@ -1070,7 +1042,7 @@ eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, if (attrib_list && !int_attribs) RETURN_EGL_ERROR(disp, EGL_BAD_ALLOC, EGL_NO_SURFACE); - native_pixmap = _fixupNativePixmap(disp, native_pixmap); + native_pixmap = fixupNativePixmap(disp, native_pixmap); surface = _eglCreatePixmapSurfaceCommon(disp, config, native_pixmap, int_attribs); free(int_attribs); @@ -1226,33 +1198,15 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); #endif - /* From the EGL 1.5 spec: - * - * If eglSwapBuffers is called and the native window associated with - * surface is no longer valid, an EGL_BAD_NATIVE_WINDOW error is - * generated. - */ - if (surf->Lost) - RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE); - ret = drv->API.SwapBuffers(drv, disp, surf); - /* EGL_KHR_partial_update - * Frame boundary successfully reached, - * reset damage region and reset BufferAgeRead - */ - if (ret) { - surf->SetDamageRegionCalled = EGL_FALSE; - surf->BufferAgeRead = EGL_FALSE; - } - RETURN_EGL_EVAL(disp, ret); } static EGLBoolean -_eglSwapBuffersWithDamageCommon(_EGLDisplay *disp, _EGLSurface *surf, - EGLint *rects, EGLint n_rects) +eglSwapBuffersWithDamageCommon(_EGLDisplay *disp, _EGLSurface *surf, + EGLint *rects, EGLint n_rects) { _EGLContext *ctx = _eglGetCurrentContext(); _EGLDriver *drv; @@ -1270,15 +1224,6 @@ _eglSwapBuffersWithDamageCommon(_EGLDisplay *disp, _EGLSurface *surf, ret = drv->API.SwapBuffersWithDamageEXT(drv, disp, surf, rects, n_rects); - /* EGL_KHR_partial_update - * Frame boundary successfully reached, - * reset damage region and reset BufferAgeRead - */ - if (ret) { - surf->SetDamageRegionCalled = EGL_FALSE; - surf->BufferAgeRead = EGL_FALSE; - } - RETURN_EGL_EVAL(disp, ret); } @@ -1289,7 +1234,7 @@ eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface surface, _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - return _eglSwapBuffersWithDamageCommon(disp, surf, rects, n_rects); + return eglSwapBuffersWithDamageCommon(disp, surf, rects, n_rects); } static EGLBoolean EGLAPIENTRY @@ -1299,71 +1244,7 @@ eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface surface, _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - return _eglSwapBuffersWithDamageCommon(disp, surf, rects, n_rects); -} - -/** - * If the width of the passed rect is greater than the surface's - * width then it is clamped to the width of the surface. Same with - * height. - */ - -static void -_eglSetDamageRegionKHRClampRects(_EGLDisplay* disp, _EGLSurface* surf, - EGLint *rects, EGLint n_rects) -{ - EGLint i; - EGLint surf_height = surf->Height; - EGLint surf_width = surf->Width; - - for (i = 0; i < (4 * n_rects); i += 4) { - EGLint x, y, rect_width, rect_height; - x = rects[i]; - y = rects[i + 1]; - rect_width = rects[i + 2]; - rect_height = rects[i + 3]; - - if (rect_width > surf_width - x) - rects[i + 2] = surf_width - x; - - if (rect_height > surf_height - y) - rects[i + 3] = surf_height - y; - } -} - -static EGLBoolean EGLAPIENTRY -eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface, - EGLint *rects, EGLint n_rects) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGLContext *ctx = _eglGetCurrentContext(); - _EGLDriver *drv; - EGLBoolean ret; - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); - - if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || - surf->Type != EGL_WINDOW_BIT || - ctx->DrawSurface != surf || - surf->SwapBehavior != EGL_BUFFER_DESTROYED) - RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE); - - /* If the damage region is already set or - * buffer age is not queried between - * frame boundaries, throw bad access error - */ - - if (surf->SetDamageRegionCalled || !surf->BufferAgeRead) - RETURN_EGL_ERROR(disp, EGL_BAD_ACCESS, EGL_FALSE); - - _eglSetDamageRegionKHRClampRects(disp, surf, rects, n_rects); - ret = drv->API.SetDamageRegion(drv, disp, surf, rects, n_rects); - - if (ret) - surf->SetDamageRegionCalled = EGL_TRUE; - - RETURN_EGL_EVAL(disp, ret); + return eglSwapBuffersWithDamageCommon(disp, surf, rects, n_rects); } EGLBoolean EGLAPIENTRY @@ -1686,12 +1567,16 @@ eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, } -static EGLBoolean -_eglDestroyImageCommon(_EGLDisplay *disp, _EGLImage *img) +EGLBoolean EGLAPIENTRY +eglDestroyImage(EGLDisplay dpy, EGLImage image) { + _EGLDisplay *disp = _eglLockDisplay(dpy); + _EGLImage *img = _eglLookupImage(image, disp); _EGLDriver *drv; EGLBoolean ret; + _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); if (!disp->Extensions.KHR_image_base) RETURN_EGL_EVAL(disp, EGL_FALSE); @@ -1704,24 +1589,6 @@ _eglDestroyImageCommon(_EGLDisplay *disp, _EGLImage *img) RETURN_EGL_EVAL(disp, ret); } -EGLBoolean EGLAPIENTRY -eglDestroyImage(EGLDisplay dpy, EGLImage image) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLImage *img = _eglLookupImage(image, disp); - _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE); - return _eglDestroyImageCommon(disp, img); -} - -static EGLBoolean EGLAPIENTRY -eglDestroyImageKHR(EGLDisplay dpy, EGLImage image) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLImage *img = _eglLookupImage(image, disp); - _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE); - return _eglDestroyImageCommon(disp, img); -} - static EGLSync _eglCreateSync(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list, @@ -1748,17 +1615,9 @@ _eglCreateSync(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list, RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SYNC_KHR); } - /* If type is EGL_SYNC_FENCE and no context is current for the bound API - * (i.e., eglGetCurrentContext returns EGL_NO_CONTEXT ), an EGL_BAD_MATCH - * error is generated. - */ - if (!ctx && - (type == EGL_SYNC_FENCE_KHR || type == EGL_SYNC_NATIVE_FENCE_ANDROID)) - RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SYNC_KHR); - /* return an error if the client API doesn't support GL_OES_EGL_sync */ - if (ctx && (ctx->Resource.Display != disp || - ctx->ClientAPI != EGL_OPENGL_ES_API)) + if (!ctx || ctx->Resource.Display != disp || + ctx->ClientAPI != EGL_OPENGL_ES_API) RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SYNC_KHR); switch (type) { @@ -1774,10 +1633,6 @@ _eglCreateSync(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list, if (!disp->Extensions.KHR_cl_event2) RETURN_EGL_ERROR(disp, invalid_type_error, EGL_NO_SYNC_KHR); break; - case EGL_SYNC_NATIVE_FENCE_ANDROID: - if (!disp->Extensions.ANDROID_native_fence_sync) - RETURN_EGL_ERROR(disp, invalid_type_error, EGL_NO_SYNC_KHR); - break; default: RETURN_EGL_ERROR(disp, invalid_type_error, EGL_NO_SYNC_KHR); } @@ -1838,16 +1693,19 @@ eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) } -static EGLBoolean -_eglDestroySync(_EGLDisplay *disp, _EGLSync *s) +EGLBoolean EGLAPIENTRY +eglDestroySync(EGLDisplay dpy, EGLSync sync) { + _EGLDisplay *disp = _eglLockDisplay(dpy); + _EGLSync *s = _eglLookupSync(sync, disp); _EGLDriver *drv; EGLBoolean ret; + _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); + _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); assert(disp->Extensions.KHR_reusable_sync || - disp->Extensions.KHR_fence_sync || - disp->Extensions.ANDROID_native_fence_sync); + disp->Extensions.KHR_fence_sync); _eglUnlinkSync(s); ret = drv->API.DestroySyncKHR(drv, disp, s); @@ -1855,36 +1713,20 @@ _eglDestroySync(_EGLDisplay *disp, _EGLSync *s) RETURN_EGL_EVAL(disp, ret); } -EGLBoolean EGLAPIENTRY -eglDestroySync(EGLDisplay dpy, EGLSync sync) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLSync *s = _eglLookupSync(sync, disp); - _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); - return _eglDestroySync(disp, s); -} -static EGLBoolean EGLAPIENTRY -eglDestroySyncKHR(EGLDisplay dpy, EGLSync sync) +EGLint EGLAPIENTRY +eglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSync *s = _eglLookupSync(sync, disp); - _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); - return _eglDestroySync(disp, s); -} - - -static EGLint -_eglClientWaitSyncCommon(_EGLDisplay *disp, EGLDisplay dpy, - _EGLSync *s, EGLint flags, EGLTime timeout) -{ _EGLDriver *drv; EGLint ret; + _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); + _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); assert(disp->Extensions.KHR_reusable_sync || - disp->Extensions.KHR_fence_sync || - disp->Extensions.ANDROID_native_fence_sync); + disp->Extensions.KHR_fence_sync); if (s->SyncStatus == EGL_SIGNALED_KHR) RETURN_EGL_EVAL(disp, EGL_CONDITION_SATISFIED_KHR); @@ -1909,26 +1751,6 @@ _eglClientWaitSyncCommon(_EGLDisplay *disp, EGLDisplay dpy, RETURN_EGL_EVAL(disp, ret); } -EGLint EGLAPIENTRY -eglClientWaitSync(EGLDisplay dpy, EGLSync sync, - EGLint flags, EGLTime timeout) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLSync *s = _eglLookupSync(sync, disp); - _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); - return _eglClientWaitSyncCommon(disp, dpy, s, flags, timeout); -} - -static EGLint EGLAPIENTRY -eglClientWaitSyncKHR(EGLDisplay dpy, EGLSync sync, - EGLint flags, EGLTime timeout) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLSync *s = _eglLookupSync(sync, disp); - _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); - return _eglClientWaitSyncCommon(disp, dpy, s, flags, timeout); -} - static EGLint _eglWaitSyncCommon(_EGLDisplay *disp, _EGLSync *s, EGLint flags) @@ -2003,8 +1825,7 @@ _eglGetSyncAttribCommon(_EGLDisplay *disp, _EGLSync *s, EGLint attribute, EGLAtt _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); assert(disp->Extensions.KHR_reusable_sync || - disp->Extensions.KHR_fence_sync || - disp->Extensions.ANDROID_native_fence_sync); + disp->Extensions.KHR_fence_sync); ret = drv->API.GetSyncAttrib(drv, disp, s, attribute, value); RETURN_EGL_EVAL(disp, ret); @@ -2047,29 +1868,6 @@ eglGetSyncAttribKHR(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint *valu return result; } -static EGLint EGLAPIENTRY -eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLSync *s = _eglLookupSync(sync, disp); - _EGLDriver *drv; - EGLBoolean ret; - - _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); - - /* the spec doesn't seem to specify what happens if the fence - * type is not EGL_SYNC_NATIVE_FENCE_ANDROID, but this seems - * sensible: - */ - if (!(s && (s->Type == EGL_SYNC_NATIVE_FENCE_ANDROID))) - RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_NO_NATIVE_FENCE_FD_ANDROID); - - _EGL_CHECK_SYNC(disp, s, EGL_NO_NATIVE_FENCE_FD_ANDROID, drv); - assert(disp->Extensions.ANDROID_native_fence_sync); - ret = drv->API.DupNativeFenceFDANDROID(drv, disp, s); - - RETURN_EGL_EVAL(disp, ret); -} static EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, @@ -2217,8 +2015,7 @@ eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImage image) _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); _EGL_CHECK_DISPLAY(disp, NULL, drv); - if (!disp->Extensions.WL_create_wayland_buffer_from_image) - RETURN_EGL_EVAL(disp, NULL); + assert(disp->Extensions.WL_create_wayland_buffer_from_image); img = _eglLookupImage(image, disp); @@ -2382,7 +2179,7 @@ eglLabelObjectKHR(EGLDisplay dpy, EGLenum objectType, EGLObjectKHR object, } static EGLBoolean -_validDebugMessageLevel(EGLAttrib level) +validDebugMessageLevel(EGLAttrib level) { return (level >= EGL_DEBUG_MSG_CRITICAL_KHR && level <= EGL_DEBUG_MSG_INFO_KHR); @@ -2403,7 +2200,7 @@ eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback, int i; for (i = 0; attrib_list[i] != EGL_NONE; i += 2) { - if (_validDebugMessageLevel(attrib_list[i])) { + if (validDebugMessageLevel(attrib_list[i])) { if (attrib_list[i + 1]) newEnabled |= DebugBitFromType(attrib_list[i]); else @@ -2440,7 +2237,7 @@ eglQueryDebugKHR(EGLint attribute, EGLAttrib *value) mtx_lock(_eglGlobal.Mutex); do { - if (_validDebugMessageLevel(attribute)) { + if (validDebugMessageLevel(attribute)) { if (_eglGlobal.debugTypesEnabled & DebugBitFromType(attribute)) *value = EGL_TRUE; else @@ -2463,77 +2260,108 @@ eglQueryDebugKHR(EGLint attribute, EGLAttrib *value) return EGL_TRUE; } -static int -_eglFunctionCompare(const void *key, const void *elem) -{ - const char *procname = key; - const struct _egl_entrypoint *entrypoint = elem; - return strcmp(procname, entrypoint->name); -} - -static EGLBoolean EGLAPIENTRY -eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint max_formats, - EGLint *formats, EGLint *num_formats) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; - EGLBoolean ret; - - _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE); - - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); - - ret = drv->API.QueryDmaBufFormatsEXT(drv, disp, max_formats, formats, - num_formats); - - RETURN_EGL_EVAL(disp, ret); -} - -static EGLBoolean EGLAPIENTRY -eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint format, EGLint max_modifiers, - EGLuint64KHR *modifiers, EGLBoolean *external_only, - EGLint *num_modifiers) -{ - _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; - EGLBoolean ret; - - _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE); - - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); - - ret = drv->API.QueryDmaBufModifiersEXT(drv, disp, format, max_modifiers, - modifiers, external_only, - num_modifiers); - - RETURN_EGL_EVAL(disp, ret); -} - __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname) { - static const struct _egl_entrypoint egl_functions[] = { -#define EGL_ENTRYPOINT(f) { .name = #f, .function = (_EGLProc) f }, -#include "eglentrypoint.h" -#undef EGL_ENTRYPOINT + static const struct { + const char *name; + _EGLProc function; + } egl_functions[] = { + /* core functions queryable in the presence of + * EGL_KHR_get_all_proc_addresses or EGL 1.5 + */ + /* alphabetical order */ + { "eglBindAPI", (_EGLProc) eglBindAPI }, + { "eglBindTexImage", (_EGLProc) eglBindTexImage }, + { "eglChooseConfig", (_EGLProc) eglChooseConfig }, + { "eglCopyBuffers", (_EGLProc) eglCopyBuffers }, + { "eglCreateContext", (_EGLProc) eglCreateContext }, + { "eglCreatePbufferFromClientBuffer", (_EGLProc) eglCreatePbufferFromClientBuffer }, + { "eglCreatePbufferSurface", (_EGLProc) eglCreatePbufferSurface }, + { "eglCreatePixmapSurface", (_EGLProc) eglCreatePixmapSurface }, + { "eglCreateWindowSurface", (_EGLProc) eglCreateWindowSurface }, + { "eglDestroyContext", (_EGLProc) eglDestroyContext }, + { "eglDestroySurface", (_EGLProc) eglDestroySurface }, + { "eglGetConfigAttrib", (_EGLProc) eglGetConfigAttrib }, + { "eglGetConfigs", (_EGLProc) eglGetConfigs }, + { "eglGetCurrentContext", (_EGLProc) eglGetCurrentContext }, + { "eglGetCurrentDisplay", (_EGLProc) eglGetCurrentDisplay }, + { "eglGetCurrentSurface", (_EGLProc) eglGetCurrentSurface }, + { "eglGetDisplay", (_EGLProc) eglGetDisplay }, + { "eglGetError", (_EGLProc) eglGetError }, + { "eglGetProcAddress", (_EGLProc) eglGetProcAddress }, + { "eglInitialize", (_EGLProc) eglInitialize }, + { "eglMakeCurrent", (_EGLProc) eglMakeCurrent }, + { "eglQueryAPI", (_EGLProc) eglQueryAPI }, + { "eglQueryContext", (_EGLProc) eglQueryContext }, + { "eglQueryString", (_EGLProc) eglQueryString }, + { "eglQuerySurface", (_EGLProc) eglQuerySurface }, + { "eglReleaseTexImage", (_EGLProc) eglReleaseTexImage }, + { "eglReleaseThread", (_EGLProc) eglReleaseThread }, + { "eglSurfaceAttrib", (_EGLProc) eglSurfaceAttrib }, + { "eglSwapBuffers", (_EGLProc) eglSwapBuffers }, + { "eglSwapInterval", (_EGLProc) eglSwapInterval }, + { "eglTerminate", (_EGLProc) eglTerminate }, + { "eglWaitClient", (_EGLProc) eglWaitClient }, + { "eglWaitGL", (_EGLProc) eglWaitGL }, + { "eglWaitNative", (_EGLProc) eglWaitNative }, + { "eglCreateSync", (_EGLProc) eglCreateSync }, + { "eglDestroySync", (_EGLProc) eglDestroySync }, + { "eglClientWaitSync", (_EGLProc) eglClientWaitSync }, + { "eglGetSyncAttrib", (_EGLProc) eglGetSyncAttrib }, + { "eglWaitSync", (_EGLProc) eglWaitSync }, + { "eglCreateImage", (_EGLProc) eglCreateImage }, + { "eglDestroyImage", (_EGLProc) eglDestroyImage }, + { "eglGetPlatformDisplay", (_EGLProc) eglGetPlatformDisplay }, + { "eglCreatePlatformWindowSurface", (_EGLProc) eglCreatePlatformWindowSurface }, + { "eglCreatePlatformPixmapSurface", (_EGLProc) eglCreatePlatformPixmapSurface }, + { "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR }, + { "eglDestroyImageKHR", (_EGLProc) eglDestroyImage }, + { "eglCreateSyncKHR", (_EGLProc) eglCreateSyncKHR }, + { "eglCreateSync64KHR", (_EGLProc) eglCreateSync64KHR }, + { "eglDestroySyncKHR", (_EGLProc) eglDestroySync }, + { "eglClientWaitSyncKHR", (_EGLProc) eglClientWaitSync }, + { "eglWaitSyncKHR", (_EGLProc) eglWaitSyncKHR }, + { "eglSignalSyncKHR", (_EGLProc) eglSignalSyncKHR }, + { "eglGetSyncAttribKHR", (_EGLProc) eglGetSyncAttribKHR }, + { "eglSwapBuffersRegionNOK", (_EGLProc) eglSwapBuffersRegionNOK }, + { "eglCreateDRMImageMESA", (_EGLProc) eglCreateDRMImageMESA }, + { "eglExportDRMImageMESA", (_EGLProc) eglExportDRMImageMESA }, + { "eglBindWaylandDisplayWL", (_EGLProc) eglBindWaylandDisplayWL }, + { "eglUnbindWaylandDisplayWL", (_EGLProc) eglUnbindWaylandDisplayWL }, + { "eglQueryWaylandBufferWL", (_EGLProc) eglQueryWaylandBufferWL }, + { "eglCreateWaylandBufferFromImageWL", (_EGLProc) eglCreateWaylandBufferFromImageWL }, + { "eglPostSubBufferNV", (_EGLProc) eglPostSubBufferNV }, + { "eglSwapBuffersWithDamageEXT", (_EGLProc) eglSwapBuffersWithDamageEXT }, + { "eglSwapBuffersWithDamageKHR", (_EGLProc) eglSwapBuffersWithDamageKHR }, + { "eglGetPlatformDisplayEXT", (_EGLProc) eglGetPlatformDisplayEXT }, + { "eglCreatePlatformWindowSurfaceEXT", (_EGLProc) eglCreatePlatformWindowSurfaceEXT }, + { "eglCreatePlatformPixmapSurfaceEXT", (_EGLProc) eglCreatePlatformPixmapSurfaceEXT }, + { "eglGetSyncValuesCHROMIUM", (_EGLProc) eglGetSyncValuesCHROMIUM }, + { "eglExportDMABUFImageQueryMESA", (_EGLProc) eglExportDMABUFImageQueryMESA }, + { "eglExportDMABUFImageMESA", (_EGLProc) eglExportDMABUFImageMESA }, + { "eglLabelObjectKHR", (_EGLProc) eglLabelObjectKHR }, + { "eglDebugMessageControlKHR", (_EGLProc) eglDebugMessageControlKHR }, + { "eglQueryDebugKHR", (_EGLProc) eglQueryDebugKHR }, + { NULL, NULL } }; - _EGLProc ret = NULL; + EGLint i; + _EGLProc ret; if (!procname) RETURN_EGL_SUCCESS(NULL, NULL); _EGL_FUNC_START(NULL, EGL_NONE, NULL, NULL); + ret = NULL; if (strncmp(procname, "egl", 3) == 0) { - const struct _egl_entrypoint *entrypoint = - bsearch(procname, - egl_functions, ARRAY_SIZE(egl_functions), - sizeof(egl_functions[0]), - _eglFunctionCompare); - if (entrypoint) - ret = entrypoint->function; + for (i = 0; egl_functions[i].name; i++) { + if (strcmp(egl_functions[i].name, procname) == 0) { + ret = egl_functions[i].function; + break; + } + } } - if (!ret) ret = _eglGetDriverProc(procname); diff --git a/lib/mesa/src/egl/main/eglapi.h b/lib/mesa/src/egl/main/eglapi.h index 852a34584..b9bcc8ec8 100644 --- a/lib/mesa/src/egl/main/eglapi.h +++ b/lib/mesa/src/egl/main/eglapi.h @@ -110,8 +110,6 @@ struct _egl_api _EGLSurface *draw); EGLBoolean (*CopyBuffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, void *native_pixmap_target); - EGLBoolean (*SetDamageRegion)(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surface, EGLint *rects, EGLint n_rects); /* misc functions */ EGLBoolean (*WaitClient)(_EGLDriver *drv, _EGLDisplay *dpy, @@ -148,8 +146,6 @@ struct _egl_api EGLBoolean (*GetSyncAttrib)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLint attribute, EGLAttrib *value); - EGLint (*DupNativeFenceFDANDROID)(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSync *sync); EGLBoolean (*SwapBuffersRegionNOK)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, @@ -200,17 +196,11 @@ struct _egl_api int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx, struct mesa_glinterop_export_in *in, struct mesa_glinterop_export_out *out); - - EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy, - EGLint max_formats, EGLint *formats, - EGLint *num_formats); - EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay *dpy, - EGLint format, EGLint max_modifiers, - EGLuint64KHR *modifiers, - EGLBoolean *external_only, - EGLint *num_modifiers); }; +EGLint _eglConvertIntsToAttribs(const EGLint *int_list, + EGLAttrib **out_attrib_list); + #ifdef __cplusplus } #endif diff --git a/lib/mesa/src/egl/main/eglarray.c b/lib/mesa/src/egl/main/eglarray.c index ba6cb3e6a..d2f39af49 100644 --- a/lib/mesa/src/egl/main/eglarray.c +++ b/lib/mesa/src/egl/main/eglarray.c @@ -26,7 +26,6 @@ **************************************************************************/ -#include <assert.h> #include <stdlib.h> #include <string.h> @@ -158,15 +157,25 @@ _eglFilterArray(_EGLArray *array, void **data, EGLint size, if (!array) return 0; - assert(filter); - for (i = 0; i < array->Size; i++) { - if (filter(array->Elements[i], filter_data)) { - if (data && count < size) - data[count] = array->Elements[i]; - count++; + if (filter) { + for (i = 0; i < array->Size; i++) { + if (filter(array->Elements[i], filter_data)) { + if (data && count < size) + data[count] = array->Elements[i]; + count++; + } + if (data && count >= size) + break; + } + } + else { + if (data) { + count = (size < array->Size) ? size : array->Size; + memcpy(data, array->Elements, count * sizeof(array->Elements[0])); + } + else { + count = array->Size; } - if (data && count >= size) - break; } return count; diff --git a/lib/mesa/src/egl/main/eglcompiler.h b/lib/mesa/src/egl/main/eglcompiler.h new file mode 100644 index 000000000..9804ca4f2 --- /dev/null +++ b/lib/mesa/src/egl/main/eglcompiler.h @@ -0,0 +1,46 @@ +/************************************************************************** + * + * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> + * Copyright 2010 LunarG, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef EGLCOMPILER_INCLUDED +#define EGLCOMPILER_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#define STATIC_ASSERT(COND) \ + do { \ + (void) sizeof(char [1 - 2*!(COND)]); \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* EGLCOMPILER_INCLUDED */ diff --git a/lib/mesa/src/egl/main/eglconfig.c b/lib/mesa/src/egl/main/eglconfig.c index f747c3318..6161d26e4 100644 --- a/lib/mesa/src/egl/main/eglconfig.c +++ b/lib/mesa/src/egl/main/eglconfig.c @@ -37,8 +37,8 @@ #include <string.h> #include <assert.h> #include "c99_compat.h" -#include "util/macros.h" +#include "eglcompiler.h" #include "eglconfig.h" #include "egldisplay.h" #include "eglcurrent.h" @@ -728,7 +728,7 @@ _eglFilterConfigArray(_EGLArray *array, EGLConfig *configs, EGLint i, count; if (!num_configs) - return _eglError(EGL_BAD_PARAMETER, "eglChooseConfig"); + return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs"); /* get the number of matched configs */ count = _eglFilterArray(array, NULL, 0, diff --git a/lib/mesa/src/egl/main/eglcontext.c b/lib/mesa/src/egl/main/eglcontext.c index 1b0316043..5313e1dab 100644 --- a/lib/mesa/src/egl/main/eglcontext.c +++ b/lib/mesa/src/egl/main/eglcontext.c @@ -312,26 +312,6 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy, ctx->Flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR; break; - case EGL_CONTEXT_OPENGL_NO_ERROR_KHR: - if (dpy->Version < 14 || - !dpy->Extensions.KHR_create_context_no_error) { - err = EGL_BAD_ATTRIBUTE; - break; - } - - /* The KHR_no_error spec only applies against OpenGL 2.0+ and - * OpenGL ES 2.0+ - */ - if ((api != EGL_OPENGL_API && api != EGL_OPENGL_ES_API) || - ctx->ClientMajorVersion < 2) { - err = EGL_BAD_ATTRIBUTE; - break; - } - - /* Canonicalize value to EGL_TRUE/EGL_FALSE definitions */ - ctx->NoError = !!val; - break; - default: err = EGL_BAD_ATTRIBUTE; break; @@ -478,16 +458,6 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy, break; } - /* The EGL_KHR_create_context_no_error spec says: - * - * "BAD_MATCH is generated if the EGL_CONTEXT_OPENGL_NO_ERROR_KHR is TRUE at - * the same time as a debug or robustness context is specified." - */ - if (ctx->NoError && (ctx->Flags & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR || - ctx->Flags & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR)) { - err = EGL_BAD_MATCH; - } - if ((ctx->Flags & ~(EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR | EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR)) != 0) { @@ -519,8 +489,10 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf, const EGLenum api = eglQueryAPI(); EGLint err; - if (api == EGL_NONE) - return _eglError(EGL_BAD_MATCH, "eglCreateContext(no client API)"); + if (api == EGL_NONE) { + _eglError(EGL_BAD_MATCH, "eglCreateContext(no client API)"); + return EGL_FALSE; + } _eglInitResource(&ctx->Resource, sizeof(*ctx), dpy); ctx->ClientAPI = api; @@ -611,7 +583,7 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c, * * Note that the context may be NULL. */ -_EGLContext * +static _EGLContext * _eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo *t) { _EGLContext *oldCtx; diff --git a/lib/mesa/src/egl/main/eglcontext.h b/lib/mesa/src/egl/main/eglcontext.h index 0667622ba..69bf77d8a 100644 --- a/lib/mesa/src/egl/main/eglcontext.h +++ b/lib/mesa/src/egl/main/eglcontext.h @@ -62,7 +62,6 @@ struct _egl_context EGLint Flags; EGLint Profile; EGLint ResetNotificationStrategy; - EGLBoolean NoError; /* The real render buffer when a window surface is bound */ EGLint WindowRenderBuffer; @@ -83,9 +82,6 @@ _eglBindContext(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read, _EGLContext **old_ctx, _EGLSurface **old_draw, _EGLSurface **old_read); -extern _EGLContext * -_eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo *t); - /** * Increment reference count for the context. diff --git a/lib/mesa/src/egl/main/eglcurrent.c b/lib/mesa/src/egl/main/eglcurrent.c index 835631d3b..eae7bdcea 100644 --- a/lib/mesa/src/egl/main/eglcurrent.c +++ b/lib/mesa/src/egl/main/eglcurrent.c @@ -26,8 +26,10 @@ **************************************************************************/ +#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> #include "c99_compat.h" #include "c11/threads.h" @@ -35,10 +37,9 @@ #include "eglcurrent.h" #include "eglglobals.h" - /* This should be kept in sync with _eglInitThreadInfo() */ #define _EGL_THREAD_INFO_INITIALIZER \ - { EGL_SUCCESS, { NULL }, 0 } + { EGL_SUCCESS, NULL, EGL_OPENGL_ES_API, NULL, NULL, NULL } /* a fallback thread info to guarantee that every thread always has one */ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; @@ -111,7 +112,7 @@ _eglInitThreadInfo(_EGLThreadInfo *t) memset(t, 0, sizeof(*t)); t->LastError = EGL_SUCCESS; /* default, per EGL spec */ - t->CurrentAPIIndex = _eglConvertApiToIndex(EGL_OPENGL_ES_API); + t->CurrentAPI = EGL_OPENGL_ES_API; } @@ -205,32 +206,21 @@ _eglIsCurrentThreadDummy(void) /** - * Return the currently bound context of the given API, or NULL. - */ -_EGLContext * -_eglGetAPIContext(EGLenum api) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - return t->CurrentContexts[_eglConvertApiToIndex(api)]; -} - - -/** * Return the currently bound context of the current API, or NULL. */ _EGLContext * _eglGetCurrentContext(void) { _EGLThreadInfo *t = _eglGetCurrentThread(); - return t->CurrentContexts[t->CurrentAPIIndex]; + return t->CurrentContext; } /** * Record EGL error code and return EGL_FALSE. */ -EGLBoolean -_eglError(EGLint errCode, const char *msg) +static EGLBoolean +_eglInternalError(EGLint errCode, const char *msg) { _EGLThreadInfo *t = _eglGetCurrentThread(); @@ -290,3 +280,86 @@ _eglError(EGLint errCode, const char *msg) return EGL_FALSE; } + +EGLBoolean +_eglError(EGLint errCode, const char *msg) +{ + if (errCode != EGL_SUCCESS) { + EGLint type; + if (errCode == EGL_BAD_ALLOC) { + type = EGL_DEBUG_MSG_CRITICAL_KHR; + } else { + type = EGL_DEBUG_MSG_ERROR_KHR; + } + + _eglDebugReport(errCode, msg, type, NULL); + } else + _eglInternalError(errCode, msg); + + return EGL_FALSE; +} + +/** + * Returns the label set for the current thread. + */ +EGLLabelKHR +_eglGetThreadLabel(void) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + return t->Label; +} + +static void +_eglDebugReportFullv(EGLenum error, const char *command, const char *funcName, + EGLint type, EGLLabelKHR objectLabel, const char *message, va_list args) +{ + EGLDEBUGPROCKHR callback = NULL; + + mtx_lock(_eglGlobal.Mutex); + if (_eglGlobal.debugTypesEnabled & DebugBitFromType(type)) { + callback = _eglGlobal.debugCallback; + } + mtx_unlock(_eglGlobal.Mutex); + + if (callback != NULL) { + char *buf = NULL; + + if (message != NULL) { + if (vasprintf(&buf, message, args) < 0) { + buf = NULL; + } + } + callback(error, command, type, _eglGetThreadLabel(), objectLabel, buf); + free(buf); + } + + if (type == EGL_DEBUG_MSG_CRITICAL_KHR || type == EGL_DEBUG_MSG_ERROR_KHR) { + _eglInternalError(error, funcName); + } +} + +void +_eglDebugReportFull(EGLenum error, const char *command, const char *funcName, + EGLint type, EGLLabelKHR objectLabel, const char *message, ...) +{ + va_list args; + va_start(args, message); + _eglDebugReportFullv(error, command, funcName, type, objectLabel, message, args); + va_end(args); +} + +void +_eglDebugReport(EGLenum error, const char *funcName, + EGLint type, const char *message, ...) +{ + _EGLThreadInfo *thr = _eglGetCurrentThread(); + va_list args; + + if (funcName == NULL) { + funcName = thr->CurrentFuncName; + } + + va_start(args, message); + _eglDebugReportFullv(error, thr->CurrentFuncName, funcName, type, thr->CurrentObjectLabel, message, args); + va_end(args); +} diff --git a/lib/mesa/src/egl/main/egldispatchstubs.c b/lib/mesa/src/egl/main/egldispatchstubs.c deleted file mode 100644 index e02abd7a9..000000000 --- a/lib/mesa/src/egl/main/egldispatchstubs.c +++ /dev/null @@ -1,110 +0,0 @@ -#include "egldispatchstubs.h" -#include "g_egldispatchstubs.h" - -#include <string.h> - -#include "eglcurrent.h" - -static const __EGLapiExports *exports; - -const int __EGL_DISPATCH_FUNC_COUNT = __EGL_DISPATCH_COUNT; -int __EGL_DISPATCH_FUNC_INDICES[__EGL_DISPATCH_COUNT + 1]; - -static int FindProcIndex(const char *name) -{ - unsigned first = 0; - unsigned last = __EGL_DISPATCH_COUNT - 1; - - while (first <= last) { - unsigned middle = (first + last) / 2; - int comp = strcmp(name, - __EGL_DISPATCH_FUNC_NAMES[middle]); - - if (comp > 0) - first = middle + 1; - else if (comp < 0) - last = middle - 1; - else - return middle; - } - - /* Just point to the dummy entry at the end of the respective table */ - return __EGL_DISPATCH_COUNT; -} - -void __eglInitDispatchStubs(const __EGLapiExports *exportsTable) -{ - int i; - exports = exportsTable; - for (i=0; i<__EGL_DISPATCH_FUNC_COUNT; i++) { - __EGL_DISPATCH_FUNC_INDICES[i] = -1; - } -} - -void __eglSetDispatchIndex(const char *name, int dispatchIndex) -{ - int index = FindProcIndex(name); - __EGL_DISPATCH_FUNC_INDICES[index] = dispatchIndex; -} - -void *__eglDispatchFindDispatchFunction(const char *name) -{ - int index = FindProcIndex(name); - return (void *) __EGL_DISPATCH_FUNCS[index]; -} - -static __eglMustCastToProperFunctionPointerType FetchVendorFunc(__EGLvendorInfo *vendor, - int index, EGLint errorCode) -{ - __eglMustCastToProperFunctionPointerType func = NULL; - - if (vendor != NULL) { - func = exports->fetchDispatchEntry(vendor, __EGL_DISPATCH_FUNC_INDICES[index]); - } - if (func == NULL) { - if (errorCode != EGL_SUCCESS) { - _eglError(errorCode, __EGL_DISPATCH_FUNC_NAMES[index]); - } - return NULL; - } - - if (!exports->setLastVendor(vendor)) { - // Don't bother trying to set an error code in libglvnd. If - // setLastVendor failed, then setEGLError would also fail. - _eglError(errorCode, __EGL_DISPATCH_FUNC_NAMES[index]); - return NULL; - } - - return func; -} - -__eglMustCastToProperFunctionPointerType __eglDispatchFetchByCurrent(int index) -{ - __EGLvendorInfo *vendor; - - // Note: This is only used for the eglWait* functions. For those, if - // there's no current context, then they're supposed to do nothing but - // return success. - exports->threadInit(); - vendor = exports->getCurrentVendor(); - return FetchVendorFunc(vendor, index, EGL_SUCCESS); -} - -__eglMustCastToProperFunctionPointerType __eglDispatchFetchByDisplay(EGLDisplay dpy, int index) -{ - __EGLvendorInfo *vendor; - - exports->threadInit(); - vendor = exports->getVendorFromDisplay(dpy); - return FetchVendorFunc(vendor, index, EGL_BAD_DISPLAY); -} - -__eglMustCastToProperFunctionPointerType __eglDispatchFetchByDevice(EGLDeviceEXT dev, int index) -{ - __EGLvendorInfo *vendor; - - exports->threadInit(); - vendor = exports->getVendorFromDevice(dev); - return FetchVendorFunc(vendor, index, EGL_BAD_DEVICE_EXT); -} - diff --git a/lib/mesa/src/egl/main/egldispatchstubs.h b/lib/mesa/src/egl/main/egldispatchstubs.h deleted file mode 100644 index 7861ea5e6..000000000 --- a/lib/mesa/src/egl/main/egldispatchstubs.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef EGLDISPATCHSTUBS_H -#define EGLDISPATCHSTUBS_H - -#include "glvnd/libeglabi.h" - -// These variables are all generated along with the dispatch stubs. -extern const int __EGL_DISPATCH_FUNC_COUNT; -extern const char * const __EGL_DISPATCH_FUNC_NAMES[]; -extern int __EGL_DISPATCH_FUNC_INDICES[]; -extern const __eglMustCastToProperFunctionPointerType __EGL_DISPATCH_FUNCS[]; - -void __eglInitDispatchStubs(const __EGLapiExports *exportsTable); -void __eglSetDispatchIndex(const char *name, int index); - -/** - * Returns the dispatch function for the given name, or \c NULL if the function - * isn't supported. - */ -void *__eglDispatchFindDispatchFunction(const char *name); - -// Helper functions used by the generated stubs. -__eglMustCastToProperFunctionPointerType __eglDispatchFetchByDisplay(EGLDisplay dpy, int index); -__eglMustCastToProperFunctionPointerType __eglDispatchFetchByDevice(EGLDeviceEXT dpy, int index); -__eglMustCastToProperFunctionPointerType __eglDispatchFetchByCurrent(int index); - -#endif // EGLDISPATCHSTUBS_H diff --git a/lib/mesa/src/egl/main/egldisplay.c b/lib/mesa/src/egl/main/egldisplay.c index 690728d2f..37711bd86 100644 --- a/lib/mesa/src/egl/main/egldisplay.c +++ b/lib/mesa/src/egl/main/egldisplay.c @@ -36,7 +36,6 @@ #include <stdlib.h> #include <string.h> #include "c11/threads.h" -#include "util/u_atomic.h" #include "eglcontext.h" #include "eglcurrent.h" @@ -49,6 +48,10 @@ #include "eglsync.h" /* Includes for _eglNativePlatformDetectNativeDisplay */ +#ifdef HAVE_MINCORE +#include <unistd.h> +#include <sys/mman.h> +#endif #ifdef HAVE_WAYLAND_PLATFORM #include <wayland-client.h> #endif @@ -58,7 +61,7 @@ /** - * Map --with-platforms names to platform types. + * Map --with-egl-platforms names to platform types. */ static const struct { _EGLPlatformType platform; @@ -102,6 +105,35 @@ _eglGetNativePlatformFromEnv(void) /** + * Perform validity checks on a generic pointer. + */ +static EGLBoolean +_eglPointerIsDereferencable(void *p) +{ +#ifdef HAVE_MINCORE + uintptr_t addr = (uintptr_t) p; + unsigned char valid = 0; + const long page_size = getpagesize(); + + if (p == NULL) + return EGL_FALSE; + + /* align addr to page_size */ + addr &= ~(page_size - 1); + + if (mincore((void *) addr, page_size, &valid) < 0) { + _eglLog(_EGL_DEBUG, "mincore failed: %m"); + return EGL_FALSE; + } + + return (valid & 0x01) == 0x01; +#else + return p != NULL; +#endif +} + + +/** * Try detecting native platform with the help of native display characteristcs. */ static _EGLPlatformType @@ -148,32 +180,25 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay) _EGLPlatformType _eglGetNativePlatform(void *nativeDisplay) { - static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM; - _EGLPlatformType detected_platform = native_platform; - - if (detected_platform == _EGL_INVALID_PLATFORM) { - const char *detection_method; + static _EGLPlatformType native_platform; + char *detection_method; - detected_platform = _eglGetNativePlatformFromEnv(); - detection_method = "environment overwrite"; - - if (detected_platform == _EGL_INVALID_PLATFORM) { - detected_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay); - detection_method = "autodetected"; - } + native_platform = _eglGetNativePlatformFromEnv(); + detection_method = "environment overwrite"; - if (detected_platform == _EGL_INVALID_PLATFORM) { - detected_platform = _EGL_NATIVE_PLATFORM; - detection_method = "build-time configuration"; - } - - _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)", - egl_platforms[detected_platform].name, detection_method); + if (native_platform == _EGL_INVALID_PLATFORM) { + native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay); + detection_method = "autodetected"; + } - p_atomic_cmpxchg(&native_platform, _EGL_INVALID_PLATFORM, - detected_platform); + if (native_platform == _EGL_INVALID_PLATFORM) { + native_platform = _EGL_NATIVE_PLATFORM; + detection_method = "build-time configuration"; } + _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)", + egl_platforms[native_platform].name, detection_method); + return native_platform; } @@ -447,7 +472,7 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type) #ifdef HAVE_X11_PLATFORM static EGLBoolean -_eglParseX11DisplayAttribList(_EGLDisplay *display, const EGLint *attrib_list) +_eglParseX11DisplayAttribList(const EGLint *attrib_list) { int i; @@ -461,11 +486,14 @@ _eglParseX11DisplayAttribList(_EGLDisplay *display, const EGLint *attrib_list) /* EGL_EXT_platform_x11 recognizes exactly one attribute, * EGL_PLATFORM_X11_SCREEN_EXT, which is optional. + * + * Mesa supports connecting to only the default screen, so we reject + * screen != 0. */ - if (attrib != EGL_PLATFORM_X11_SCREEN_EXT) - return _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay"); - - display->Options.Platform = (void *)(uintptr_t)value; + if (attrib != EGL_PLATFORM_X11_SCREEN_EXT || value != 0) { + _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay"); + return EGL_FALSE; + } } return EGL_TRUE; @@ -475,19 +503,11 @@ _EGLDisplay* _eglGetX11Display(Display *native_display, const EGLint *attrib_list) { - _EGLDisplay *display = _eglFindDisplay(_EGL_PLATFORM_X11, - native_display); - - if (!display) { - _eglError(EGL_BAD_ALLOC, "eglGetPlatformDisplay"); - return NULL; - } - - if (!_eglParseX11DisplayAttribList(display, attrib_list)) { + if (!_eglParseX11DisplayAttribList(attrib_list)) { return NULL; } - return display; + return _eglFindDisplay(_EGL_PLATFORM_X11, native_display); } #endif /* HAVE_X11_PLATFORM */ diff --git a/lib/mesa/src/egl/main/egldisplay.h b/lib/mesa/src/egl/main/egldisplay.h index 3d5a44578..62d9a112f 100644 --- a/lib/mesa/src/egl/main/egldisplay.h +++ b/lib/mesa/src/egl/main/egldisplay.h @@ -94,7 +94,6 @@ struct _egl_extensions /* Please keep these sorted alphabetically. */ EGLBoolean ANDROID_framebuffer_target; EGLBoolean ANDROID_image_native_buffer; - EGLBoolean ANDROID_native_fence_sync; EGLBoolean ANDROID_recordable; EGLBoolean CHROMIUM_sync_control; @@ -102,11 +101,9 @@ struct _egl_extensions EGLBoolean EXT_buffer_age; EGLBoolean EXT_create_context_robustness; EGLBoolean EXT_image_dma_buf_import; - EGLBoolean EXT_image_dma_buf_import_modifiers; EGLBoolean EXT_swap_buffers_with_damage; EGLBoolean KHR_cl_event2; - EGLBoolean KHR_config_attribs; EGLBoolean KHR_create_context; EGLBoolean KHR_fence_sync; EGLBoolean KHR_get_all_proc_addresses; @@ -118,11 +115,9 @@ struct _egl_extensions EGLBoolean KHR_image_base; EGLBoolean KHR_image_pixmap; EGLBoolean KHR_no_config_context; - EGLBoolean KHR_partial_update; EGLBoolean KHR_reusable_sync; EGLBoolean KHR_surfaceless_context; EGLBoolean KHR_wait_sync; - EGLBoolean KHR_create_context_no_error; EGLBoolean MESA_drm_image; EGLBoolean MESA_image_dma_buf_export; @@ -154,7 +149,6 @@ struct _egl_display struct { EGLBoolean TestOnly; /**< Driver should not set fields when true */ EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */ - void *Platform; /**< Platform-specific options */ } Options; /* these fields are set by the driver during init */ diff --git a/lib/mesa/src/egl/main/eglentrypoint.h b/lib/mesa/src/egl/main/eglentrypoint.h deleted file mode 100644 index f7fe77410..000000000 --- a/lib/mesa/src/egl/main/eglentrypoint.h +++ /dev/null @@ -1,80 +0,0 @@ -/* core functions queryable in the presence of - * EGL_KHR_get_all_proc_addresses or EGL 1.5 - */ -/* alphabetical order */ -EGL_ENTRYPOINT(eglBindAPI) -EGL_ENTRYPOINT(eglBindTexImage) -EGL_ENTRYPOINT(eglBindWaylandDisplayWL) -EGL_ENTRYPOINT(eglChooseConfig) -EGL_ENTRYPOINT(eglClientWaitSync) -EGL_ENTRYPOINT(eglClientWaitSyncKHR) -EGL_ENTRYPOINT(eglCopyBuffers) -EGL_ENTRYPOINT(eglCreateContext) -EGL_ENTRYPOINT(eglCreateDRMImageMESA) -EGL_ENTRYPOINT(eglCreateImage) -EGL_ENTRYPOINT(eglCreateImageKHR) -EGL_ENTRYPOINT(eglCreatePbufferFromClientBuffer) -EGL_ENTRYPOINT(eglCreatePbufferSurface) -EGL_ENTRYPOINT(eglCreatePixmapSurface) -EGL_ENTRYPOINT(eglCreatePlatformPixmapSurface) -EGL_ENTRYPOINT(eglCreatePlatformPixmapSurfaceEXT) -EGL_ENTRYPOINT(eglCreatePlatformWindowSurface) -EGL_ENTRYPOINT(eglCreatePlatformWindowSurfaceEXT) -EGL_ENTRYPOINT(eglCreateSync) -EGL_ENTRYPOINT(eglCreateSync64KHR) -EGL_ENTRYPOINT(eglCreateSyncKHR) -EGL_ENTRYPOINT(eglCreateWaylandBufferFromImageWL) -EGL_ENTRYPOINT(eglCreateWindowSurface) -EGL_ENTRYPOINT(eglDebugMessageControlKHR) -EGL_ENTRYPOINT(eglDestroyContext) -EGL_ENTRYPOINT(eglDestroyImage) -EGL_ENTRYPOINT(eglDestroyImageKHR) -EGL_ENTRYPOINT(eglDestroySurface) -EGL_ENTRYPOINT(eglDestroySync) -EGL_ENTRYPOINT(eglDestroySyncKHR) -EGL_ENTRYPOINT(eglDupNativeFenceFDANDROID) -EGL_ENTRYPOINT(eglExportDMABUFImageMESA) -EGL_ENTRYPOINT(eglExportDMABUFImageQueryMESA) -EGL_ENTRYPOINT(eglExportDRMImageMESA) -EGL_ENTRYPOINT(eglGetConfigAttrib) -EGL_ENTRYPOINT(eglGetConfigs) -EGL_ENTRYPOINT(eglGetCurrentContext) -EGL_ENTRYPOINT(eglGetCurrentDisplay) -EGL_ENTRYPOINT(eglGetCurrentSurface) -EGL_ENTRYPOINT(eglGetDisplay) -EGL_ENTRYPOINT(eglGetError) -EGL_ENTRYPOINT(eglGetPlatformDisplay) -EGL_ENTRYPOINT(eglGetPlatformDisplayEXT) -EGL_ENTRYPOINT(eglGetProcAddress) -EGL_ENTRYPOINT(eglGetSyncAttrib) -EGL_ENTRYPOINT(eglGetSyncAttribKHR) -EGL_ENTRYPOINT(eglGetSyncValuesCHROMIUM) -EGL_ENTRYPOINT(eglInitialize) -EGL_ENTRYPOINT(eglLabelObjectKHR) -EGL_ENTRYPOINT(eglMakeCurrent) -EGL_ENTRYPOINT(eglPostSubBufferNV) -EGL_ENTRYPOINT(eglQueryAPI) -EGL_ENTRYPOINT(eglQueryContext) -EGL_ENTRYPOINT(eglQueryDebugKHR) -EGL_ENTRYPOINT(eglQueryDmaBufFormatsEXT) -EGL_ENTRYPOINT(eglQueryDmaBufModifiersEXT) -EGL_ENTRYPOINT(eglQueryString) -EGL_ENTRYPOINT(eglQuerySurface) -EGL_ENTRYPOINT(eglQueryWaylandBufferWL) -EGL_ENTRYPOINT(eglReleaseTexImage) -EGL_ENTRYPOINT(eglReleaseThread) -EGL_ENTRYPOINT(eglSetDamageRegionKHR) -EGL_ENTRYPOINT(eglSignalSyncKHR) -EGL_ENTRYPOINT(eglSurfaceAttrib) -EGL_ENTRYPOINT(eglSwapBuffers) -EGL_ENTRYPOINT(eglSwapBuffersRegionNOK) -EGL_ENTRYPOINT(eglSwapBuffersWithDamageEXT) -EGL_ENTRYPOINT(eglSwapBuffersWithDamageKHR) -EGL_ENTRYPOINT(eglSwapInterval) -EGL_ENTRYPOINT(eglTerminate) -EGL_ENTRYPOINT(eglUnbindWaylandDisplayWL) -EGL_ENTRYPOINT(eglWaitClient) -EGL_ENTRYPOINT(eglWaitGL) -EGL_ENTRYPOINT(eglWaitNative) -EGL_ENTRYPOINT(eglWaitSync) -EGL_ENTRYPOINT(eglWaitSyncKHR) diff --git a/lib/mesa/src/egl/main/eglfallbacks.c b/lib/mesa/src/egl/main/eglfallbacks.c index 1575ab5f7..d0fce8c20 100644 --- a/lib/mesa/src/egl/main/eglfallbacks.c +++ b/lib/mesa/src/egl/main/eglfallbacks.c @@ -77,7 +77,6 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.ReleaseTexImage = (void*) _eglReturnFalse; drv->API.CopyBuffers = (void*) _eglReturnFalse; drv->API.SwapBuffers = (void*) _eglReturnFalse; - drv->API.SetDamageRegion = (void*) _eglReturnFalse; drv->API.SwapInterval = _eglSwapInterval; drv->API.WaitClient = (void*) _eglReturnFalse; @@ -93,7 +92,6 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.WaitSyncKHR = NULL; drv->API.SignalSyncKHR = NULL; drv->API.GetSyncAttrib = _eglGetSyncAttrib; - drv->API.DupNativeFenceFDANDROID = NULL; drv->API.CreateDRMImageMESA = NULL; drv->API.ExportDRMImageMESA = NULL; diff --git a/lib/mesa/src/egl/main/eglglobals.c b/lib/mesa/src/egl/main/eglglobals.c index 907122661..cb41063e3 100644 --- a/lib/mesa/src/egl/main/eglglobals.c +++ b/lib/mesa/src/egl/main/eglglobals.c @@ -29,20 +29,12 @@ #include <stdlib.h> -#include <stdio.h> -#include <string.h> #include <assert.h> #include "c11/threads.h" #include "eglglobals.h" #include "egldisplay.h" #include "egldriver.h" -#include "egllog.h" - -#ifdef HAVE_MINCORE -#include <unistd.h> -#include <sys/mman.h> -#endif static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP; @@ -58,13 +50,9 @@ struct _egl_global _eglGlobal = _eglFiniDisplay }, - /* ClientOnlyExtensionString */ + /* ClientExtensionString */ "EGL_EXT_client_extensions" " EGL_EXT_platform_base" - " EGL_KHR_client_get_all_proc_addresses" - " EGL_KHR_debug", - - /* PlatformExtensionString */ #ifdef HAVE_WAYLAND_PLATFORM " EGL_EXT_platform_wayland" #endif @@ -77,9 +65,8 @@ struct _egl_global _eglGlobal = #ifdef HAVE_SURFACELESS_PLATFORM " EGL_MESA_platform_surfaceless" #endif - "", - - NULL, /* ClientExtensionsString */ + " EGL_KHR_client_get_all_proc_addresses" + " EGL_KHR_debug", NULL, /* debugCallback */ _EGL_DEBUG_BIT_CRITICAL | _EGL_DEBUG_BIT_ERROR, /* debugTypesEnabled */ @@ -114,73 +101,3 @@ _eglAddAtExitCall(void (*func)(void)) mtx_unlock(_eglGlobal.Mutex); } } - -const char * -_eglGetClientExtensionString(void) -{ - const char *ret; - - mtx_lock(_eglGlobal.Mutex); - - if (_eglGlobal.ClientExtensionString == NULL) { - size_t clientLen = strlen(_eglGlobal.ClientOnlyExtensionString); - size_t platformLen = strlen(_eglGlobal.PlatformExtensionString); - - _eglGlobal.ClientExtensionString = (char *) malloc(clientLen + platformLen + 1); - if (_eglGlobal.ClientExtensionString != NULL) { - char *ptr = _eglGlobal.ClientExtensionString; - - memcpy(ptr, _eglGlobal.ClientOnlyExtensionString, clientLen); - ptr += clientLen; - - if (platformLen > 0) { - // Note that if PlatformExtensionString is not empty, then it will - // already have a leading space. - assert(_eglGlobal.PlatformExtensionString[0] == ' '); - memcpy(ptr, _eglGlobal.PlatformExtensionString, platformLen); - ptr += platformLen; - } - *ptr = '\0'; - } - } - ret = _eglGlobal.ClientExtensionString; - - mtx_unlock(_eglGlobal.Mutex); - return ret; -} - -EGLBoolean -_eglPointerIsDereferencable(void *p) -{ -#ifdef HAVE_MINCORE - uintptr_t addr = (uintptr_t) p; - unsigned char valid = 0; - const long page_size = getpagesize(); - - if (p == NULL) - return EGL_FALSE; - - /* align addr to page_size */ - addr &= ~(page_size - 1); - - if (mincore((void *) addr, page_size, &valid) < 0) { - _eglLog(_EGL_DEBUG, "mincore failed: %m"); - return EGL_FALSE; - } - - /* mincore() returns 0 on success, and -1 on failure. The last parameter - * is a vector of bytes with one entry for each page queried. mincore - * returns page residency information in the first bit of each byte in the - * vector. - * - * Residency doesn't actually matter when determining whether a pointer is - * dereferenceable, so the output vector can be ignored. What matters is - * whether mincore succeeds. See: - * - * http://man7.org/linux/man-pages/man2/mincore.2.html - */ - return EGL_TRUE; -#else - return p != NULL; -#endif -} diff --git a/lib/mesa/src/egl/main/eglglobals.h b/lib/mesa/src/egl/main/eglglobals.h index 6655ccab6..ec4f3d04a 100644 --- a/lib/mesa/src/egl/main/eglglobals.h +++ b/lib/mesa/src/egl/main/eglglobals.h @@ -57,15 +57,7 @@ struct _egl_global EGLint NumAtExitCalls; void (*AtExitCalls[10])(void); - /* - * Under libglvnd, the client extension string has to be split into two - * strings, one for platform extensions, and one for everything else. So, - * define separate strings for them. _eglGetClientExtensionString will - * concatenate them together for a non-libglvnd build. - */ - const char *ClientOnlyExtensionString; - const char *PlatformExtensionString; - char *ClientExtensionString; + const char *ClientExtensionString; EGLDEBUGPROCKHR debugCallback; unsigned int debugTypesEnabled; @@ -84,13 +76,4 @@ static inline unsigned int DebugBitFromType(EGLenum type) return (1 << (type - EGL_DEBUG_MSG_CRITICAL_KHR)); } -extern const char * -_eglGetClientExtensionString(void); - -/** - * Perform validity checks on a generic pointer. - */ -extern EGLBoolean -_eglPointerIsDereferencable(void *p); - #endif /* EGLGLOBALS_INCLUDED */ diff --git a/lib/mesa/src/egl/main/eglglvnd.c b/lib/mesa/src/egl/main/eglglvnd.c deleted file mode 100644 index 6b984ed6c..000000000 --- a/lib/mesa/src/egl/main/eglglvnd.c +++ /dev/null @@ -1,82 +0,0 @@ -#include <string.h> -#include <assert.h> - -#include <glvnd/libeglabi.h> - -#include "eglcurrent.h" -#include "egldispatchstubs.h" -#include "eglglobals.h" - -static const __EGLapiExports *__eglGLVNDApiExports = NULL; - -static const char * EGLAPIENTRY -__eglGLVNDQueryString(EGLDisplay dpy, EGLenum name) -{ - // For client extensions, return the list of non-platform extensions. The - // platform extensions are returned by __eglGLVNDGetVendorString. - if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) - return _eglGlobal.ClientOnlyExtensionString; - - // For everything else, forward to the normal eglQueryString function. - return eglQueryString(dpy, name); -} - -static const char * -__eglGLVNDGetVendorString(int name) -{ - if (name == __EGL_VENDOR_STRING_PLATFORM_EXTENSIONS) { - const char *str = _eglGlobal.PlatformExtensionString; - // The platform extension string may have a leading space. If it does, - // then skip over it. - while (*str == ' ') { - str++; - } - return str; - } - - return NULL; -} - -static EGLDisplay -__eglGLVNDGetPlatformDisplay(EGLenum platform, void *native_display, - const EGLAttrib *attrib_list) -{ - if (platform == EGL_NONE) { - assert(native_display == (void *) EGL_DEFAULT_DISPLAY); - assert(attrib_list == NULL); - return eglGetDisplay((EGLNativeDisplayType) native_display); - } else { - return eglGetPlatformDisplay(platform, native_display, attrib_list); - } -} - -static void * -__eglGLVNDGetProcAddress(const char *procName) -{ - if (strcmp(procName, "eglQueryString") == 0) - return (void *) __eglGLVNDQueryString; - - return (void *) eglGetProcAddress(procName); -} - -EGLAPI EGLBoolean -__egl_Main(uint32_t version, const __EGLapiExports *exports, - __EGLvendorInfo *vendor, __EGLapiImports *imports) -{ - if (EGL_VENDOR_ABI_GET_MAJOR_VERSION(version) != - EGL_VENDOR_ABI_MAJOR_VERSION) - return EGL_FALSE; - - __eglGLVNDApiExports = exports; - __eglInitDispatchStubs(exports); - - imports->getPlatformDisplay = __eglGLVNDGetPlatformDisplay; - imports->getSupportsAPI = _eglIsApiValid; - imports->getVendorString = __eglGLVNDGetVendorString; - imports->getProcAddress = __eglGLVNDGetProcAddress; - imports->getDispatchAddress = __eglDispatchFindDispatchFunction; - imports->setDispatchIndex = __eglSetDispatchIndex; - - return EGL_TRUE; -} - diff --git a/lib/mesa/src/egl/main/eglimage.c b/lib/mesa/src/egl/main/eglimage.c index 72a556e8d..818b5975c 100644 --- a/lib/mesa/src/egl/main/eglimage.c +++ b/lib/mesa/src/egl/main/eglimage.c @@ -30,291 +30,164 @@ #include <assert.h> #include <string.h> -#include "eglcurrent.h" #include "eglimage.h" #include "egllog.h" -static EGLint -_eglParseKHRImageAttribs(_EGLImageAttribs *attrs, _EGLDisplay *dpy, - EGLint attr, EGLint val) -{ - switch (attr) { - case EGL_IMAGE_PRESERVED_KHR: - if (!dpy->Extensions.KHR_image_base) - return EGL_BAD_PARAMETER; - - attrs->ImagePreserved = val; - break; - - case EGL_GL_TEXTURE_LEVEL_KHR: - if (!dpy->Extensions.KHR_gl_texture_2D_image) - return EGL_BAD_PARAMETER; - - attrs->GLTextureLevel = val; - break; - case EGL_GL_TEXTURE_ZOFFSET_KHR: - if (!dpy->Extensions.KHR_gl_texture_3D_image) - return EGL_BAD_PARAMETER; - - attrs->GLTextureZOffset = val; - break; - default: - return EGL_BAD_PARAMETER; - } - - return EGL_SUCCESS; -} - -static EGLint -_eglParseMESADrmImageAttribs(_EGLImageAttribs *attrs, _EGLDisplay *dpy, - EGLint attr, EGLint val) -{ - if (!dpy->Extensions.MESA_drm_image) - return EGL_BAD_PARAMETER; - - switch (attr) { - case EGL_WIDTH: - attrs->Width = val; - break; - case EGL_HEIGHT: - attrs->Height = val; - break; - case EGL_DRM_BUFFER_FORMAT_MESA: - attrs->DRMBufferFormatMESA = val; - break; - case EGL_DRM_BUFFER_USE_MESA: - attrs->DRMBufferUseMESA = val; - break; - case EGL_DRM_BUFFER_STRIDE_MESA: - attrs->DRMBufferStrideMESA = val; - break; - default: - return EGL_BAD_PARAMETER; - } - - return EGL_SUCCESS; -} - -static EGLint -_eglParseWLBindWaylandDisplayAttribs(_EGLImageAttribs *attrs, _EGLDisplay *dpy, - EGLint attr, EGLint val) -{ - if (!dpy->Extensions.WL_bind_wayland_display) - return EGL_BAD_PARAMETER; - - switch (attr) { - case EGL_WAYLAND_PLANE_WL: - attrs->PlaneWL = val; - break; - default: - return EGL_BAD_PARAMETER; - } - - return EGL_SUCCESS; -} - -static EGLint -_eglParseEXTImageDmaBufImportAttribs(_EGLImageAttribs *attrs, _EGLDisplay *dpy, - EGLint attr, EGLint val) -{ - if (!dpy->Extensions.EXT_image_dma_buf_import) - return EGL_BAD_PARAMETER; - - switch (attr) { - case EGL_WIDTH: - attrs->Width = val; - break; - case EGL_HEIGHT: - attrs->Height = val; - break; - case EGL_LINUX_DRM_FOURCC_EXT: - attrs->DMABufFourCC.Value = val; - attrs->DMABufFourCC.IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE0_FD_EXT: - attrs->DMABufPlaneFds[0].Value = val; - attrs->DMABufPlaneFds[0].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE0_OFFSET_EXT: - attrs->DMABufPlaneOffsets[0].Value = val; - attrs->DMABufPlaneOffsets[0].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE0_PITCH_EXT: - attrs->DMABufPlanePitches[0].Value = val; - attrs->DMABufPlanePitches[0].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE1_FD_EXT: - attrs->DMABufPlaneFds[1].Value = val; - attrs->DMABufPlaneFds[1].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE1_OFFSET_EXT: - attrs->DMABufPlaneOffsets[1].Value = val; - attrs->DMABufPlaneOffsets[1].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE1_PITCH_EXT: - attrs->DMABufPlanePitches[1].Value = val; - attrs->DMABufPlanePitches[1].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE2_FD_EXT: - attrs->DMABufPlaneFds[2].Value = val; - attrs->DMABufPlaneFds[2].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE2_OFFSET_EXT: - attrs->DMABufPlaneOffsets[2].Value = val; - attrs->DMABufPlaneOffsets[2].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE2_PITCH_EXT: - attrs->DMABufPlanePitches[2].Value = val; - attrs->DMABufPlanePitches[2].IsPresent = EGL_TRUE; - break; - case EGL_YUV_COLOR_SPACE_HINT_EXT: - if (val != EGL_ITU_REC601_EXT && val != EGL_ITU_REC709_EXT && - val != EGL_ITU_REC2020_EXT) - return EGL_BAD_ATTRIBUTE; - - attrs->DMABufYuvColorSpaceHint.Value = val; - attrs->DMABufYuvColorSpaceHint.IsPresent = EGL_TRUE; - break; - case EGL_SAMPLE_RANGE_HINT_EXT: - if (val != EGL_YUV_FULL_RANGE_EXT && val != EGL_YUV_NARROW_RANGE_EXT) - return EGL_BAD_ATTRIBUTE; - - attrs->DMABufSampleRangeHint.Value = val; - attrs->DMABufSampleRangeHint.IsPresent = EGL_TRUE; - break; - case EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT: - if (val != EGL_YUV_CHROMA_SITING_0_EXT && - val != EGL_YUV_CHROMA_SITING_0_5_EXT) - return EGL_BAD_ATTRIBUTE; - - attrs->DMABufChromaHorizontalSiting.Value = val; - attrs->DMABufChromaHorizontalSiting.IsPresent = EGL_TRUE; - break; - case EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT: - if (val != EGL_YUV_CHROMA_SITING_0_EXT && - val != EGL_YUV_CHROMA_SITING_0_5_EXT) - return EGL_BAD_ATTRIBUTE; - - attrs->DMABufChromaVerticalSiting.Value = val; - attrs->DMABufChromaVerticalSiting.IsPresent = EGL_TRUE; - break; - default: - return EGL_BAD_PARAMETER; - } - - return EGL_SUCCESS; -} - -static EGLint -_eglParseEXTImageDmaBufImportModifiersAttribs(_EGLImageAttribs *attrs, - _EGLDisplay *dpy, - EGLint attr, EGLint val) -{ - if (!dpy->Extensions.EXT_image_dma_buf_import_modifiers) - return EGL_BAD_PARAMETER; - - switch (attr) { - case EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT: - attrs->DMABufPlaneModifiersLo[0].Value = val; - attrs->DMABufPlaneModifiersLo[0].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT: - attrs->DMABufPlaneModifiersHi[0].Value = val; - attrs->DMABufPlaneModifiersHi[0].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT: - attrs->DMABufPlaneModifiersLo[1].Value = val; - attrs->DMABufPlaneModifiersLo[1].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT: - attrs->DMABufPlaneModifiersHi[1].Value = val; - attrs->DMABufPlaneModifiersHi[1].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT: - attrs->DMABufPlaneModifiersLo[2].Value = val; - attrs->DMABufPlaneModifiersLo[2].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT: - attrs->DMABufPlaneModifiersHi[2].Value = val; - attrs->DMABufPlaneModifiersHi[2].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE3_FD_EXT: - attrs->DMABufPlaneFds[3].Value = val; - attrs->DMABufPlaneFds[3].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE3_OFFSET_EXT: - attrs->DMABufPlaneOffsets[3].Value = val; - attrs->DMABufPlaneOffsets[3].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE3_PITCH_EXT: - attrs->DMABufPlanePitches[3].Value = val; - attrs->DMABufPlanePitches[3].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT: - attrs->DMABufPlaneModifiersLo[3].Value = val; - attrs->DMABufPlaneModifiersLo[3].IsPresent = EGL_TRUE; - break; - case EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT: - attrs->DMABufPlaneModifiersHi[3].Value = val; - attrs->DMABufPlaneModifiersHi[3].IsPresent = EGL_TRUE; - break; - default: - return EGL_BAD_PARAMETER; - } - - return EGL_SUCCESS; -} /** - * Parse the list of image attributes. - * - * Returns EGL_TRUE on success and EGL_FALSE otherwise. - * Function calls _eglError to set the correct error code. + * Parse the list of image attributes and return the proper error code. */ -EGLBoolean +EGLint _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy, const EGLint *attrib_list) { - EGLint i, err; + EGLint i, err = EGL_SUCCESS; + + (void) dpy; memset(attrs, 0, sizeof(*attrs)); + attrs->ImagePreserved = EGL_FALSE; + attrs->GLTextureLevel = 0; + attrs->GLTextureZOffset = 0; if (!attrib_list) - return EGL_TRUE; + return err; for (i = 0; attrib_list[i] != EGL_NONE; i++) { EGLint attr = attrib_list[i++]; EGLint val = attrib_list[i]; - err = _eglParseKHRImageAttribs(attrs, dpy, attr, val); - if (err == EGL_SUCCESS) - continue; - - err = _eglParseMESADrmImageAttribs(attrs, dpy, attr, val); - if (err == EGL_SUCCESS) - continue; - - err = _eglParseWLBindWaylandDisplayAttribs(attrs, dpy, attr, val); - if (err == EGL_SUCCESS) - continue; - - err = _eglParseEXTImageDmaBufImportAttribs(attrs, dpy, attr, val); - if (err == EGL_SUCCESS) - continue; + switch (attr) { + /* EGL_KHR_image_base */ + case EGL_IMAGE_PRESERVED_KHR: + attrs->ImagePreserved = val; + break; + + /* EGL_KHR_gl_image */ + case EGL_GL_TEXTURE_LEVEL_KHR: + attrs->GLTextureLevel = val; + break; + case EGL_GL_TEXTURE_ZOFFSET_KHR: + attrs->GLTextureZOffset = val; + break; + + /* EGL_MESA_drm_image */ + case EGL_WIDTH: + attrs->Width = val; + break; + case EGL_HEIGHT: + attrs->Height = val; + break; + case EGL_DRM_BUFFER_FORMAT_MESA: + attrs->DRMBufferFormatMESA = val; + break; + case EGL_DRM_BUFFER_USE_MESA: + attrs->DRMBufferUseMESA = val; + break; + case EGL_DRM_BUFFER_STRIDE_MESA: + attrs->DRMBufferStrideMESA = val; + break; + + /* EGL_WL_bind_wayland_display */ + case EGL_WAYLAND_PLANE_WL: + attrs->PlaneWL = val; + break; + + case EGL_LINUX_DRM_FOURCC_EXT: + attrs->DMABufFourCC.Value = val; + attrs->DMABufFourCC.IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE0_FD_EXT: + attrs->DMABufPlaneFds[0].Value = val; + attrs->DMABufPlaneFds[0].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE0_OFFSET_EXT: + attrs->DMABufPlaneOffsets[0].Value = val; + attrs->DMABufPlaneOffsets[0].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE0_PITCH_EXT: + attrs->DMABufPlanePitches[0].Value = val; + attrs->DMABufPlanePitches[0].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE1_FD_EXT: + attrs->DMABufPlaneFds[1].Value = val; + attrs->DMABufPlaneFds[1].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE1_OFFSET_EXT: + attrs->DMABufPlaneOffsets[1].Value = val; + attrs->DMABufPlaneOffsets[1].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE1_PITCH_EXT: + attrs->DMABufPlanePitches[1].Value = val; + attrs->DMABufPlanePitches[1].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE2_FD_EXT: + attrs->DMABufPlaneFds[2].Value = val; + attrs->DMABufPlaneFds[2].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE2_OFFSET_EXT: + attrs->DMABufPlaneOffsets[2].Value = val; + attrs->DMABufPlaneOffsets[2].IsPresent = EGL_TRUE; + break; + case EGL_DMA_BUF_PLANE2_PITCH_EXT: + attrs->DMABufPlanePitches[2].Value = val; + attrs->DMABufPlanePitches[2].IsPresent = EGL_TRUE; + break; + case EGL_YUV_COLOR_SPACE_HINT_EXT: + if (val != EGL_ITU_REC601_EXT && val != EGL_ITU_REC709_EXT && + val != EGL_ITU_REC2020_EXT) { + err = EGL_BAD_ATTRIBUTE; + } else { + attrs->DMABufYuvColorSpaceHint.Value = val; + attrs->DMABufYuvColorSpaceHint.IsPresent = EGL_TRUE; + } + break; + case EGL_SAMPLE_RANGE_HINT_EXT: + if (val != EGL_YUV_FULL_RANGE_EXT && val != EGL_YUV_NARROW_RANGE_EXT) { + err = EGL_BAD_ATTRIBUTE; + } else { + attrs->DMABufSampleRangeHint.Value = val; + attrs->DMABufSampleRangeHint.IsPresent = EGL_TRUE; + } + break; + case EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT: + if (val != EGL_YUV_CHROMA_SITING_0_EXT && + val != EGL_YUV_CHROMA_SITING_0_5_EXT) { + err = EGL_BAD_ATTRIBUTE; + } else { + attrs->DMABufChromaHorizontalSiting.Value = val; + attrs->DMABufChromaHorizontalSiting.IsPresent = EGL_TRUE; + } + break; + case EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT: + if (val != EGL_YUV_CHROMA_SITING_0_EXT && + val != EGL_YUV_CHROMA_SITING_0_5_EXT) { + err = EGL_BAD_ATTRIBUTE; + } else { + attrs->DMABufChromaVerticalSiting.Value = val; + attrs->DMABufChromaVerticalSiting.IsPresent = EGL_TRUE; + } + break; + + default: + /* unknown attrs are ignored */ + break; + } + + if (err != EGL_SUCCESS) { + _eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr); + break; + } + } - /* EXT_image_dma_buf_import states that if invalid value is provided for - * its attributes, we should return EGL_BAD_ATTRIBUTE. - * Bail out ASAP, since follow-up calls can return another EGL_BAD error. - */ - if (err == EGL_BAD_ATTRIBUTE) - return _eglError(err, __func__); + return err; +} - err = _eglParseEXTImageDmaBufImportModifiersAttribs(attrs, dpy, attr, val); - if (err == EGL_SUCCESS) - continue; - return _eglError(err, __func__); - } +EGLBoolean +_eglInitImage(_EGLImage *img, _EGLDisplay *dpy) +{ + _eglInitResource(&img->Resource, sizeof(*img), dpy); return EGL_TRUE; } diff --git a/lib/mesa/src/egl/main/eglsurface.c b/lib/mesa/src/egl/main/eglsurface.c index f6e41f10d..3af337fef 100644 --- a/lib/mesa/src/egl/main/eglsurface.c +++ b/lib/mesa/src/egl/main/eglsurface.c @@ -286,14 +286,15 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, return EGL_FALSE; } - if ((conf->SurfaceType & type) == 0) + if ((conf->SurfaceType & type) == 0) { /* The config can't be used to create a surface of this type */ - return _eglError(EGL_BAD_MATCH, func); + _eglError(EGL_BAD_CONFIG, func); + return EGL_FALSE; + } _eglInitResource(&surf->Resource, sizeof(*surf), dpy); surf->Type = type; surf->Config = conf; - surf->Lost = EGL_FALSE; surf->Width = 0; surf->Height = 0; @@ -315,8 +316,6 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, surf->AspectRatio = EGL_UNKNOWN; surf->PostSubBufferSupportedNV = EGL_FALSE; - surf->SetDamageRegionCalled = EGL_FALSE; - surf->BufferAgeRead = EGL_FALSE; /* the default swap interval is 1 */ _eglClampSwapInterval(surf, 1); @@ -395,32 +394,25 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, *value = surface->VGColorspace; break; case EGL_GL_COLORSPACE_KHR: - if (!dpy->Extensions.KHR_gl_colorspace) - return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); - + if (!dpy->Extensions.KHR_gl_colorspace) { + _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); + return EGL_FALSE; + } *value = surface->GLColorspace; break; case EGL_POST_SUB_BUFFER_SUPPORTED_NV: *value = surface->PostSubBufferSupportedNV; break; case EGL_BUFFER_AGE_EXT: - if (!dpy->Extensions.EXT_buffer_age) - return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); - - _EGLContext *ctx = _eglGetCurrentContext(); - EGLint result = drv->API.QueryBufferAge(drv, dpy, surface); - /* error happened */ - if (result < 0) + if (!dpy->Extensions.EXT_buffer_age) { + _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); return EGL_FALSE; - if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || - ctx->DrawSurface != surface) - return _eglError(EGL_BAD_SURFACE, "eglQuerySurface"); - - *value = result; - surface->BufferAgeRead = EGL_TRUE; + } + *value = drv->API.QueryBufferAge(drv, dpy, surface); break; default: - return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); + _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); + return EGL_FALSE; } return EGL_TRUE; @@ -507,17 +499,25 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, if (dpy->Extensions.NOK_texture_from_pixmap) texture_type |= EGL_PIXMAP_BIT; - if (!(surface->Type & texture_type)) - return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + if (!(surface->Type & texture_type)) { + _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + return EGL_FALSE; + } - if (surface->TextureFormat == EGL_NO_TEXTURE) - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + if (surface->TextureFormat == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } - if (surface->TextureTarget == EGL_NO_TEXTURE) - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + if (surface->TextureTarget == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); + if (buffer != EGL_BACK_BUFFER) { + _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); + return EGL_FALSE; + } surface->BoundToTexture = EGL_TRUE; @@ -525,39 +525,14 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, } EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, +_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer) { - /* Just do basic error checking and return success/fail. + /* TODO: do basic error checking and return success/fail. * Drivers must implement the real stuff. */ - EGLint texture_type = EGL_PBUFFER_BIT; - - if (surf == EGL_NO_SURFACE) - return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); - - if (!surf->BoundToTexture) - { - /* Not an error, simply nothing to do */ - return EGL_TRUE; - } - - if (surf->TextureFormat == EGL_NO_TEXTURE) - return _eglError(EGL_BAD_MATCH, "eglReleaseTexImage"); - - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); - - if (dpy->Extensions.NOK_texture_from_pixmap) - texture_type |= EGL_PIXMAP_BIT; - - if (!(surf->Type & texture_type)) - return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); - - surf->BoundToTexture = EGL_FALSE; - - return EGL_TRUE; + return EGL_TRUE; } diff --git a/lib/mesa/src/egl/main/eglsurface.h b/lib/mesa/src/egl/main/eglsurface.h index c53e8d006..fc799ee43 100644 --- a/lib/mesa/src/egl/main/eglsurface.h +++ b/lib/mesa/src/egl/main/eglsurface.h @@ -56,11 +56,6 @@ struct _egl_surface EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */ - /* The native surface is lost. The EGL spec requires certain functions - * to generate EGL_BAD_NATIVE_WINDOW when given this surface. - */ - EGLBoolean Lost; - /* attributes set by attribute list */ EGLint Width, Height; EGLenum TextureFormat; @@ -82,18 +77,6 @@ struct _egl_surface EGLint SwapInterval; - /* EGL_KHR_partial_update - * True if the damage region is already set - * between frame boundaries. - */ - EGLBoolean SetDamageRegionCalled; - - /* EGL_KHR_partial_update - * True if the buffer age is read by the client - * between frame boundaries. - */ - EGLBoolean BufferAgeRead; - /* True if the surface is bound to an OpenGL ES texture */ EGLBoolean BoundToTexture; diff --git a/lib/mesa/src/egl/main/eglsync.c b/lib/mesa/src/egl/main/eglsync.c index cb931b816..dea324b11 100644 --- a/lib/mesa/src/egl/main/eglsync.c +++ b/lib/mesa/src/egl/main/eglsync.c @@ -55,19 +55,11 @@ _eglParseSyncAttribList(_EGLSync *sync, const EGLAttrib *attrib_list) case EGL_CL_EVENT_HANDLE_KHR: if (sync->Type == EGL_SYNC_CL_EVENT_KHR) { sync->CLEvent = val; - } else { - err = EGL_BAD_ATTRIBUTE; + break; } - break; - case EGL_SYNC_NATIVE_FENCE_FD_ANDROID: - if (sync->Type == EGL_SYNC_NATIVE_FENCE_ANDROID) { - /* we take ownership of the native fd, so no dup(): */ - sync->SyncFd = val; - } else { - err = EGL_BAD_ATTRIBUTE; - } - break; + /* fall through */ default: + (void) val; err = EGL_BAD_ATTRIBUTE; break; } @@ -91,24 +83,16 @@ _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type, _eglInitResource(&sync->Resource, sizeof(*sync), dpy); sync->Type = type; sync->SyncStatus = EGL_UNSIGNALED_KHR; - sync->SyncFd = EGL_NO_NATIVE_FENCE_FD_ANDROID; - - err = _eglParseSyncAttribList(sync, attrib_list); switch (type) { case EGL_SYNC_CL_EVENT_KHR: sync->SyncCondition = EGL_SYNC_CL_EVENT_COMPLETE_KHR; break; - case EGL_SYNC_NATIVE_FENCE_ANDROID: - if (sync->SyncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) - sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; - else - sync->SyncCondition = EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID; - break; default: sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; } + err = _eglParseSyncAttribList(sync, attrib_list); if (err != EGL_SUCCESS) return _eglError(err, "eglCreateSyncKHR"); @@ -132,20 +116,17 @@ _eglGetSyncAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, if (sync->SyncStatus != EGL_SIGNALED_KHR && (sync->Type == EGL_SYNC_FENCE_KHR || sync->Type == EGL_SYNC_CL_EVENT_KHR || - sync->Type == EGL_SYNC_REUSABLE_KHR || - sync->Type == EGL_SYNC_NATIVE_FENCE_ANDROID)) + sync->Type == EGL_SYNC_REUSABLE_KHR)) drv->API.ClientWaitSyncKHR(drv, dpy, sync, 0, 0); *value = sync->SyncStatus; break; case EGL_SYNC_CONDITION_KHR: if (sync->Type != EGL_SYNC_FENCE_KHR && - sync->Type != EGL_SYNC_CL_EVENT_KHR && - sync->Type != EGL_SYNC_NATIVE_FENCE_ANDROID) + sync->Type != EGL_SYNC_CL_EVENT_KHR) return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR"); *value = sync->SyncCondition; break; - default: return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR"); break; diff --git a/lib/mesa/src/egl/main/eglsync.h b/lib/mesa/src/egl/main/eglsync.h index 5ac76f3ac..83b6f72fc 100644 --- a/lib/mesa/src/egl/main/eglsync.h +++ b/lib/mesa/src/egl/main/eglsync.h @@ -48,7 +48,6 @@ struct _egl_sync EGLenum SyncStatus; EGLenum SyncCondition; EGLAttrib CLEvent; - EGLint SyncFd; }; |