diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:50:50 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:50:50 +0000 |
commit | 9130ec005fbc78a62420643414d8354d0929ca50 (patch) | |
tree | 6762777acdd2d4eee17ef87290e80dc7afe2b73d /lib/mesa/src/egl | |
parent | ca11beabae33eb59fb981b8adf50b1d47a2a98f0 (diff) |
Merge Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/egl')
35 files changed, 1557 insertions, 2131 deletions
diff --git a/lib/mesa/src/egl/Makefile.sources b/lib/mesa/src/egl/Makefile.sources index 5efdb3378..5f5b6d27e 100644 --- a/lib/mesa/src/egl/Makefile.sources +++ b/lib/mesa/src/egl/Makefile.sources @@ -1,6 +1,5 @@ LIBEGL_C_FILES := \ main/eglapi.c \ - main/eglapi.h \ main/eglarray.c \ main/eglarray.h \ main/eglconfig.c \ @@ -14,7 +13,6 @@ LIBEGL_C_FILES := \ main/egldevice.h \ main/egldisplay.c \ main/egldisplay.h \ - main/egldriver.c \ main/egldriver.h \ main/eglglobals.c \ main/eglglobals.h \ @@ -31,5 +29,4 @@ LIBEGL_C_FILES := \ dri2_backend_core_FILES := \ drivers/dri2/egl_dri2.c \ - drivers/dri2/egl_dri2.h \ - drivers/dri2/egl_dri2_fallbacks.h + drivers/dri2/egl_dri2.h diff --git a/lib/mesa/src/egl/SConscript b/lib/mesa/src/egl/SConscript deleted file mode 100644 index 927092d22..000000000 --- a/lib/mesa/src/egl/SConscript +++ /dev/null @@ -1,36 +0,0 @@ -####################################################################### -# SConscript for EGL - - -Import('*') - -env = env.Clone() - -env.Append(CPPPATH = [ - '#/include', - '#/include/HaikuGL', - '#/src/egl/main', - '#/src', -]) - - -# parse Makefile.sources -egl_sources = env.ParseSourceList('Makefile.sources', 'LIBEGL_C_FILES') - -env.Append(CPPDEFINES = [ - '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_HAIKU', - '_EGL_BUILT_IN_DRIVER_HAIKU', - 'HAVE_HAIKU_PLATFORM', -]) -egl_sources.append('drivers/haiku/egl_haiku.cpp') - -env.Prepend(LIBS = [mesautil]) - -egl = env.SharedLibrary( - target = 'EGL', - source = egl_sources, -) - -egl = env.InstallSharedLibrary(egl, version=(1, 0, 0)) - -env.Alias('egl', egl) diff --git a/lib/mesa/src/egl/drivers/dri2/egl_dri2.c b/lib/mesa/src/egl/drivers/dri2/egl_dri2.c index 2a216ef1c..0e48b9656 100644 --- a/lib/mesa/src/egl/drivers/dri2/egl_dri2.c +++ b/lib/mesa/src/egl/drivers/dri2/egl_dri2.c @@ -62,6 +62,7 @@ #include "egl_dri2.h" #include "GL/mesa_glinterop.h" #include "loader/loader.h" +#include "util/os_file.h" #include "util/u_atomic.h" #include "util/u_vector.h" #include "mapi/glapi/glapi.h" @@ -85,41 +86,49 @@ #define NUM_ATTRIBS 12 static const struct dri2_pbuffer_visual { + const char *format_name; unsigned int dri_image_format; int rgba_shifts[4]; unsigned int rgba_sizes[4]; } dri2_pbuffer_visuals[] = { { + "ABGR16F", __DRI_IMAGE_FORMAT_ABGR16161616F, { 0, 16, 32, 48 }, { 16, 16, 16, 16 } }, { + "XBGR16F", __DRI_IMAGE_FORMAT_XBGR16161616F, { 0, 16, 32, -1 }, { 16, 16, 16, 0 } }, { + "A2RGB10", __DRI_IMAGE_FORMAT_ARGB2101010, { 20, 10, 0, 30 }, { 10, 10, 10, 2 } }, { + "X2RGB10", __DRI_IMAGE_FORMAT_XRGB2101010, { 20, 10, 0, -1 }, { 10, 10, 10, 0 } }, { + "ARGB8888", __DRI_IMAGE_FORMAT_ARGB8888, { 16, 8, 0, 24 }, { 8, 8, 8, 8 } }, { + "RGB888", __DRI_IMAGE_FORMAT_XRGB8888, { 16, 8, 0, -1 }, { 8, 8, 8, 0 } }, { + "RGB565", __DRI_IMAGE_FORMAT_RGB565, { 11, 5, 0, -1 }, { 5, 6, 5, 0 } @@ -174,11 +183,6 @@ dri_is_thread_safe(void *loaderPrivate) return false; #endif -#ifdef HAVE_WAYLAND_PLATFORM - if (display->Platform == _EGL_PLATFORM_WAYLAND) - return true; -#endif - return true; } @@ -432,15 +436,14 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, switch (attrib) { case __DRI_ATTRIB_RENDER_TYPE: if (value & __DRI_ATTRIB_FLOAT_BIT) - _eglSetConfigKey(&base, EGL_COLOR_COMPONENT_TYPE_EXT, - EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT); + base.ComponentType = EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT; if (value & __DRI_ATTRIB_RGBA_BIT) value = EGL_RGB_BUFFER; else if (value & __DRI_ATTRIB_LUMINANCE_BIT) value = EGL_LUMINANCE_BUFFER; else return NULL; - _eglSetConfigKey(&base, EGL_COLOR_BUFFER_TYPE, value); + base.ColorBufferType = value; break; case __DRI_ATTRIB_CONFIG_CAVEAT: @@ -450,7 +453,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, value = EGL_SLOW_CONFIG; else value = EGL_NONE; - _eglSetConfigKey(&base, EGL_CONFIG_CAVEAT, value); + base.ConfigCaveat = value; break; case __DRI_ATTRIB_BIND_TO_TEXTURE_RGB: @@ -467,7 +470,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, case __DRI_ATTRIB_RED_SIZE: dri_sizes[0] = value; - _eglSetConfigKey(&base, EGL_RED_SIZE, value); + base.RedSize = value; break; case __DRI_ATTRIB_RED_MASK: @@ -480,7 +483,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, case __DRI_ATTRIB_GREEN_SIZE: dri_sizes[1] = value; - _eglSetConfigKey(&base, EGL_GREEN_SIZE, value); + base.GreenSize = value; break; case __DRI_ATTRIB_GREEN_MASK: @@ -493,7 +496,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, case __DRI_ATTRIB_BLUE_SIZE: dri_sizes[2] = value; - _eglSetConfigKey(&base, EGL_BLUE_SIZE, value); + base.BlueSize = value; break; case __DRI_ATTRIB_BLUE_MASK: @@ -506,7 +509,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, case __DRI_ATTRIB_ALPHA_SIZE: dri_sizes[3] = value; - _eglSetConfigKey(&base, EGL_ALPHA_SIZE, value); + base.AlphaSize = value; break; case __DRI_ATTRIB_ALPHA_MASK: @@ -533,12 +536,10 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, break; case __DRI_ATTRIB_MAX_PBUFFER_WIDTH: - _eglSetConfigKey(&base, EGL_MAX_PBUFFER_WIDTH, - _EGL_MAX_PBUFFER_WIDTH); + base.MaxPbufferWidth = _EGL_MAX_PBUFFER_WIDTH; break; case __DRI_ATTRIB_MAX_PBUFFER_HEIGHT: - _eglSetConfigKey(&base, EGL_MAX_PBUFFER_HEIGHT, - _EGL_MAX_PBUFFER_HEIGHT); + base.MaxPbufferHeight = _EGL_MAX_PBUFFER_HEIGHT; break; case __DRI_ATTRIB_MUTABLE_RENDER_BUFFER: if (disp->Extensions.KHR_mutable_render_buffer) @@ -637,6 +638,39 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, return conf; } +EGLBoolean +dri2_add_pbuffer_configs_for_visuals(_EGLDisplay *disp) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + unsigned int format_count[ARRAY_SIZE(dri2_pbuffer_visuals)] = { 0 }; + unsigned int config_count = 0; + + for (unsigned i = 0; dri2_dpy->driver_configs[i] != NULL; i++) { + for (unsigned j = 0; j < ARRAY_SIZE(dri2_pbuffer_visuals); j++) { + struct dri2_egl_config *dri2_conf; + + dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i], + config_count + 1, EGL_PBUFFER_BIT, NULL, + dri2_pbuffer_visuals[j].rgba_shifts, dri2_pbuffer_visuals[j].rgba_sizes); + + if (dri2_conf) { + if (dri2_conf->base.ConfigID == config_count + 1) + config_count++; + format_count[j]++; + } + } + } + + for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) { + if (!format_count[i]) { + _eglLog(_EGL_DEBUG, "No DRI config supports native format %s", + dri2_pbuffer_visuals[i].format_name); + } + } + + return (config_count != 0); +} + __DRIimage * dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data) { @@ -646,7 +680,10 @@ dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data) (void) screen; + mtx_lock(&disp->Mutex); img = _eglLookupImage(image, disp); + mtx_unlock(&disp->Mutex); + if (img == NULL) { _eglError(EGL_BAD_PARAMETER, "dri2_lookup_egl_image"); return NULL; @@ -968,11 +1005,6 @@ dri2_setup_screen(_EGLDisplay *disp) if (dri2_dpy->image->base.version >= 8 && dri2_dpy->image->createImageFromDmaBufs) { disp->Extensions.EXT_image_dma_buf_import = EGL_TRUE; - } - if (dri2_dpy->image->base.version >= 15 && - dri2_dpy->image->createImageFromDmaBufs2 && - dri2_dpy->image->queryDmaBufFormats && - dri2_dpy->image->queryDmaBufModifiers) { disp->Extensions.EXT_image_dma_buf_import_modifiers = EGL_TRUE; } #endif @@ -983,6 +1015,10 @@ dri2_setup_screen(_EGLDisplay *disp) if (dri2_dpy->buffer_damage && dri2_dpy->buffer_damage->set_damage_region) disp->Extensions.KHR_partial_update = EGL_TRUE; + + disp->Extensions.EXT_protected_surface = + dri2_renderer_query_integer(dri2_dpy, + __DRI2_RENDERER_HAS_PROTECTED_CONTENT); } void @@ -1102,13 +1138,13 @@ dri2_setup_extensions(_EGLDisplay *disp) } /** - * Called via eglInitialize(), GLX_drv->API.Initialize(). + * Called via eglInitialize(), drv->Initialize(). * * This must be guaranteed to be called exactly once, even if eglInitialize is * called many times (without a eglTerminate in between). */ static EGLBoolean -dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize(_EGLDisplay *disp) { EGLBoolean ret = EGL_FALSE; struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -1134,22 +1170,23 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp) switch (disp->Platform) { case _EGL_PLATFORM_SURFACELESS: - ret = dri2_initialize_surfaceless(drv, disp); + ret = dri2_initialize_surfaceless(disp); break; case _EGL_PLATFORM_DEVICE: - ret = dri2_initialize_device(drv, disp); + ret = dri2_initialize_device(disp); break; case _EGL_PLATFORM_X11: - ret = dri2_initialize_x11(drv, disp); + case _EGL_PLATFORM_XCB: + ret = dri2_initialize_x11(disp); break; case _EGL_PLATFORM_DRM: - ret = dri2_initialize_drm(drv, disp); + ret = dri2_initialize_drm(disp); break; case _EGL_PLATFORM_WAYLAND: - ret = dri2_initialize_wayland(drv, disp); + ret = dri2_initialize_wayland(disp); break; case _EGL_PLATFORM_ANDROID: - ret = dri2_initialize_android(drv, disp); + ret = dri2_initialize_android(disp); break; default: unreachable("Callers ensure we cannot get here."); @@ -1200,8 +1237,15 @@ dri2_display_destroy(_EGLDisplay *disp) } if (dri2_dpy->fd >= 0) close(dri2_dpy->fd); + + /* Don't dlclose the driver when building with the address sanitizer, so you + * get good symbols from the leak reports. + */ +#if !BUILT_WITH_ASAN || defined(NDEBUG) if (dri2_dpy->driver) dlclose(dri2_dpy->driver); +#endif + free(dri2_dpy->driver_name); #ifdef HAVE_WAYLAND_PLATFORM @@ -1271,16 +1315,16 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf) } /** - * Called via eglTerminate(), drv->API.Terminate(). + * Called via eglTerminate(), drv->Terminate(). * * This must be guaranteed to be called exactly once, even if eglTerminate is * called many times (without a eglInitialize in between). */ static EGLBoolean -dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp) +dri2_terminate(_EGLDisplay *disp) { /* Release all non-current Context/Surfaces. */ - _eglReleaseDisplayResources(drv, disp); + _eglReleaseDisplayResources(disp); dri2_display_release(disp); @@ -1429,10 +1473,10 @@ dri2_fill_context_attribs(struct dri2_egl_context *dri2_ctx, } /** - * Called via eglCreateContext(), drv->API.CreateContext(). + * Called via eglCreateContext(), drv->CreateContext(). */ static _EGLContext * -dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, +dri2_create_context(_EGLDisplay *disp, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) { struct dri2_egl_context *dri2_ctx; @@ -1447,8 +1491,6 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, unsigned num_attribs = NUM_ATTRIBS; uint32_t ctx_attribs[NUM_ATTRIBS]; - (void) drv; - dri2_ctx = malloc(sizeof *dri2_ctx); if (!dri2_ctx) { _eglError(EGL_BAD_ALLOC, "eglCreateContext"); @@ -1604,10 +1646,10 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, } /** - * Called via eglDestroyContext(), drv->API.DestroyContext(). + * Called via eglDestroyContext(), drv->DestroyContext(). */ static EGLBoolean -dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) +dri2_destroy_context(_EGLDisplay *disp, _EGLContext *ctx) { struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -1661,14 +1703,14 @@ dri2_fini_surface(_EGLSurface *surf) } static EGLBoolean -dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri2_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); if (!_eglPutSurface(surf)) return EGL_TRUE; - return dri2_dpy->vtbl->destroy_surface(drv, disp, surf); + return dri2_dpy->vtbl->destroy_surface(disp, surf); } static void @@ -1719,10 +1761,10 @@ dri2_create_drawable(struct dri2_egl_display *dri2_dpy, } /** - * Called via eglMakeCurrent(), drv->API.MakeCurrent(). + * Called via eglMakeCurrent(), drv->MakeCurrent(). */ static EGLBoolean -dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, +dri2_make_current(_EGLDisplay *disp, _EGLSurface *dsurf, _EGLSurface *rsurf, _EGLContext *ctx) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -1734,33 +1776,23 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, _EGLSurface *tmp_dsurf, *tmp_rsurf; __DRIdrawable *ddraw, *rdraw; __DRIcontext *cctx; - EGLBoolean unbind; + EGLint egl_error = EGL_SUCCESS; if (!dri2_dpy) return _eglError(EGL_NOT_INITIALIZED, "eglMakeCurrent"); - /* make new bindings */ - if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf)) { - /* _eglBindContext already sets the EGL error (in _eglCheckMakeCurrent) */ + /* make new bindings, set the EGL error otherwise */ + if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf)) return EGL_FALSE; - } if (old_ctx) { + __DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context; old_disp = old_ctx->Resource.Display; old_dri2_dpy = dri2_egl_display(old_disp); - } - /* flush before context switch */ - if (old_ctx) + /* flush before context switch */ dri2_gl_flush(); - ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL; - rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL; - cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL; - - if (old_ctx) { - __DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context; - if (old_dsurf) dri2_surf_update_fence_fd(old_ctx, disp, old_dsurf); @@ -1773,46 +1805,82 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, dri2_dpy->core->unbindContext(old_cctx); } - unbind = (cctx == NULL && ddraw == NULL && rdraw == NULL); + ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL; + rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL; + cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL; - if (!unbind && !dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) { - /* undo the previous _eglBindContext */ - _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf); - assert(&dri2_ctx->base == ctx && - tmp_dsurf == dsurf && - tmp_rsurf == rsurf); + if (cctx || ddraw || rdraw) { + if (!dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) { + _EGLContext *tmp_ctx; - if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) && - old_dri2_dpy->vtbl->set_shared_buffer_mode) { - old_dri2_dpy->vtbl->set_shared_buffer_mode(old_disp, old_dsurf, true); - } + /* dri2_dpy->core->bindContext failed. We cannot tell for sure why, but + * setting the error to EGL_BAD_MATCH is surely better than leaving it + * as EGL_SUCCESS. + */ + egl_error = EGL_BAD_MATCH; + + /* undo the previous _eglBindContext */ + _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf); + assert(&dri2_ctx->base == ctx && + tmp_dsurf == dsurf && + tmp_rsurf == rsurf); + + _eglPutSurface(dsurf); + _eglPutSurface(rsurf); + _eglPutContext(ctx); + + _eglPutSurface(old_dsurf); + _eglPutSurface(old_rsurf); + _eglPutContext(old_ctx); + + ddraw = (old_dsurf) ? dri2_dpy->vtbl->get_dri_drawable(old_dsurf) : NULL; + rdraw = (old_rsurf) ? dri2_dpy->vtbl->get_dri_drawable(old_rsurf) : NULL; + cctx = (old_ctx) ? dri2_egl_context(old_ctx)->dri_context : NULL; + + /* undo the previous dri2_dpy->core->unbindContext */ + if (dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) { + if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) && + old_dri2_dpy->vtbl->set_shared_buffer_mode) { + old_dri2_dpy->vtbl->set_shared_buffer_mode(old_disp, old_dsurf, true); + } - _eglPutSurface(dsurf); - _eglPutSurface(rsurf); - _eglPutContext(ctx); + return _eglError(egl_error, "eglMakeCurrent"); + } - _eglPutSurface(old_dsurf); - _eglPutSurface(old_rsurf); - _eglPutContext(old_ctx); + /* We cannot restore the same state as it was before calling + * eglMakeCurrent() and the spec isn't clear about what to do. We + * can prevent EGL from calling into the DRI driver with no DRI + * context bound. + */ + dsurf = rsurf = NULL; + ctx = NULL; - /* dri2_dpy->core->bindContext failed. We cannot tell for sure why, but - * setting the error to EGL_BAD_MATCH is surely better than leaving it - * as EGL_SUCCESS. - */ - return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - } + _eglBindContext(ctx, dsurf, rsurf, &tmp_ctx, &tmp_dsurf, &tmp_rsurf); + assert(tmp_ctx == old_ctx && tmp_dsurf == old_dsurf && + tmp_rsurf == old_rsurf); - dri2_destroy_surface(drv, disp, old_dsurf); - dri2_destroy_surface(drv, disp, old_rsurf); + _eglLog(_EGL_WARNING, "DRI2: failed to rebind the previous context"); + } else { + /* dri2_dpy->core->bindContext succeeded, so take a reference on the + * dri2_dpy. This prevents dri2_dpy from being reinitialized when a + * EGLDisplay is terminated and then initialized again while a + * context is still bound. See dri2_intitialize() for a more in depth + * explanation. */ + dri2_dpy->ref_count++; + } + } - if (!unbind) - dri2_dpy->ref_count++; + dri2_destroy_surface(disp, old_dsurf); + dri2_destroy_surface(disp, old_rsurf); if (old_ctx) { - dri2_destroy_context(drv, disp, old_ctx); + dri2_destroy_context(disp, old_ctx); dri2_display_release(old_disp); } + if (egl_error != EGL_SUCCESS) + return _eglError(egl_error, "eglMakeCurrent"); + if (dsurf && _eglSurfaceHasMutableRenderBuffer(dsurf) && dri2_dpy->vtbl->set_shared_buffer_mode) { /* Always update the shared buffer mode. This is obviously needed when @@ -1837,50 +1905,51 @@ dri2_surface_get_dri_drawable(_EGLSurface *surf) } /* - * Called from eglGetProcAddress() via drv->API.GetProcAddress(). + * Called from eglGetProcAddress() via drv->GetProcAddress(). */ static _EGLProc -dri2_get_proc_address(_EGLDriver *drv, const char *procname) +dri2_get_proc_address(const char *procname) { return _glapi_get_proc_address(procname); } static _EGLSurface* -dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +dri2_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->create_window_surface(drv, disp, conf, native_window, + return dri2_dpy->vtbl->create_window_surface(disp, conf, native_window, attrib_list); } static _EGLSurface* -dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_pixmap, - const EGLint *attrib_list) +dri2_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_pixmap, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->create_pixmap_surface(drv, disp, conf, native_pixmap, + if (!dri2_dpy->vtbl->create_pixmap_surface) + return NULL; + return dri2_dpy->vtbl->create_pixmap_surface(disp, conf, native_pixmap, attrib_list); } static _EGLSurface* -dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, const EGLint *attrib_list) +dri2_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf, + const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->create_pbuffer_surface(drv, disp, conf, attrib_list); + if (!dri2_dpy->vtbl->create_pbuffer_surface) + return NULL; + return dri2_dpy->vtbl->create_pbuffer_surface(disp, conf, attrib_list); } static EGLBoolean -dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint interval) +dri2_swap_interval(_EGLDisplay *disp, _EGLSurface *surf, EGLint interval) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); if (!dri2_dpy->vtbl->swap_interval) return EGL_TRUE; - return dri2_dpy->vtbl->swap_interval(drv, disp, surf, interval); + return dri2_dpy->vtbl->swap_interval(disp, surf, interval); } /** @@ -1920,7 +1989,7 @@ dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw) } static EGLBoolean -dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri2_swap_buffers(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); __DRIdrawable *dri_drawable = dri2_dpy->vtbl->get_dri_drawable(surf); @@ -1929,7 +1998,7 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) if (ctx && surf) dri2_surf_update_fence_fd(ctx, disp, surf); - ret = dri2_dpy->vtbl->swap_buffers(drv, disp, surf); + ret = dri2_dpy->vtbl->swap_buffers(disp, surf); /* SwapBuffers marks the end of the frame; reset the damage region for * use again next time. @@ -1942,8 +2011,7 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } static EGLBoolean -dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, +dri2_swap_buffers_with_damage(_EGLDisplay *disp, _EGLSurface *surf, const EGLint *rects, EGLint n_rects) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -1953,8 +2021,11 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *disp, if (ctx && surf) dri2_surf_update_fence_fd(ctx, disp, surf); - ret = dri2_dpy->vtbl->swap_buffers_with_damage(drv, disp, surf, - rects, n_rects); + if (dri2_dpy->vtbl->swap_buffers_with_damage) + ret = dri2_dpy->vtbl->swap_buffers_with_damage(disp, surf, + rects, n_rects); + else + ret = dri2_dpy->vtbl->swap_buffers(disp, surf); /* SwapBuffers marks the end of the frame; reset the damage region for * use again next time. @@ -1967,14 +2038,16 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, +dri2_swap_buffers_region(_EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); __DRIdrawable *dri_drawable = dri2_dpy->vtbl->get_dri_drawable(surf); EGLBoolean ret; - ret = dri2_dpy->vtbl->swap_buffers_region(drv, disp, surf, numRects, rects); + if (!dri2_dpy->vtbl->swap_buffers_region) + return EGL_FALSE; + ret = dri2_dpy->vtbl->swap_buffers_region(disp, surf, numRects, rects); /* SwapBuffers marks the end of the frame; reset the damage region for * use again next time. @@ -1987,7 +2060,7 @@ dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, } static EGLBoolean -dri2_set_damage_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, +dri2_set_damage_region(_EGLDisplay *disp, _EGLSurface *surf, EGLint *rects, EGLint n_rects) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -2001,37 +2074,40 @@ dri2_set_damage_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, } static EGLBoolean -dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, +dri2_post_sub_buffer(_EGLDisplay *disp, _EGLSurface *surf, EGLint x, EGLint y, EGLint width, EGLint height) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->post_sub_buffer(drv, disp, surf, x, y, width, height); + if (!dri2_dpy->vtbl->post_sub_buffer) + return EGL_FALSE; + return dri2_dpy->vtbl->post_sub_buffer(disp, surf, x, y, width, height); } static EGLBoolean -dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - void *native_pixmap_target) +dri2_copy_buffers(_EGLDisplay *disp, _EGLSurface *surf, void *native_pixmap_target) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->copy_buffers(drv, disp, surf, native_pixmap_target); + if (!dri2_dpy->vtbl->copy_buffers) + return _eglError(EGL_BAD_NATIVE_PIXMAP, "no support for native pixmaps"); + return dri2_dpy->vtbl->copy_buffers(disp, surf, native_pixmap_target); } static EGLint -dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri2_query_buffer_age(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->query_buffer_age(drv, disp, surf); + if (!dri2_dpy->vtbl->query_buffer_age) + return 0; + return dri2_dpy->vtbl->query_buffer_age(disp, surf); } static EGLBoolean -dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) +dri2_wait_client(_EGLDisplay *disp, _EGLContext *ctx) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); _EGLSurface *surf = ctx->DrawSurface; __DRIdrawable *dri_drawable = dri2_dpy->vtbl->get_dri_drawable(surf); - (void) drv; - /* FIXME: If EGL allows frontbuffer rendering for window surfaces, * we need to copy fake to real here.*/ @@ -2042,11 +2118,8 @@ dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) } static EGLBoolean -dri2_wait_native(_EGLDriver *drv, _EGLDisplay *disp, EGLint engine) +dri2_wait_native(EGLint engine) { - (void) drv; - (void) disp; - if (engine != EGL_CORE_NATIVE_ENGINE) return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); /* glXWaitX(); */ @@ -2055,8 +2128,7 @@ dri2_wait_native(_EGLDriver *drv, _EGLDisplay *disp, EGLint engine) } static EGLBoolean -dri2_bind_tex_image(_EGLDriver *drv, - _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer) +dri2_bind_tex_image(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_context *dri2_ctx; @@ -2067,7 +2139,7 @@ dri2_bind_tex_image(_EGLDriver *drv, ctx = _eglGetCurrentContext(); dri2_ctx = dri2_egl_context(ctx); - if (!_eglBindTexImage(drv, disp, surf, buffer)) + if (!_eglBindTexImage(disp, surf, buffer)) return EGL_FALSE; switch (surf->TextureFormat) { @@ -2099,8 +2171,7 @@ dri2_bind_tex_image(_EGLDriver *drv, } static EGLBoolean -dri2_release_tex_image(_EGLDriver *drv, - _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer) +dri2_release_tex_image(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_context *dri2_ctx; @@ -2111,7 +2182,7 @@ dri2_release_tex_image(_EGLDriver *drv, ctx = _eglGetCurrentContext(); dri2_ctx = dri2_egl_context(ctx); - if (!_eglReleaseTexImage(drv, disp, surf, buffer)) + if (!_eglReleaseTexImage(disp, surf, buffer)) return EGL_FALSE; switch (surf->TextureTarget) { @@ -2132,16 +2203,15 @@ dri2_release_tex_image(_EGLDriver *drv, } static _EGLImage* -dri2_create_image(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx, - EGLenum target, EGLClientBuffer buffer, - const EGLint *attr_list) +dri2_create_image(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, + EGLClientBuffer buffer, const EGLint *attr_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->create_image(drv, disp, ctx, target, buffer, + return dri2_dpy->vtbl->create_image(disp, ctx, target, buffer, attr_list); } -static _EGLImage * +_EGLImage * dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image) { struct dri2_egl_image *dri2_img; @@ -2298,6 +2368,8 @@ dri2_get_sync_values_chromium(_EGLDisplay *disp, _EGLSurface *surf, EGLuint64KHR *sbc) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + if (!dri2_dpy->vtbl->get_sync_values) + return EGL_FALSE; return dri2_dpy->vtbl->get_sync_values(disp, surf, ust, msc, sbc); } @@ -2389,7 +2461,7 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx, depth, attrs.GLTextureLevel, &error, - dri2_img); + NULL); dri2_create_image_khr_texture_error(error); if (!dri2_img->dri_image) { @@ -2400,21 +2472,22 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx, } static EGLBoolean -dri2_query_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, +dri2_query_surface(_EGLDisplay *disp, _EGLSurface *surf, EGLint attribute, EGLint *value) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); if (!dri2_dpy->vtbl->query_surface) - return _eglQuerySurface(drv, disp, surf, attribute, value); - return dri2_dpy->vtbl->query_surface(drv, disp, surf, attribute, value); + return _eglQuerySurface(disp, surf, attribute, value); + return dri2_dpy->vtbl->query_surface(disp, surf, attribute, value); } static struct wl_buffer* -dri2_create_wayland_buffer_from_image(_EGLDriver *drv, _EGLDisplay *disp, - _EGLImage *img) +dri2_create_wayland_buffer_from_image(_EGLDisplay *disp, _EGLImage *img) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->create_wayland_buffer_from_image(drv, disp, img); + if (!dri2_dpy->vtbl->create_wayland_buffer_from_image) + return NULL; + return dri2_dpy->vtbl->create_wayland_buffer_from_image(disp, img); } #ifdef HAVE_LIBDRM @@ -2678,8 +2751,8 @@ dri2_check_dma_buf_format(const _EGLImageAttribs *attrs) } static EGLBoolean -dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp, - EGLint max, EGLint *formats, EGLint *count) +dri2_query_dma_buf_formats(_EGLDisplay *disp, EGLint max, + EGLint *formats, EGLint *count) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); if (max < 0 || (max > 0 && formats == NULL)) @@ -2709,7 +2782,7 @@ dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint format, +dri2_query_dma_buf_modifiers(_EGLDisplay *disp, EGLint format, EGLint max, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *count) { @@ -2799,7 +2872,28 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, has_modifier = true; } - if (has_modifier) { + if (attrs.ProtectedContent) { + if (dri2_dpy->image->base.version < 18 || + dri2_dpy->image->createImageFromDmaBufs3 == NULL) { + _eglError(EGL_BAD_MATCH, "unsupported protected_content attribute"); + return EGL_NO_IMAGE_KHR; + } + if (!has_modifier) + modifier = DRM_FORMAT_MOD_INVALID; + + dri_image = + dri2_dpy->image->createImageFromDmaBufs3(dri2_dpy->dri_screen, + attrs.Width, attrs.Height, attrs.DMABufFourCC.Value, + modifier, fds, num_fds, pitches, offsets, + attrs.DMABufYuvColorSpaceHint.Value, + attrs.DMABufSampleRangeHint.Value, + attrs.DMABufChromaHorizontalSiting.Value, + attrs.DMABufChromaVerticalSiting.Value, + attrs.ProtectedContent ? __DRI_IMAGE_PROTECTED_CONTENT_FLAG : 0, + &error, + NULL); + } + else if (has_modifier) { if (dri2_dpy->image->base.version < 15 || dri2_dpy->image->createImageFromDmaBufs2 == NULL) { _eglError(EGL_BAD_MATCH, "unsupported dma_buf format modifier"); @@ -2838,8 +2932,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, return res; } static _EGLImage * -dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, - const EGLint *attr_list) +dri2_create_drm_image_mesa(_EGLDisplay *disp, const EGLint *attr_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img; @@ -2847,8 +2940,6 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, unsigned int dri_use, valid_mask; int format; - (void) drv; - if (!attr_list) { _eglError(EGL_BAD_PARAMETER, __func__); return EGL_NO_IMAGE_KHR; @@ -2910,14 +3001,12 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, +dri2_export_drm_image_mesa(_EGLDisplay *disp, _EGLImage *img, EGLint *name, EGLint *handle, EGLint *stride) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img = dri2_egl_image(img); - (void) drv; - if (name && !dri2_dpy->image->queryImage(dri2_img->dri_image, __DRI_IMAGE_ATTRIB_NAME, name)) return _eglError(EGL_BAD_ALLOC, "dri2_export_drm_image_mesa"); @@ -2956,8 +3045,7 @@ dri2_can_export_dma_buf_image(_EGLDisplay *disp, _EGLImage *img) } static EGLBoolean -dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp, - _EGLImage *img, +dri2_export_dma_buf_image_query_mesa(_EGLDisplay *disp, _EGLImage *img, EGLint *fourcc, EGLint *nplanes, EGLuint64KHR *modifiers) { @@ -2965,8 +3053,6 @@ dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp, struct dri2_egl_image *dri2_img = dri2_egl_image(img); int num_planes; - (void) drv; - if (!dri2_can_export_dma_buf_image(disp, img)) return EGL_FALSE; @@ -3001,15 +3087,13 @@ dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, +dri2_export_dma_buf_image_mesa(_EGLDisplay *disp, _EGLImage *img, int *fds, EGLint *strides, EGLint *offsets) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img = dri2_egl_image(img); EGLint nplanes; - (void) drv; - if (!dri2_can_export_dma_buf_image(disp, img)) return EGL_FALSE; @@ -3049,12 +3133,9 @@ dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *im #endif _EGLImage * -dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, +dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list) { - (void) drv; - switch (target) { case EGL_GL_TEXTURE_2D_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR: @@ -3084,13 +3165,11 @@ dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_destroy_image_khr(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *image) +dri2_destroy_image_khr(_EGLDisplay *disp, _EGLImage *image) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img = dri2_egl_image(image); - (void) drv; - dri2_dpy->image->destroyImage(dri2_img->dri_image); free(dri2_img); @@ -3153,8 +3232,7 @@ dri2_wl_release_buffer(void *user_data, struct wl_drm_buffer *buffer) } static EGLBoolean -dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, - struct wl_display *wl_dpy) +dri2_bind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); const struct wayland_drm_callbacks wl_drm_callbacks = { @@ -3164,13 +3242,18 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, .is_format_supported = dri2_wl_is_format_supported }; int flags = 0; + char *device_name; uint64_t cap; - (void) drv; - if (dri2_dpy->wl_server_drm) return EGL_FALSE; + device_name = drmGetRenderDeviceNameFromFd(dri2_dpy->fd); + if (!device_name) + device_name = strdup(dri2_dpy->device_name); + if (!device_name) + return EGL_FALSE; + if (drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap) == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) && dri2_dpy->image->base.version >= 7 && @@ -3178,9 +3261,11 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, flags |= WAYLAND_DRM_PRIME; dri2_dpy->wl_server_drm = - wayland_drm_init(wl_dpy, dri2_dpy->device_name, + wayland_drm_init(wl_dpy, device_name, &wl_drm_callbacks, disp, flags); + free(device_name); + if (!dri2_dpy->wl_server_drm) return EGL_FALSE; @@ -3195,13 +3280,10 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, - struct wl_display *wl_dpy) +dri2_unbind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - (void) drv; - if (!dri2_dpy->wl_server_drm) return EGL_FALSE; @@ -3212,8 +3294,7 @@ dri2_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp, - struct wl_resource *buffer_resource, +dri2_query_wayland_buffer_wl(_EGLDisplay *disp, struct wl_resource *buffer_resource, EGLint attribute, EGLint *value) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3272,8 +3353,7 @@ dri2_egl_unref_sync(struct dri2_egl_display *dri2_dpy, } static _EGLSync * -dri2_create_sync(_EGLDriver *drv, _EGLDisplay *disp, - EGLenum type, const EGLAttrib *attrib_list) +dri2_create_sync(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list) { _EGLContext *ctx = _eglGetCurrentContext(); struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3373,7 +3453,7 @@ dri2_create_sync(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_destroy_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) +dri2_destroy_sync(_EGLDisplay *disp, _EGLSync *sync) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync); @@ -3402,7 +3482,7 @@ dri2_destroy_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) } static EGLint -dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) +dri2_dup_native_fence_fd(_EGLDisplay *disp, _EGLSync *sync) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync); @@ -3423,11 +3503,11 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) return EGL_NO_NATIVE_FENCE_FD_ANDROID; } - return dup(sync->SyncFd); + return os_dupfd_cloexec(sync->SyncFd); } static void -dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *disp, +dri2_set_blob_cache_funcs(_EGLDisplay *disp, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get) { @@ -3438,7 +3518,7 @@ dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *disp, } static EGLint -dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, +dri2_client_wait_sync(_EGLDisplay *disp, _EGLSync *sync, EGLint flags, EGLTime timeout) { _EGLContext *ctx = _eglGetCurrentContext(); @@ -3530,8 +3610,7 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, } static EGLBoolean -dri2_signal_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, - EGLenum mode) +dri2_signal_sync(_EGLDisplay *disp, _EGLSync *sync, EGLenum mode) { struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync); EGLint ret; @@ -3556,7 +3635,7 @@ dri2_signal_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, } static EGLint -dri2_server_wait_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) +dri2_server_wait_sync(_EGLDisplay *disp, _EGLSync *sync) { _EGLContext *ctx = _eglGetCurrentContext(); struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3595,62 +3674,56 @@ dri2_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx, return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out); } -/** - * This is the main entrypoint into the driver, called by libEGL. - * Gets an _EGLDriver object and init its dispatch table. - */ -void -_eglInitDriver(_EGLDriver *dri2_drv) -{ - dri2_drv->API.Initialize = dri2_initialize; - dri2_drv->API.Terminate = dri2_terminate; - dri2_drv->API.CreateContext = dri2_create_context; - dri2_drv->API.DestroyContext = dri2_destroy_context; - dri2_drv->API.MakeCurrent = dri2_make_current; - dri2_drv->API.CreateWindowSurface = dri2_create_window_surface; - dri2_drv->API.CreatePixmapSurface = dri2_create_pixmap_surface; - dri2_drv->API.CreatePbufferSurface = dri2_create_pbuffer_surface; - dri2_drv->API.DestroySurface = dri2_destroy_surface; - dri2_drv->API.GetProcAddress = dri2_get_proc_address; - dri2_drv->API.WaitClient = dri2_wait_client; - dri2_drv->API.WaitNative = dri2_wait_native; - dri2_drv->API.BindTexImage = dri2_bind_tex_image; - dri2_drv->API.ReleaseTexImage = dri2_release_tex_image; - dri2_drv->API.SwapInterval = dri2_swap_interval; - dri2_drv->API.SwapBuffers = dri2_swap_buffers; - dri2_drv->API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage; - dri2_drv->API.SwapBuffersRegionNOK = dri2_swap_buffers_region; - dri2_drv->API.SetDamageRegion = dri2_set_damage_region; - dri2_drv->API.PostSubBufferNV = dri2_post_sub_buffer; - dri2_drv->API.CopyBuffers = dri2_copy_buffers, - dri2_drv->API.QueryBufferAge = dri2_query_buffer_age; - dri2_drv->API.CreateImageKHR = dri2_create_image; - dri2_drv->API.DestroyImageKHR = dri2_destroy_image_khr; - dri2_drv->API.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image; - dri2_drv->API.QuerySurface = dri2_query_surface; - dri2_drv->API.QueryDriverName = dri2_query_driver_name; - dri2_drv->API.QueryDriverConfig = dri2_query_driver_config; +const _EGLDriver _eglDriver = { + .Initialize = dri2_initialize, + .Terminate = dri2_terminate, + .CreateContext = dri2_create_context, + .DestroyContext = dri2_destroy_context, + .MakeCurrent = dri2_make_current, + .CreateWindowSurface = dri2_create_window_surface, + .CreatePixmapSurface = dri2_create_pixmap_surface, + .CreatePbufferSurface = dri2_create_pbuffer_surface, + .DestroySurface = dri2_destroy_surface, + .GetProcAddress = dri2_get_proc_address, + .WaitClient = dri2_wait_client, + .WaitNative = dri2_wait_native, + .BindTexImage = dri2_bind_tex_image, + .ReleaseTexImage = dri2_release_tex_image, + .SwapInterval = dri2_swap_interval, + .SwapBuffers = dri2_swap_buffers, + .SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage, + .SwapBuffersRegionNOK = dri2_swap_buffers_region, + .SetDamageRegion = dri2_set_damage_region, + .PostSubBufferNV = dri2_post_sub_buffer, + .CopyBuffers = dri2_copy_buffers, + .QueryBufferAge = dri2_query_buffer_age, + .CreateImageKHR = dri2_create_image, + .DestroyImageKHR = dri2_destroy_image_khr, + .CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image, + .QuerySurface = dri2_query_surface, + .QueryDriverName = dri2_query_driver_name, + .QueryDriverConfig = dri2_query_driver_config, #ifdef HAVE_LIBDRM - dri2_drv->API.CreateDRMImageMESA = dri2_create_drm_image_mesa; - dri2_drv->API.ExportDRMImageMESA = dri2_export_drm_image_mesa; - dri2_drv->API.ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa; - dri2_drv->API.ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa; - dri2_drv->API.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats; - dri2_drv->API.QueryDmaBufModifiersEXT = dri2_query_dma_buf_modifiers; + .CreateDRMImageMESA = dri2_create_drm_image_mesa, + .ExportDRMImageMESA = dri2_export_drm_image_mesa, + .ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa, + .ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa, + .QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats, + .QueryDmaBufModifiersEXT = dri2_query_dma_buf_modifiers, #endif #ifdef HAVE_WAYLAND_PLATFORM - dri2_drv->API.BindWaylandDisplayWL = dri2_bind_wayland_display_wl; - dri2_drv->API.UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl; - dri2_drv->API.QueryWaylandBufferWL = dri2_query_wayland_buffer_wl; + .BindWaylandDisplayWL = dri2_bind_wayland_display_wl, + .UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl, + .QueryWaylandBufferWL = dri2_query_wayland_buffer_wl, #endif - dri2_drv->API.GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium; - dri2_drv->API.CreateSyncKHR = dri2_create_sync; - dri2_drv->API.ClientWaitSyncKHR = dri2_client_wait_sync; - dri2_drv->API.SignalSyncKHR = dri2_signal_sync; - dri2_drv->API.WaitSyncKHR = dri2_server_wait_sync; - dri2_drv->API.DestroySyncKHR = dri2_destroy_sync; - dri2_drv->API.GLInteropQueryDeviceInfo = dri2_interop_query_device_info; - dri2_drv->API.GLInteropExportObject = dri2_interop_export_object; - dri2_drv->API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd; - dri2_drv->API.SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs; -} + .GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium, + .CreateSyncKHR = dri2_create_sync, + .ClientWaitSyncKHR = dri2_client_wait_sync, + .SignalSyncKHR = dri2_signal_sync, + .WaitSyncKHR = dri2_server_wait_sync, + .DestroySyncKHR = dri2_destroy_sync, + .GLInteropQueryDeviceInfo = dri2_interop_query_device_info, + .GLInteropExportObject = dri2_interop_export_object, + .DupNativeFenceFDANDROID = dri2_dup_native_fence_fd, + .SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs, +}; diff --git a/lib/mesa/src/egl/drivers/dri2/egl_dri2.h b/lib/mesa/src/egl/drivers/dri2/egl_dri2.h index 96cf04d89..d7f9696da 100644 --- a/lib/mesa/src/egl/drivers/dri2/egl_dri2.h +++ b/lib/mesa/src/egl/drivers/dri2/egl_dri2.h @@ -88,72 +88,80 @@ struct zwp_linux_dmabuf_v1; struct wl_buffer; struct dri2_egl_display_vtbl { + /* mandatory on Wayland, unused otherwise */ int (*authenticate)(_EGLDisplay *disp, uint32_t id); - _EGLSurface* (*create_window_surface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *config, + /* mandatory */ + _EGLSurface* (*create_window_surface)(_EGLDisplay *disp, _EGLConfig *config, void *native_window, const EGLint *attrib_list); - _EGLSurface* (*create_pixmap_surface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *config, + /* optional */ + _EGLSurface* (*create_pixmap_surface)(_EGLDisplay *disp, _EGLConfig *config, void *native_pixmap, const EGLint *attrib_list); - _EGLSurface* (*create_pbuffer_surface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *config, + /* optional */ + _EGLSurface* (*create_pbuffer_surface)(_EGLDisplay *disp, _EGLConfig *config, const EGLint *attrib_list); - EGLBoolean (*destroy_surface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface); + /* mandatory */ + EGLBoolean (*destroy_surface)(_EGLDisplay *disp, _EGLSurface *surface); - EGLBoolean (*swap_interval)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint interval); + /* optional */ + EGLBoolean (*swap_interval)(_EGLDisplay *disp, _EGLSurface *surf, + EGLint interval); - _EGLImage* (*create_image)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, - EGLClientBuffer buffer, + /* mandatory */ + _EGLImage* (*create_image)(_EGLDisplay *disp, _EGLContext *ctx, + EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list); - EGLBoolean (*swap_buffers)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf); + /* mandatory */ + EGLBoolean (*swap_buffers)(_EGLDisplay *disp, _EGLSurface *surf); - EGLBoolean (*swap_buffers_with_damage)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, + /* optional - falls back to .swap_buffers */ + EGLBoolean (*swap_buffers_with_damage)(_EGLDisplay *disp, _EGLSurface *surface, const EGLint *rects, EGLint n_rects); - EGLBoolean (*swap_buffers_region)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint numRects, - const EGLint *rects); + /* optional */ + EGLBoolean (*swap_buffers_region)(_EGLDisplay *disp, _EGLSurface *surf, + EGLint numRects, const EGLint *rects); - EGLBoolean (*post_sub_buffer)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, + /* optional */ + EGLBoolean (*post_sub_buffer)(_EGLDisplay *disp, _EGLSurface *surf, EGLint x, EGLint y, EGLint width, EGLint height); - EGLBoolean (*copy_buffers)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, void *native_pixmap_target); + /* optional */ + EGLBoolean (*copy_buffers)(_EGLDisplay *disp, _EGLSurface *surf, + void *native_pixmap_target); - EGLint (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf); + /* optional */ + EGLint (*query_buffer_age)(_EGLDisplay *disp, _EGLSurface *surf); - EGLBoolean (*query_surface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint attribute, - EGLint *value); + /* optional */ + EGLBoolean (*query_surface)(_EGLDisplay *disp, _EGLSurface *surf, + EGLint attribute, EGLint *value); - struct wl_buffer* (*create_wayland_buffer_from_image)( - _EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img); + /* optional */ + struct wl_buffer* (*create_wayland_buffer_from_image)(_EGLDisplay *disp, + _EGLImage *img); + /* optional */ EGLBoolean (*get_sync_values)(_EGLDisplay *display, _EGLSurface *surface, EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc); + /* mandatory */ __DRIdrawable *(*get_dri_drawable)(_EGLSurface *surf); + /* optional */ void (*close_screen_notify)(_EGLDisplay *disp); /* Used in EGL_KHR_mutable_render_buffer to update the native window's * shared buffer mode. + * optional */ bool (*set_shared_buffer_mode)(_EGLDisplay *disp, _EGLSurface *surf, bool mode); @@ -363,7 +371,7 @@ struct dri2_egl_sync { void *fence; }; -/* From xmlpool/options.h, user exposed so should be stable */ +/* From driconf.h, user exposed so should be stable */ #define DRI_CONF_VBLANK_NEVER 0 #define DRI_CONF_VBLANK_DEF_INTERVAL_0 1 #define DRI_CONF_VBLANK_DEF_INTERVAL_1 2 @@ -426,25 +434,30 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, EGLint surface_type, const EGLint *attr_list, const int *rgba_shifts, const unsigned int *rgba_sizes); +EGLBoolean +dri2_add_pbuffer_configs_for_visuals(_EGLDisplay *disp); + _EGLImage * -dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, +dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list); _EGLImage * dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, EGLClientBuffer buffer, const EGLint *attr_list); +_EGLImage * +dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image); + #ifdef HAVE_X11_PLATFORM EGLBoolean -dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp); +dri2_initialize_x11(_EGLDisplay *disp); void dri2_teardown_x11(struct dri2_egl_display *dri2_dpy); unsigned int dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth); #else static inline EGLBoolean -dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_x11(_EGLDisplay *disp) { return _eglError(EGL_NOT_INITIALIZED, "X11 platform not built"); } @@ -459,12 +472,12 @@ dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth) #ifdef HAVE_DRM_PLATFORM EGLBoolean -dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp); +dri2_initialize_drm(_EGLDisplay *disp); void dri2_teardown_drm(struct dri2_egl_display *dri2_dpy); #else static inline EGLBoolean -dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_drm(_EGLDisplay *disp) { return _eglError(EGL_NOT_INITIALIZED, "GBM/DRM platform not built"); } @@ -474,14 +487,14 @@ dri2_teardown_drm(struct dri2_egl_display *dri2_dpy) {} #ifdef HAVE_WAYLAND_PLATFORM EGLBoolean -dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp); +dri2_initialize_wayland(_EGLDisplay *disp); void dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy); bool dri2_wl_is_format_supported(void* user_data, uint32_t format); #else static inline EGLBoolean -dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_wayland(_EGLDisplay *disp) { return _eglError(EGL_NOT_INITIALIZED, "Wayland platform not built"); } @@ -491,28 +504,20 @@ dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy) {} #ifdef HAVE_ANDROID_PLATFORM EGLBoolean -dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp); +dri2_initialize_android(_EGLDisplay *disp); #else static inline EGLBoolean -dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_android(_EGLDisplay *disp) { return _eglError(EGL_NOT_INITIALIZED, "Android platform not built"); } #endif -#ifdef HAVE_SURFACELESS_PLATFORM EGLBoolean -dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp); -#else -static inline EGLBoolean -dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp) -{ - return _eglError(EGL_NOT_INITIALIZED, "Surfaceless platform not built"); -} -#endif +dri2_initialize_surfaceless(_EGLDisplay *disp); EGLBoolean -dri2_initialize_device(_EGLDriver *drv, _EGLDisplay *disp); +dri2_initialize_device(_EGLDisplay *disp); static inline void dri2_teardown_device(struct dri2_egl_display *dri2_dpy) { /* noop */ } @@ -524,13 +529,11 @@ dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type, EGLenum colorspace); static inline void -dri2_set_WL_bind_wayland_display(_EGLDriver *drv, _EGLDisplay *disp) +dri2_set_WL_bind_wayland_display(_EGLDisplay *disp) { #ifdef HAVE_WAYLAND_PLATFORM struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - (void) drv; - if (dri2_dpy->device_name && dri2_dpy->image) { if (dri2_dpy->image->base.version >= 10 && dri2_dpy->image->getCapabilities != NULL) { diff --git a/lib/mesa/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/lib/mesa/src/egl/drivers/dri2/egl_dri2_fallbacks.h deleted file mode 100644 index d975b7a8b..000000000 --- a/lib/mesa/src/egl/drivers/dri2/egl_dri2_fallbacks.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2014 Intel Corporation - * - * 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, sublicense, - * 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 EGL_DRI2_FALLBACKS_INCLUDED -#define EGL_DRI2_FALLBACKS_INCLUDED - -#include "eglcurrent.h" -#include "egltypedefs.h" - -struct wl_buffer; - -static inline _EGLSurface * -dri2_fallback_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, - void *native_pixmap, - const EGLint *attrib_list) -{ - return NULL; -} - -static inline _EGLSurface * -dri2_fallback_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, - const EGLint *attrib_list) -{ - return NULL; -} - -static inline _EGLImage* -dri2_fallback_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, - EGLClientBuffer buffer, - const EGLint *attr_list) -{ - return NULL; -} - -static inline EGLBoolean -dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, - const EGLint *rects, EGLint n_rects) -{ - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return dri2_dpy->vtbl->swap_buffers(drv, disp, surf); -} - -static inline EGLBoolean -dri2_fallback_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, - EGLint numRects, const EGLint *rects) -{ - return EGL_FALSE; -} - -static inline EGLBoolean -dri2_fallback_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *draw, - EGLint x, EGLint y, EGLint width, EGLint height) -{ - return EGL_FALSE; -} - -static inline EGLBoolean -dri2_fallback_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, - void *native_pixmap_target) -{ - return _eglError(EGL_BAD_NATIVE_PIXMAP, "no support for native pixmaps"); -} - -static inline EGLint -dri2_fallback_query_buffer_age(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf) -{ - return 0; -} - -static inline struct wl_buffer* -dri2_fallback_create_wayland_buffer_from_image(_EGLDriver *drv, - _EGLDisplay *disp, - _EGLImage *img) -{ - return NULL; -} - -static inline EGLBoolean -dri2_fallback_get_sync_values(_EGLDisplay *disp, _EGLSurface *surf, - EGLuint64KHR *ust, EGLuint64KHR *msc, - EGLuint64KHR *sbc) -{ - return EGL_FALSE; -} - -#endif /* EGL_DRI2_FALLBACKS_INCLUDED */ diff --git a/lib/mesa/src/egl/drivers/dri2/platform_android.c b/lib/mesa/src/egl/drivers/dri2/platform_android.c index da90c44d6..1fb3166dc 100644 --- a/lib/mesa/src/egl/drivers/dri2/platform_android.c +++ b/lib/mesa/src/egl/drivers/dri2/platform_android.c @@ -39,9 +39,10 @@ #include <sys/types.h> #include <drm-uapi/drm_fourcc.h> +#include "util/os_file.h" + #include "loader.h" #include "egl_dri2.h" -#include "egl_dri2_fallbacks.h" #ifdef HAVE_DRM_GRALLOC #include <gralloc_drm_handle.h> @@ -156,26 +157,6 @@ static int get_fourcc(int native) return -1; } -static int get_format(int format) -{ - switch (format) { - case HAL_PIXEL_FORMAT_BGRA_8888: return __DRI_IMAGE_FORMAT_ARGB8888; - case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FORMAT_RGB565; - case HAL_PIXEL_FORMAT_RGBA_8888: return __DRI_IMAGE_FORMAT_ABGR8888; - case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: - /* - * HACK: Hardcode this to RGBX_8888 as per cros_gralloc hack. - * TODO: Revert this once https://issuetracker.google.com/32077885 is fixed. - */ - case HAL_PIXEL_FORMAT_RGBX_8888: return __DRI_IMAGE_FORMAT_XBGR8888; - case HAL_PIXEL_FORMAT_RGBA_FP16: return __DRI_IMAGE_FORMAT_ABGR16161616F; - case HAL_PIXEL_FORMAT_RGBA_1010102: return __DRI_IMAGE_FORMAT_ABGR2101010; - default: - _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", format); - } - return -1; -} - /* returns # of fds, and by reference the actual fds */ static unsigned get_native_buffer_fds(struct ANativeWindowBuffer *buf, int fds[3]) @@ -204,6 +185,222 @@ get_native_buffer_name(struct ANativeWindowBuffer *buf) } #endif /* HAVE_DRM_GRALLOC */ +static __DRIimage * +droid_create_image_from_prime_fds_yuv(_EGLDisplay *disp, + struct ANativeWindowBuffer *buf, + void *priv, + int num_fds, int fds[3]) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct android_ycbcr ycbcr; + int offsets[3]; + int pitches[3]; + enum chroma_order chroma_order; + int fourcc; + int ret; + unsigned error; + + if (!dri2_dpy->gralloc->lock_ycbcr) { + _eglLog(_EGL_WARNING, "Gralloc does not support lock_ycbcr"); + return NULL; + } + + memset(&ycbcr, 0, sizeof(ycbcr)); + ret = dri2_dpy->gralloc->lock_ycbcr(dri2_dpy->gralloc, buf->handle, + 0, 0, 0, 0, 0, &ycbcr); + if (ret) { + /* HACK: See droid_create_image_from_prime_fds() and + * https://issuetracker.google.com/32077885.*/ + if (buf->format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) + return NULL; + + _eglLog(_EGL_WARNING, "gralloc->lock_ycbcr failed: %d", ret); + return NULL; + } + dri2_dpy->gralloc->unlock(dri2_dpy->gralloc, buf->handle); + + /* When lock_ycbcr's usage argument contains no SW_READ/WRITE flags + * it will return the .y/.cb/.cr pointers based on a NULL pointer, + * so they can be interpreted as offsets. */ + offsets[0] = (size_t)ycbcr.y; + /* We assume here that all the planes are located in one DMA-buf. */ + if ((size_t)ycbcr.cr < (size_t)ycbcr.cb) { + chroma_order = YCrCb; + offsets[1] = (size_t)ycbcr.cr; + offsets[2] = (size_t)ycbcr.cb; + } else { + chroma_order = YCbCr; + offsets[1] = (size_t)ycbcr.cb; + offsets[2] = (size_t)ycbcr.cr; + } + + /* .ystride is the line length (in bytes) of the Y plane, + * .cstride is the line length (in bytes) of any of the remaining + * Cb/Cr/CbCr planes, assumed to be the same for Cb and Cr for fully + * planar formats. */ + pitches[0] = ycbcr.ystride; + pitches[1] = pitches[2] = ycbcr.cstride; + + /* .chroma_step is the byte distance between the same chroma channel + * values of subsequent pixels, assumed to be the same for Cb and Cr. */ + fourcc = get_fourcc_yuv(buf->format, chroma_order, ycbcr.chroma_step); + if (fourcc == -1) { + _eglLog(_EGL_WARNING, "unsupported YUV format, native = %x, chroma_order = %s, chroma_step = %d", + buf->format, chroma_order == YCbCr ? "YCbCr" : "YCrCb", ycbcr.chroma_step); + return NULL; + } + + /* + * Since this is EGL_NATIVE_BUFFER_ANDROID don't assume that + * the single-fd case cannot happen. So handle eithe single + * fd or fd-per-plane case: + */ + int num_planes = (ycbcr.chroma_step == 2) ? 2 : 3; + if (num_fds == 1) { + fds[2] = fds[1] = fds[0]; + } else { + assert(num_fds == num_planes); + } + + return dri2_dpy->image->createImageFromDmaBufs(dri2_dpy->dri_screen, + buf->width, buf->height, fourcc, + fds, num_planes, pitches, offsets, + EGL_ITU_REC601_EXT, + EGL_YUV_NARROW_RANGE_EXT, + EGL_YUV_CHROMA_SITING_0_EXT, + EGL_YUV_CHROMA_SITING_0_EXT, + &error, + priv); +} + +static __DRIimage * +droid_create_image_from_prime_fds(_EGLDisplay *disp, + struct ANativeWindowBuffer *buf, + void *priv) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + int pitches[4] = { 0 }, offsets[4] = { 0 }; + unsigned error; + int num_fds; + int fds[3]; + + num_fds = get_native_buffer_fds(buf, fds); + if (num_fds == 0) + return NULL; + + if (is_yuv(buf->format)) { + __DRIimage *image; + + image = droid_create_image_from_prime_fds_yuv( + disp, buf, priv, num_fds, fds); + /* + * HACK: https://issuetracker.google.com/32077885 + * There is no API available to properly query the IMPLEMENTATION_DEFINED + * format. As a workaround we rely here on gralloc allocating either + * an arbitrary YCbCr 4:2:0 or RGBX_8888, with the latter being recognized + * by lock_ycbcr failing. + */ + if (image || buf->format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) + return image; + } + + /* + * Non-YUV formats could *also* have multiple planes, such as ancillary + * color compression state buffer, but the rest of the code isn't ready + * yet to deal with modifiers: + */ + assert(num_fds == 1); + + const int fourcc = get_fourcc(buf->format); + if (fourcc == -1) { + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); + return NULL; + } + + pitches[0] = buf->stride * get_format_bpp(buf->format); + if (pitches[0] == 0) { + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); + return NULL; + } + + return dri2_dpy->image->createImageFromDmaBufs(dri2_dpy->dri_screen, + buf->width, buf->height, fourcc, + fds, num_fds, pitches, offsets, + EGL_ITU_REC601_EXT, + EGL_YUV_NARROW_RANGE_EXT, + EGL_YUV_CHROMA_SITING_0_EXT, + EGL_YUV_CHROMA_SITING_0_EXT, + &error, + priv); +} + +/* More recent CrOS gralloc has a perform op that fills out the struct below + * with canonical information about the buffer and its modifier, planes, + * offsets and strides. If we have this, we can skip straight to + * createImageFromDmaBufs2() and avoid all the guessing and recalculations. + * This also gives us the modifier and plane offsets/strides for multiplanar + * compressed buffers (eg Intel CCS buffers) in order to make that work in Android. + */ + +static const char cros_gralloc_module_name[] = "CrOS Gralloc"; + +#define CROS_GRALLOC_DRM_GET_BUFFER_INFO 4 + +struct cros_gralloc0_buffer_info { + uint32_t drm_fourcc; + int num_fds; + int fds[4]; + uint64_t modifier; + int offset[4]; + int stride[4]; +}; + +static __DRIimage * +droid_create_image_from_cros_info(_EGLDisplay *disp, + struct ANativeWindowBuffer *buf, + void* priv) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct cros_gralloc0_buffer_info info; + unsigned error; + + if (strcmp(dri2_dpy->gralloc->common.name, cros_gralloc_module_name) == 0 && + dri2_dpy->gralloc->perform && + dri2_dpy->image->base.version >= 15 && + dri2_dpy->image->createImageFromDmaBufs2 != NULL && + dri2_dpy->gralloc->perform(dri2_dpy->gralloc, + CROS_GRALLOC_DRM_GET_BUFFER_INFO, + buf->handle, &info) == 0) { + return dri2_dpy->image->createImageFromDmaBufs2(dri2_dpy->dri_screen, + buf->width, buf->height, + info.drm_fourcc, info.modifier, + info.fds, info.num_fds, + info.stride, info.offset, + EGL_ITU_REC601_EXT, + EGL_YUV_FULL_RANGE_EXT, + EGL_YUV_CHROMA_SITING_0_EXT, + EGL_YUV_CHROMA_SITING_0_EXT, + &error, + priv); + } + + return NULL; +} + +static __DRIimage * +droid_create_image_from_native_buffer(_EGLDisplay *disp, + struct ANativeWindowBuffer *buf, + void *priv) +{ + __DRIimage *dri_image; + + dri_image = droid_create_image_from_cros_info(disp, buf, priv); + if (dri_image) + return dri_image; + + return droid_create_image_from_prime_fds(disp, buf, priv); +} + static EGLBoolean droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf) { @@ -329,7 +526,6 @@ static bool droid_set_shared_buffer_mode(_EGLDisplay *disp, _EGLSurface *surf, bool mode) { #if ANDROID_API_LEVEL >= 24 - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); struct ANativeWindow *window = dri2_surf->window; @@ -352,9 +548,8 @@ droid_set_shared_buffer_mode(_EGLDisplay *disp, _EGLSurface *surf, bool mode) } static _EGLSurface * -droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); @@ -432,6 +627,11 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, window->query(window, NATIVE_WINDOW_WIDTH, &dri2_surf->base.Width); window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height); + + uint32_t usage = strcmp(dri2_dpy->driver_name, "kms_swrast") == 0 + ? GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN + : GRALLOC_USAGE_HW_RENDER; + native_window_set_usage(window, usage); } config = dri2_get_dri_config(dri2_conf, type, @@ -460,24 +660,23 @@ cleanup_surface: } static _EGLSurface * -droid_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +droid_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { - return droid_create_surface(drv, disp, EGL_WINDOW_BIT, conf, + return droid_create_surface(disp, EGL_WINDOW_BIT, conf, native_window, attrib_list); } static _EGLSurface * -droid_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, const EGLint *attrib_list) +droid_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf, + const EGLint *attrib_list) { - return droid_create_surface(drv, disp, EGL_PBUFFER_BIT, conf, - NULL, attrib_list); + return droid_create_surface(disp, EGL_PBUFFER_BIT, conf, + NULL, attrib_list); } static EGLBoolean -droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +droid_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); @@ -513,8 +712,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } static EGLBoolean -droid_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint interval) +droid_swap_interval(_EGLDisplay *disp, _EGLSurface *surf, EGLint interval) { struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); struct ANativeWindow *window = dri2_surf->window; @@ -576,7 +774,7 @@ get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format) dri2_surf->base.Height, format, 0, - dri2_surf); + NULL); if (!dri2_surf->dri_image_front) { _eglLog(_EGL_WARNING, "dri2_image_front allocation failed"); return -1; @@ -589,11 +787,7 @@ get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format) static int get_back_bo(struct dri2_egl_surface *dri2_surf) { - struct dri2_egl_display *dri2_dpy = - dri2_egl_display(dri2_surf->base.Resource.Display); - int fourcc, pitch; - int offset = 0, fds[3]; - unsigned num_fds; + _EGLDisplay *disp = dri2_surf->base.Resource.Display; if (dri2_surf->dri_image_back) return 0; @@ -604,33 +798,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) return -1; } - num_fds = get_native_buffer_fds(dri2_surf->buffer, fds); - if (num_fds == 0) { - _eglLog(_EGL_WARNING, "Could not get native buffer FD"); - return -1; - } - - fourcc = get_fourcc(dri2_surf->buffer->format); - - pitch = dri2_surf->buffer->stride * - get_format_bpp(dri2_surf->buffer->format); - - if (fourcc == -1 || pitch == 0) { - _eglLog(_EGL_WARNING, "Invalid buffer fourcc(%x) or pitch(%d)", - fourcc, pitch); - return -1; - } - dri2_surf->dri_image_back = - dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen, - dri2_surf->base.Width, - dri2_surf->base.Height, - fourcc, - fds, - num_fds, - &pitch, - &offset, - dri2_surf); + droid_create_image_from_native_buffer(disp, dri2_surf->buffer, NULL); if (!dri2_surf->dri_image_back) { _eglLog(_EGL_WARNING, "failed to create DRI image from FD"); return -1; @@ -716,8 +885,7 @@ droid_image_get_buffers(__DRIdrawable *driDrawable, } static EGLint -droid_query_buffer_age(_EGLDriver *drv, - _EGLDisplay *disp, _EGLSurface *surface) +droid_query_buffer_age(_EGLDisplay *disp, _EGLSurface *surface) { struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface); @@ -730,7 +898,7 @@ droid_query_buffer_age(_EGLDriver *drv, } static EGLBoolean -droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +droid_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); @@ -788,179 +956,33 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) return EGL_TRUE; } -static _EGLImage * -droid_create_image_from_prime_fds_yuv(_EGLDisplay *disp, _EGLContext *ctx, - struct ANativeWindowBuffer *buf, - int num_fds, int fds[3]) -{ - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - struct android_ycbcr ycbcr; - size_t offsets[3]; - size_t pitches[3]; - enum chroma_order chroma_order; - int fourcc; - int ret; - - if (!dri2_dpy->gralloc->lock_ycbcr) { - _eglLog(_EGL_WARNING, "Gralloc does not support lock_ycbcr"); - return NULL; - } - - memset(&ycbcr, 0, sizeof(ycbcr)); - ret = dri2_dpy->gralloc->lock_ycbcr(dri2_dpy->gralloc, buf->handle, - 0, 0, 0, 0, 0, &ycbcr); - if (ret) { - /* HACK: See droid_create_image_from_prime_fds() and - * https://issuetracker.google.com/32077885.*/ - if (buf->format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) - return NULL; - - _eglLog(_EGL_WARNING, "gralloc->lock_ycbcr failed: %d", ret); - return NULL; - } - dri2_dpy->gralloc->unlock(dri2_dpy->gralloc, buf->handle); - - /* When lock_ycbcr's usage argument contains no SW_READ/WRITE flags - * it will return the .y/.cb/.cr pointers based on a NULL pointer, - * so they can be interpreted as offsets. */ - offsets[0] = (size_t)ycbcr.y; - /* We assume here that all the planes are located in one DMA-buf. */ - if ((size_t)ycbcr.cr < (size_t)ycbcr.cb) { - chroma_order = YCrCb; - offsets[1] = (size_t)ycbcr.cr; - offsets[2] = (size_t)ycbcr.cb; - } else { - chroma_order = YCbCr; - offsets[1] = (size_t)ycbcr.cb; - offsets[2] = (size_t)ycbcr.cr; - } - - /* .ystride is the line length (in bytes) of the Y plane, - * .cstride is the line length (in bytes) of any of the remaining - * Cb/Cr/CbCr planes, assumed to be the same for Cb and Cr for fully - * planar formats. */ - pitches[0] = ycbcr.ystride; - pitches[1] = pitches[2] = ycbcr.cstride; - - /* .chroma_step is the byte distance between the same chroma channel - * values of subsequent pixels, assumed to be the same for Cb and Cr. */ - fourcc = get_fourcc_yuv(buf->format, chroma_order, ycbcr.chroma_step); - if (fourcc == -1) { - _eglLog(_EGL_WARNING, "unsupported YUV format, native = %x, chroma_order = %s, chroma_step = %d", - buf->format, chroma_order == YCbCr ? "YCbCr" : "YCrCb", ycbcr.chroma_step); - return NULL; - } - - /* - * Since this is EGL_NATIVE_BUFFER_ANDROID don't assume that - * the single-fd case cannot happen. So handle eithe single - * fd or fd-per-plane case: - */ - if (num_fds == 1) { - fds[2] = fds[1] = fds[0]; - } else { - int expected_planes = (ycbcr.chroma_step == 2) ? 2 : 3; - assert(num_fds == expected_planes); - } - - if (ycbcr.chroma_step == 2) { - /* Semi-planar Y + CbCr or Y + CrCb format. */ - const EGLint attr_list_2plane[] = { - EGL_WIDTH, buf->width, - EGL_HEIGHT, buf->height, - EGL_LINUX_DRM_FOURCC_EXT, fourcc, - EGL_DMA_BUF_PLANE0_FD_EXT, fds[0], - EGL_DMA_BUF_PLANE0_PITCH_EXT, pitches[0], - EGL_DMA_BUF_PLANE0_OFFSET_EXT, offsets[0], - EGL_DMA_BUF_PLANE1_FD_EXT, fds[1], - EGL_DMA_BUF_PLANE1_PITCH_EXT, pitches[1], - EGL_DMA_BUF_PLANE1_OFFSET_EXT, offsets[1], - EGL_NONE, 0 - }; - - return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list_2plane); - } else { - /* Fully planar Y + Cb + Cr or Y + Cr + Cb format. */ - const EGLint attr_list_3plane[] = { - EGL_WIDTH, buf->width, - EGL_HEIGHT, buf->height, - EGL_LINUX_DRM_FOURCC_EXT, fourcc, - EGL_DMA_BUF_PLANE0_FD_EXT, fds[0], - EGL_DMA_BUF_PLANE0_PITCH_EXT, pitches[0], - EGL_DMA_BUF_PLANE0_OFFSET_EXT, offsets[0], - EGL_DMA_BUF_PLANE1_FD_EXT, fds[1], - EGL_DMA_BUF_PLANE1_PITCH_EXT, pitches[1], - EGL_DMA_BUF_PLANE1_OFFSET_EXT, offsets[1], - EGL_DMA_BUF_PLANE2_FD_EXT, fds[2], - EGL_DMA_BUF_PLANE2_PITCH_EXT, pitches[2], - EGL_DMA_BUF_PLANE2_OFFSET_EXT, offsets[2], - EGL_NONE, 0 - }; - - return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list_3plane); - } -} - -static _EGLImage * -droid_create_image_from_prime_fds(_EGLDisplay *disp, _EGLContext *ctx, - struct ANativeWindowBuffer *buf, int num_fds, int fds[3]) +#ifdef HAVE_DRM_GRALLOC +static int get_format(int format) { - unsigned int pitch; - - if (is_yuv(buf->format)) { - _EGLImage *image; - - image = droid_create_image_from_prime_fds_yuv(disp, ctx, buf, num_fds, fds); + switch (format) { + case HAL_PIXEL_FORMAT_BGRA_8888: return __DRI_IMAGE_FORMAT_ARGB8888; + case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FORMAT_RGB565; + case HAL_PIXEL_FORMAT_RGBA_8888: return __DRI_IMAGE_FORMAT_ABGR8888; + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: /* - * HACK: https://issuetracker.google.com/32077885 - * There is no API available to properly query the IMPLEMENTATION_DEFINED - * format. As a workaround we rely here on gralloc allocating either - * an arbitrary YCbCr 4:2:0 or RGBX_8888, with the latter being recognized - * by lock_ycbcr failing. + * HACK: Hardcode this to RGBX_8888 as per cros_gralloc hack. + * TODO: Revert this once https://issuetracker.google.com/32077885 is fixed. */ - if (image || buf->format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) - return image; - } - - /* - * Non-YUV formats could *also* have multiple planes, such as ancillary - * color compression state buffer, but the rest of the code isn't ready - * yet to deal with modifiers: - */ - assert(num_fds == 1); - - const int fourcc = get_fourcc(buf->format); - if (fourcc == -1) { - _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); - return NULL; - } - - pitch = buf->stride * get_format_bpp(buf->format); - if (pitch == 0) { - _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); - return NULL; + case HAL_PIXEL_FORMAT_RGBX_8888: return __DRI_IMAGE_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGBA_FP16: return __DRI_IMAGE_FORMAT_ABGR16161616F; + case HAL_PIXEL_FORMAT_RGBA_1010102: return __DRI_IMAGE_FORMAT_ABGR2101010; + default: + _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", format); } - - const EGLint attr_list[] = { - EGL_WIDTH, buf->width, - EGL_HEIGHT, buf->height, - EGL_LINUX_DRM_FOURCC_EXT, fourcc, - EGL_DMA_BUF_PLANE0_FD_EXT, fds[0], - EGL_DMA_BUF_PLANE0_PITCH_EXT, pitch, - EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, - EGL_NONE, 0 - }; - - return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list); + return -1; } -#ifdef HAVE_DRM_GRALLOC -static _EGLImage * -droid_create_image_from_name(_EGLDisplay *disp, _EGLContext *ctx, - struct ANativeWindowBuffer *buf) +static __DRIimage * +droid_create_image_from_name(_EGLDisplay *disp, + struct ANativeWindowBuffer *buf, + void *priv) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - struct dri2_egl_image *dri2_img; int name; int format; @@ -974,34 +996,19 @@ droid_create_image_from_name(_EGLDisplay *disp, _EGLContext *ctx, if (format == -1) return NULL; - dri2_img = calloc(1, sizeof(*dri2_img)); - if (!dri2_img) { - _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm"); - return NULL; - } - - _eglInitImage(&dri2_img->base, disp); - - dri2_img->dri_image = + return dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen, buf->width, buf->height, format, name, buf->stride, - dri2_img); - if (!dri2_img->dri_image) { - free(dri2_img); - _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm"); - return NULL; - } - - return &dri2_img->base; + priv); } #endif /* HAVE_DRM_GRALLOC */ static EGLBoolean -droid_query_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, +droid_query_surface(_EGLDisplay *disp, _EGLSurface *surf, EGLint attribute, EGLint *value) { struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); @@ -1023,7 +1030,7 @@ droid_query_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, default: break; } - return _eglQuerySurface(drv, disp, surf, attribute, value); + return _eglQuerySurface(disp, surf, attribute, value); } static _EGLImage * @@ -1031,9 +1038,6 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx, struct ANativeWindowBuffer *buf) { - int fds[3]; - unsigned num_fds; - if (ctx != NULL) { /* From the EGL_ANDROID_image_native_buffer spec: * @@ -1052,28 +1056,34 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, return NULL; } - num_fds = get_native_buffer_fds(buf, fds); - if (num_fds > 0) - return droid_create_image_from_prime_fds(disp, ctx, buf, num_fds, fds); + __DRIimage *dri_image = + droid_create_image_from_native_buffer(disp, buf, buf); #ifdef HAVE_DRM_GRALLOC - return droid_create_image_from_name(disp, ctx, buf); -#else - return NULL; + if (dri_image == NULL) + dri_image = droid_create_image_from_name(disp, buf, buf); #endif + + if (dri_image) { +#if ANDROID_API_LEVEL >= 26 + AHardwareBuffer_acquire(ANativeWindowBuffer_getHardwareBuffer(buf)); +#endif + return dri2_create_image_from_dri(disp, dri_image); + } + + return NULL; } static _EGLImage * -droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, - EGLClientBuffer buffer, const EGLint *attr_list) +droid_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, + EGLClientBuffer buffer, const EGLint *attr_list) { switch (target) { case EGL_NATIVE_BUFFER_ANDROID: return dri2_create_image_android_native_buffer(disp, ctx, (struct ANativeWindowBuffer *) buffer); default: - return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list); + return dri2_create_image_khr(disp, ctx, target, buffer, attr_list); } } @@ -1110,7 +1120,7 @@ droid_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf, break; } - /* fall through for pbuffers */ + FALLTHROUGH; /* for pbuffers */ case __DRI_BUFFER_DEPTH: case __DRI_BUFFER_STENCIL: case __DRI_BUFFER_ACCUM: @@ -1172,8 +1182,19 @@ droid_get_capability(void *loaderPrivate, enum dri_loader_cap cap) } } +static void +droid_destroy_loader_image_state(void *loaderPrivate) +{ +#if ANDROID_API_LEVEL >= 26 + if (loaderPrivate) { + AHardwareBuffer_release( + ANativeWindowBuffer_getHardwareBuffer(loaderPrivate)); + } +#endif +} + static EGLBoolean -droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp) +droid_add_configs_for_visuals(_EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); static const struct { @@ -1256,32 +1277,26 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp) static const struct dri2_egl_display_vtbl droid_display_vtbl = { .authenticate = NULL, .create_window_surface = droid_create_window_surface, - .create_pixmap_surface = dri2_fallback_create_pixmap_surface, .create_pbuffer_surface = droid_create_pbuffer_surface, .destroy_surface = droid_destroy_surface, .create_image = droid_create_image_khr, .swap_buffers = droid_swap_buffers, - .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage, /* Android implements the function */ - .swap_buffers_region = dri2_fallback_swap_buffers_region, .swap_interval = droid_swap_interval, - .post_sub_buffer = dri2_fallback_post_sub_buffer, - .copy_buffers = dri2_fallback_copy_buffers, .query_buffer_age = droid_query_buffer_age, .query_surface = droid_query_surface, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, - .get_sync_values = dri2_fallback_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, .set_shared_buffer_mode = droid_set_shared_buffer_mode, }; #ifdef HAVE_DRM_GRALLOC static const __DRIdri2LoaderExtension droid_dri2_loader_extension = { - .base = { __DRI_DRI2_LOADER, 4 }, + .base = { __DRI_DRI2_LOADER, 5 }, - .getBuffers = NULL, - .flushFrontBuffer = droid_flush_front_buffer, - .getBuffersWithFormat = droid_get_buffers_with_format, - .getCapability = droid_get_capability, + .getBuffers = NULL, + .flushFrontBuffer = droid_flush_front_buffer, + .getBuffersWithFormat = droid_get_buffers_with_format, + .getCapability = droid_get_capability, + .destroyLoaderImageState = droid_destroy_loader_image_state, }; static const __DRIextension *droid_dri2_loader_extensions[] = { @@ -1296,11 +1311,13 @@ static const __DRIextension *droid_dri2_loader_extensions[] = { #endif /* HAVE_DRM_GRALLOC */ static const __DRIimageLoaderExtension droid_image_loader_extension = { - .base = { __DRI_IMAGE_LOADER, 2 }, + .base = { __DRI_IMAGE_LOADER, 4 }, - .getBuffers = droid_image_get_buffers, - .flushFrontBuffer = droid_flush_front_buffer, - .getCapability = droid_get_capability, + .getBuffers = droid_image_get_buffers, + .flushFrontBuffer = droid_flush_front_buffer, + .getCapability = droid_get_capability, + .flushSwapBuffers = NULL, + .destroyLoaderImageState = droid_destroy_loader_image_state, }; static void @@ -1390,8 +1407,7 @@ static const __DRIextension *droid_image_loader_extensions[] = { static EGLBoolean droid_load_driver(_EGLDisplay *disp, bool swrast) { - struct dri2_egl_display *dri2_dpy = disp->DriverData; - const char *err; + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); if (dri2_dpy->driver_name == NULL) @@ -1403,7 +1419,6 @@ droid_load_driver(_EGLDisplay *disp, bool swrast) * systems.) */ dri2_dpy->loader_extensions = droid_dri2_loader_extensions; if (!dri2_load_driver(disp)) { - err = "DRI2: failed to load driver"; goto error; } #else @@ -1417,14 +1432,12 @@ droid_load_driver(_EGLDisplay *disp, bool swrast) free(dri2_dpy->driver_name); dri2_dpy->driver_name = strdup("kms_swrast"); } else { - err = "DRI3: failed to find software capable driver"; goto error; } } dri2_dpy->loader_extensions = droid_image_loader_extensions; if (!dri2_load_driver_dri3(disp)) { - err = "DRI3: failed to load driver"; goto error; } #endif @@ -1501,7 +1514,7 @@ droid_open_device(_EGLDisplay *disp, bool swrast) return EGL_FALSE; } - dri2_dpy->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); + dri2_dpy->fd = os_dupfd_cloexec(fd); if (dri2_dpy->fd < 0) return EGL_FALSE; @@ -1590,7 +1603,7 @@ droid_open_device(_EGLDisplay *disp, bool swrast) #endif EGLBoolean -dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_android(_EGLDisplay *disp) { _EGLDevice *dev; bool device_opened = false; @@ -1611,10 +1624,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp) } disp->DriverData = (void *) dri2_dpy; - if (!disp->Options.ForceSoftware) - device_opened = droid_open_device(disp, false); - if (!device_opened) - device_opened = droid_open_device(disp, true); + device_opened = droid_open_device(disp, disp->Options.ForceSoftware); if (!device_opened) { err = "DRI2: failed to open device"; @@ -1645,7 +1655,20 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp) disp->Extensions.ANDROID_framebuffer_target = EGL_TRUE; disp->Extensions.ANDROID_image_native_buffer = EGL_TRUE; disp->Extensions.ANDROID_recordable = EGL_TRUE; - disp->Extensions.EXT_buffer_age = EGL_TRUE; + + /* Querying buffer age requires a buffer to be dequeued. Without + * EGL_ANDROID_native_fence_sync, dequeue might call eglClientWaitSync and + * result in a deadlock (the lock is already held by eglQuerySurface). + */ + if (disp->Extensions.ANDROID_native_fence_sync) { + disp->Extensions.EXT_buffer_age = EGL_TRUE; + } else { + /* disable KHR_partial_update that might have been enabled in + * dri2_setup_screen + */ + disp->Extensions.KHR_partial_update = EGL_FALSE; + } + disp->Extensions.KHR_image = EGL_TRUE; #if ANDROID_API_LEVEL >= 24 if (dri2_dpy->mutable_render_buffer && @@ -1657,7 +1680,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp) /* Create configs *after* enabling extensions because presence of DRI * driver extensions can affect the capabilities of EGLConfigs. */ - if (!droid_add_configs_for_visuals(drv, disp)) { + if (!droid_add_configs_for_visuals(disp)) { err = "DRI2: failed to add configs"; goto cleanup; } diff --git a/lib/mesa/src/egl/drivers/dri2/platform_drm.c b/lib/mesa/src/egl/drivers/dri2/platform_drm.c index d25141a52..8b392f3e7 100644 --- a/lib/mesa/src/egl/drivers/dri2/platform_drm.c +++ b/lib/mesa/src/egl/drivers/dri2/platform_drm.c @@ -36,8 +36,9 @@ #include <fcntl.h> #include <unistd.h> +#include "util/os_file.h" + #include "egl_dri2.h" -#include "egl_dri2_fallbacks.h" #include "loader.h" static struct gbm_bo * @@ -137,9 +138,8 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy, } static _EGLSurface * -dri2_drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_surface, - const EGLint *attrib_list) +dri2_drm_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_surface, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); @@ -148,8 +148,6 @@ dri2_drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, struct gbm_dri_surface *surf; const __DRIconfig *config; - (void) drv; - dri2_surf = calloc(1, sizeof *dri2_surf); if (!dri2_surf) { _eglError(EGL_BAD_ALLOC, "dri2_create_surface"); @@ -191,9 +189,8 @@ dri2_drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, } static _EGLSurface * -dri2_drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +dri2_drm_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { /* From the EGL_MESA_platform_gbm spec, version 5: * @@ -206,7 +203,7 @@ dri2_drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri2_drm_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); @@ -254,12 +251,16 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) surf->base.format, surf->base.modifiers, surf->base.count); - else + else { + unsigned flags = surf->base.flags; + if (dri2_surf->base.ProtectedContent) + flags |= GBM_BO_USE_PROTECTED; dri2_surf->back->bo = gbm_bo_create(&dri2_dpy->gbm_dri->base, surf->base.width, surf->base.height, surf->base.format, - surf->base.flags); + flags); + } } if (dri2_surf->back->bo == NULL) @@ -417,7 +418,7 @@ dri2_drm_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) } static EGLBoolean -dri2_drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +dri2_drm_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); @@ -449,8 +450,7 @@ dri2_drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) } static EGLint -dri2_drm_query_buffer_age(_EGLDriver *drv, - _EGLDisplay *disp, _EGLSurface *surface) +dri2_drm_query_buffer_age(_EGLDisplay *disp, _EGLSurface *surface) { struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface); @@ -489,17 +489,14 @@ dri2_drm_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, } static _EGLImage * -dri2_drm_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, +dri2_drm_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list) { - (void) drv; - switch (target) { case EGL_NATIVE_PIXMAP_KHR: return dri2_drm_create_image_khr_pixmap(disp, ctx, buffer, attr_list); default: - return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list); + return dri2_create_image_khr(disp, ctx, target, buffer, attr_list); } } @@ -609,7 +606,7 @@ swrast_get_image(__DRIdrawable *driDrawable, } static EGLBoolean -drm_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp) +drm_add_configs_for_visuals(_EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); const struct gbm_dri_visual *visuals = dri2_dpy->gbm_dri->visual_table; @@ -673,22 +670,15 @@ static const struct dri2_egl_display_vtbl dri2_drm_display_vtbl = { .authenticate = dri2_drm_authenticate, .create_window_surface = dri2_drm_create_window_surface, .create_pixmap_surface = dri2_drm_create_pixmap_surface, - .create_pbuffer_surface = dri2_fallback_create_pbuffer_surface, .destroy_surface = dri2_drm_destroy_surface, .create_image = dri2_drm_create_image_khr, .swap_buffers = dri2_drm_swap_buffers, - .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage, - .swap_buffers_region = dri2_fallback_swap_buffers_region, - .post_sub_buffer = dri2_fallback_post_sub_buffer, - .copy_buffers = dri2_fallback_copy_buffers, .query_buffer_age = dri2_drm_query_buffer_age, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, - .get_sync_values = dri2_fallback_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, }; EGLBoolean -dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_drm(_EGLDisplay *disp) { _EGLDevice *dev; struct dri2_egl_display *dri2_dpy; @@ -715,7 +705,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) } dri2_dpy->own_device = true; } else { - dri2_dpy->fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3); + dri2_dpy->fd = os_dupfd_cloexec(gbm_device_get_fd(gbm)); if (dri2_dpy->fd < 0) { err = "DRI2: failed to fcntl() existing gbm device"; goto cleanup; @@ -728,7 +718,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) goto cleanup; } - dev = _eglAddDevice(dri2_dpy->fd, disp->Options.ForceSoftware); + dev = _eglAddDevice(dri2_dpy->fd, dri2_dpy->gbm_dri->software); if (!dev) { err = "DRI2: failed to find EGLDevice"; goto cleanup; @@ -780,7 +770,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) dri2_setup_screen(disp); - if (!drm_add_configs_for_visuals(drv, disp)) { + if (!drm_add_configs_for_visuals(disp)) { err = "DRI2: failed to add configs"; goto cleanup; } @@ -792,7 +782,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) #ifdef HAVE_WAYLAND_PLATFORM dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd); #endif - dri2_set_WL_bind_wayland_display(drv, disp); + dri2_set_WL_bind_wayland_display(disp); /* Fill vtbl last to prevent accidentally calling virtual function during * initialization. diff --git a/lib/mesa/src/egl/drivers/dri2/platform_surfaceless.c b/lib/mesa/src/egl/drivers/dri2/platform_surfaceless.c index 212b5c143..2cd909c75 100644 --- a/lib/mesa/src/egl/drivers/dri2/platform_surfaceless.c +++ b/lib/mesa/src/egl/drivers/dri2/platform_surfaceless.c @@ -34,7 +34,6 @@ #include <unistd.h> #include "egl_dri2.h" -#include "egl_dri2_fallbacks.h" #include "loader.h" static __DRIimage* @@ -109,8 +108,8 @@ surfaceless_image_get_buffers(__DRIdrawable *driDrawable, } static _EGLSurface * -dri2_surfaceless_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, const EGLint *attrib_list) +dri2_surfaceless_create_surface(_EGLDisplay *disp, EGLint type, + _EGLConfig *conf, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); @@ -154,7 +153,7 @@ dri2_surfaceless_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, } static EGLBoolean -surfaceless_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +surfaceless_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); @@ -169,70 +168,17 @@ surfaceless_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *sur } static _EGLSurface * -dri2_surfaceless_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, const EGLint *attrib_list) +dri2_surfaceless_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf, + const EGLint *attrib_list) { - return dri2_surfaceless_create_surface(drv, disp, EGL_PBUFFER_BIT, conf, + return dri2_surfaceless_create_surface(disp, EGL_PBUFFER_BIT, conf, attrib_list); } -static EGLBoolean -surfaceless_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp) -{ - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - static const struct { - const char *format_name; - int rgba_shifts[4]; - unsigned int rgba_sizes[4]; - } visuals[] = { - { "ABGR16F", { 0, 16, 32, 48 }, { 16, 16, 16, 16 } }, - { "XBGR16F", { 0, 16, 32, -1 }, { 16, 16, 16, 0 } }, - { "A2RGB10", { 20, 10, 0, 30 }, { 10, 10, 10, 2 } }, - { "X2RGB10", { 20, 10, 0, -1 }, { 10, 10, 10, 0 } }, - { "ARGB8888", { 16, 8, 0, 24 }, { 8, 8, 8, 8 } }, - { "RGB888", { 16, 8, 0, -1 }, { 8, 8, 8, 0 } }, - { "RGB565", { 11, 5, 0, -1 }, { 5, 6, 5, 0 } }, - }; - unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 }; - unsigned int config_count = 0; - - for (unsigned i = 0; dri2_dpy->driver_configs[i] != NULL; i++) { - for (unsigned j = 0; j < ARRAY_SIZE(visuals); j++) { - struct dri2_egl_config *dri2_conf; - - dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i], - config_count + 1, EGL_PBUFFER_BIT, NULL, - visuals[j].rgba_shifts, visuals[j].rgba_sizes); - - if (dri2_conf) { - if (dri2_conf->base.ConfigID == config_count + 1) - config_count++; - format_count[j]++; - } - } - } - - for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) { - if (!format_count[i]) { - _eglLog(_EGL_DEBUG, "No DRI config supports native format %s", - visuals[i].format_name); - } - } - - return (config_count != 0); -} - static const struct dri2_egl_display_vtbl dri2_surfaceless_display_vtbl = { - .create_pixmap_surface = dri2_fallback_create_pixmap_surface, .create_pbuffer_surface = dri2_surfaceless_create_pbuffer_surface, .destroy_surface = surfaceless_destroy_surface, .create_image = dri2_create_image_khr, - .swap_buffers_region = dri2_fallback_swap_buffers_region, - .post_sub_buffer = dri2_fallback_post_sub_buffer, - .copy_buffers = dri2_fallback_copy_buffers, - .query_buffer_age = dri2_fallback_query_buffer_age, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, - .get_sync_values = dri2_fallback_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, }; @@ -264,6 +210,7 @@ static const __DRIextension *image_loader_extensions[] = { &image_loader_extension.base, &image_lookup_extension.base, &use_invalidate.base, + &background_callable_extension.base, NULL, }; @@ -280,7 +227,7 @@ surfaceless_probe_device(_EGLDisplay *disp, bool swrast) { #define MAX_DRM_DEVICES 64 const unsigned node_type = swrast ? DRM_NODE_PRIMARY : DRM_NODE_RENDER; - struct dri2_egl_display *dri2_dpy = disp->DriverData; + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL }; int i, num_devices; @@ -346,7 +293,7 @@ surfaceless_probe_device(_EGLDisplay *disp, bool swrast) static bool surfaceless_probe_device_sw(_EGLDisplay *disp) { - struct dri2_egl_display *dri2_dpy = disp->DriverData; + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); dri2_dpy->fd = -1; disp->Device = _eglAddDevice(dri2_dpy->fd, true); @@ -367,7 +314,7 @@ surfaceless_probe_device_sw(_EGLDisplay *disp) } EGLBoolean -dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_surfaceless(_EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; const char* err; @@ -380,15 +327,7 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp) dri2_dpy->fd = -1; disp->DriverData = (void *) dri2_dpy; - if (!disp->Options.ForceSoftware) { - driver_loaded = surfaceless_probe_device(disp, false); - if (!driver_loaded) - _eglLog(_EGL_WARNING, - "No hardware driver found, falling back to software rendering"); - } - - if (!driver_loaded) - driver_loaded = surfaceless_probe_device(disp, true); + driver_loaded = surfaceless_probe_device(disp, disp->Options.ForceSoftware); if (!driver_loaded) { _eglLog(_EGL_DEBUG, "Falling back to surfaceless swrast without DRM."); @@ -412,9 +351,9 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp) #ifdef HAVE_WAYLAND_PLATFORM dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd); #endif - dri2_set_WL_bind_wayland_display(drv, disp); + dri2_set_WL_bind_wayland_display(disp); - if (!surfaceless_add_configs_for_visuals(drv, disp)) { + if (!dri2_add_pbuffer_configs_for_visuals(disp)) { err = "DRI2: failed to add configs"; goto cleanup; } diff --git a/lib/mesa/src/egl/drivers/dri2/platform_wayland.c b/lib/mesa/src/egl/drivers/dri2/platform_wayland.c index 7b7646e6e..26b671195 100644 --- a/lib/mesa/src/egl/drivers/dri2/platform_wayland.c +++ b/lib/mesa/src/egl/drivers/dri2/platform_wayland.c @@ -40,7 +40,6 @@ #include <sys/mman.h> #include "egl_dri2.h" -#include "egl_dri2_fallbacks.h" #include "loader.h" #include "util/u_vector.h" #include "util/anon_file.h" @@ -51,13 +50,6 @@ #include "wayland-drm-client-protocol.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" -/* cheesy workaround until wayland 1.18 is released */ -#if WAYLAND_VERSION_MAJOR > 1 || \ - (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR < 18) -#define WL_SHM_FORMAT_ABGR16161616F 0x48344241 -#define WL_SHM_FORMAT_XBGR16161616F 0x48344258 -#endif - /* * The index of entries in this table is used as a bitmask in * dri2_dpy->formats, which tracks the formats supported by our server. @@ -266,6 +258,10 @@ resize_callback(struct wl_egl_window *wl_win, void *data) struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display); + if (dri2_surf->base.Width == wl_win->width && + dri2_surf->base.Height == wl_win->height) + return; + /* Update the surface size as soon as native window is resized; from user * pov, this makes the effect that resize is done immediately after native * window resize, without requiring to wait until the first draw. @@ -301,12 +297,11 @@ get_wl_surface_proxy(struct wl_egl_window *window) } /** - * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + * Called via eglCreateWindowSurface(), drv->CreateWindowSurface(). */ static _EGLSurface * -dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +dri2_wl_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); @@ -407,9 +402,8 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, } static _EGLSurface * -dri2_wl_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +dri2_wl_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { /* From the EGL_EXT_platform_wayland spec, version 3: * @@ -423,16 +417,14 @@ dri2_wl_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, } /** - * Called via eglDestroySurface(), drv->API.DestroySurface(). + * Called via eglDestroySurface(), drv->DestroySurface(). */ static EGLBoolean -dri2_wl_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri2_wl_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); - (void) drv; - dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable); for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) { @@ -575,6 +567,13 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) use_flags = __DRI_IMAGE_USE_SHARE | __DRI_IMAGE_USE_BACKBUFFER; + if (dri2_surf->base.ProtectedContent) { + /* Protected buffers can't be read from another GPU */ + if (dri2_dpy->is_different_gpu) + return -1; + use_flags |= __DRI_IMAGE_USE_PROTECTED; + } + if (dri2_dpy->is_different_gpu && dri2_surf->back->linear_copy == NULL) { /* The LINEAR modifier should be a perfect alias of the LINEAR use @@ -1045,12 +1044,12 @@ try_damage_buffer(struct dri2_egl_surface *dri2_surf, } return EGL_TRUE; } + /** - * Called via eglSwapBuffers(), drv->API.SwapBuffers(). + * Called via eglSwapBuffers(), drv->SwapBuffers(). */ static EGLBoolean -dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, - _EGLDisplay *disp, +dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, _EGLSurface *draw, const EGLint *rects, EGLint n_rects) @@ -1150,8 +1149,7 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, } static EGLint -dri2_wl_query_buffer_age(_EGLDriver *drv, - _EGLDisplay *disp, _EGLSurface *surface) +dri2_wl_query_buffer_age(_EGLDisplay *disp, _EGLSurface *surface) { struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface); @@ -1164,15 +1162,13 @@ dri2_wl_query_buffer_age(_EGLDriver *drv, } static EGLBoolean -dri2_wl_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +dri2_wl_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) { - return dri2_wl_swap_buffers_with_damage(drv, disp, draw, NULL, 0); + return dri2_wl_swap_buffers_with_damage(disp, draw, NULL, 0); } static struct wl_buffer * -dri2_wl_create_wayland_buffer_from_image(_EGLDriver *drv, - _EGLDisplay *disp, - _EGLImage *img) +dri2_wl_create_wayland_buffer_from_image(_EGLDisplay *disp, _EGLImage *img) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img = dri2_egl_image(img); @@ -1378,17 +1374,12 @@ static const struct dri2_egl_display_vtbl dri2_wl_display_vtbl = { .authenticate = dri2_wl_authenticate, .create_window_surface = dri2_wl_create_window_surface, .create_pixmap_surface = dri2_wl_create_pixmap_surface, - .create_pbuffer_surface = dri2_fallback_create_pbuffer_surface, .destroy_surface = dri2_wl_destroy_surface, .create_image = dri2_create_image_khr, .swap_buffers = dri2_wl_swap_buffers, .swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage, - .swap_buffers_region = dri2_fallback_swap_buffers_region, - .post_sub_buffer = dri2_fallback_post_sub_buffer, - .copy_buffers = dri2_fallback_copy_buffers, .query_buffer_age = dri2_wl_query_buffer_age, .create_wayland_buffer_from_image = dri2_wl_create_wayland_buffer_from_image, - .get_sync_values = dri2_fallback_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, }; @@ -1408,7 +1399,7 @@ static const __DRIextension *image_loader_extensions[] = { }; static EGLBoolean -dri2_wl_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp) +dri2_wl_add_configs_for_visuals(_EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); unsigned int format_count[ARRAY_SIZE(dri2_wl_visuals)] = { 0 }; @@ -1483,7 +1474,7 @@ dri2_wl_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp) } static EGLBoolean -dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_wayland_drm(_EGLDisplay *disp) { _EGLDevice *dev; struct dri2_egl_display *dri2_dpy; @@ -1533,7 +1524,8 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) if (roundtrip(dri2_dpy) < 0 || dri2_dpy->fd == -1) goto cleanup; - if (roundtrip(dri2_dpy) < 0 || !dri2_dpy->authenticated) + if (!dri2_dpy->authenticated && + (roundtrip(dri2_dpy) < 0 || !dri2_dpy->authenticated)) goto cleanup; dri2_dpy->fd = loader_get_user_preferred_fd(dri2_dpy->fd, @@ -1621,12 +1613,12 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) goto cleanup; } - if (!dri2_wl_add_configs_for_visuals(drv, disp)) { + if (!dri2_wl_add_configs_for_visuals(disp)) { _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to add configs"); goto cleanup; } - dri2_set_WL_bind_wayland_display(drv, disp); + dri2_set_WL_bind_wayland_display(disp); /* When cannot convert EGLImage to wl_buffer when on a different gpu, * because the buffer of the EGLImage has likely a tiling mode the server * gpu won't support. These is no way to check for now. Thus do not support the @@ -1950,7 +1942,7 @@ dri2_wl_swrast_put_image(__DRIdrawable * draw, int op, } static EGLBoolean -dri2_wl_swrast_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +dri2_wl_swrast_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); @@ -1998,17 +1990,9 @@ static const struct dri2_egl_display_vtbl dri2_wl_swrast_display_vtbl = { .authenticate = NULL, .create_window_surface = dri2_wl_create_window_surface, .create_pixmap_surface = dri2_wl_create_pixmap_surface, - .create_pbuffer_surface = dri2_fallback_create_pbuffer_surface, .destroy_surface = dri2_wl_destroy_surface, .create_image = dri2_create_image_khr, .swap_buffers = dri2_wl_swrast_swap_buffers, - .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage, - .swap_buffers_region = dri2_fallback_swap_buffers_region, - .post_sub_buffer = dri2_fallback_post_sub_buffer, - .copy_buffers = dri2_fallback_copy_buffers, - .query_buffer_age = dri2_fallback_query_buffer_age, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, - .get_sync_values = dri2_fallback_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, }; @@ -2028,7 +2012,7 @@ static const __DRIextension *swrast_loader_extensions[] = { }; static EGLBoolean -dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_wayland_swrast(_EGLDisplay *disp) { _EGLDevice *dev; struct dri2_egl_display *dri2_dpy; @@ -2095,7 +2079,7 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp) dri2_wl_setup_swap_interval(disp); - if (!dri2_wl_add_configs_for_visuals(drv, disp)) { + if (!dri2_wl_add_configs_for_visuals(disp)) { _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to add configs"); goto cleanup; } @@ -2113,18 +2097,12 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp) } EGLBoolean -dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_wayland(_EGLDisplay *disp) { - EGLBoolean initialized = EGL_FALSE; - - if (!disp->Options.ForceSoftware) - initialized = dri2_initialize_wayland_drm(drv, disp); - - if (!initialized) - initialized = dri2_initialize_wayland_swrast(drv, disp); - - return initialized; - + if (disp->Options.ForceSoftware) + return dri2_initialize_wayland_swrast(disp); + else + return dri2_initialize_wayland_drm(disp); } void diff --git a/lib/mesa/src/egl/drivers/dri2/platform_x11.c b/lib/mesa/src/egl/drivers/dri2/platform_x11.c index 5a1e2f318..5ffdf1321 100644 --- a/lib/mesa/src/egl/drivers/dri2/platform_x11.c +++ b/lib/mesa/src/egl/drivers/dri2/platform_x11.c @@ -45,7 +45,6 @@ #include "util/bitscan.h" #include "egl_dri2.h" -#include "egl_dri2_fallbacks.h" #include "loader.h" #ifdef HAVE_DRI3 @@ -53,8 +52,7 @@ #endif static EGLBoolean -dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint interval); +dri2_x11_swap_interval(_EGLDisplay *disp, _EGLSurface *surf, EGLint interval); uint32_t dri2_format_for_depth(struct dri2_egl_display *dri2_dpy, uint32_t depth); @@ -245,12 +243,11 @@ dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth) } /** - * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + * Called via eglCreateWindowSurface(), drv->CreateWindowSurface(). */ static _EGLSurface * -dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, void *native_surface, - const EGLint *attrib_list) +dri2_x11_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf, + void *native_surface, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); @@ -260,8 +257,6 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, xcb_generic_error_t *error; const __DRIconfig *config; - (void) drv; - dri2_surf = calloc(1, sizeof *dri2_surf); if (!dri2_surf) { _eglError(EGL_BAD_ALLOC, "dri2_create_surface"); @@ -305,6 +300,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, else _eglError(EGL_BAD_NATIVE_PIXMAP, "xcb_get_geometry"); free(error); + free(reply); goto cleanup_dri_drawable; } else if (reply == NULL) { _eglError(EGL_BAD_ALLOC, "xcb_get_geometry"); @@ -339,7 +335,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, } } else { if (type == EGL_PBUFFER_BIT) { - dri2_surf->depth = _eglGetConfigKey(conf, EGL_BUFFER_SIZE); + dri2_surf->depth = conf->BufferSize; } swrastCreateDrawable(dri2_dpy, dri2_surf); } @@ -361,17 +357,16 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, } /** - * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + * Called via eglCreateWindowSurface(), drv->CreateWindowSurface(). */ static _EGLSurface * -dri2_x11_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +dri2_x11_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); _EGLSurface *surf; - surf = dri2_x11_create_surface(drv, disp, EGL_WINDOW_BIT, conf, + surf = dri2_x11_create_surface(disp, EGL_WINDOW_BIT, conf, native_window, attrib_list); if (surf != NULL) { /* When we first create the DRI2 drawable, its swap interval on the @@ -380,37 +375,34 @@ dri2_x11_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, surf->SwapInterval = 1; /* Override that with a driconf-set value. */ - dri2_x11_swap_interval(drv, disp, surf, dri2_dpy->default_swap_interval); + dri2_x11_swap_interval(disp, surf, dri2_dpy->default_swap_interval); } return surf; } static _EGLSurface * -dri2_x11_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_pixmap, - const EGLint *attrib_list) +dri2_x11_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_pixmap, const EGLint *attrib_list) { - return dri2_x11_create_surface(drv, disp, EGL_PIXMAP_BIT, conf, + return dri2_x11_create_surface(disp, EGL_PIXMAP_BIT, conf, native_pixmap, attrib_list); } static _EGLSurface * -dri2_x11_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, const EGLint *attrib_list) +dri2_x11_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf, + const EGLint *attrib_list) { - return dri2_x11_create_surface(drv, disp, EGL_PBUFFER_BIT, conf, + return dri2_x11_create_surface(disp, EGL_PBUFFER_BIT, conf, NULL, attrib_list); } static EGLBoolean -dri2_x11_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri2_x11_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); - (void) drv; - dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable); if (dri2_dpy->dri2) { @@ -438,9 +430,8 @@ dri2_x11_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) * have. */ static EGLBoolean -dri2_query_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint attribute, - EGLint *value) +dri2_query_surface(_EGLDisplay *disp, _EGLSurface *surf, + EGLint attribute, EGLint *value) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); @@ -459,7 +450,7 @@ dri2_query_surface(_EGLDriver *drv, _EGLDisplay *disp, default: break; } - return _eglQuerySurface(drv, disp, surf, attribute, value); + return _eglQuerySurface(disp, surf, attribute, value); } /** @@ -529,8 +520,10 @@ dri2_x11_get_buffers(__DRIdrawable * driDrawable, if (reply == NULL) return NULL; buffers = xcb_dri2_get_buffers_buffers (reply); - if (buffers == NULL) + if (buffers == NULL) { + free(reply); return NULL; + } *out_count = reply->count; dri2_surf->base.Width = *width = reply->width; @@ -687,6 +680,7 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy) if (dri2_query == NULL || error != NULL) { _eglLog(_EGL_WARNING, "DRI2: failed to query version"); free(error); + free(dri2_query); return EGL_FALSE; } dri2_dpy->dri2_major = dri2_query->major_version; @@ -697,6 +691,7 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy) if (connect == NULL || connect->driver_name_length + connect->device_name_length == 0) { _eglLog(_EGL_WARNING, "DRI2: failed to authenticate"); + free(connect); return EGL_FALSE; } @@ -852,7 +847,7 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy, } static EGLBoolean -dri2_copy_region(_EGLDriver *drv, _EGLDisplay *disp, +dri2_copy_region(_EGLDisplay *disp, _EGLSurface *draw, xcb_xfixes_region_t region) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -882,7 +877,7 @@ dri2_copy_region(_EGLDriver *drv, _EGLDisplay *disp, } static int64_t -dri2_x11_swap_buffers_msc(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, +dri2_x11_swap_buffers_msc(_EGLDisplay *disp, _EGLSurface *draw, int64_t msc, int64_t divisor, int64_t remainder) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -898,7 +893,7 @@ dri2_x11_swap_buffers_msc(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, int64_t swap_count = -1; if (draw->SwapBehavior == EGL_BUFFER_PRESERVED || !dri2_dpy->swap_available) { - swap_count = dri2_copy_region(drv, disp, draw, dri2_surf->region) ? 0 : -1; + swap_count = dri2_copy_region(disp, draw, dri2_surf->region) ? 0 : -1; } else { dri2_flush_drawable_for_swapbuffers(disp, draw); @@ -932,7 +927,7 @@ dri2_x11_swap_buffers_msc(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, } static EGLBoolean -dri2_x11_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +dri2_x11_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); @@ -942,7 +937,7 @@ dri2_x11_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) return EGL_TRUE; } - if (dri2_x11_swap_buffers_msc(drv, disp, draw, 0, 0, 0) == -1) { + if (dri2_x11_swap_buffers_msc(disp, draw, 0, 0, 0) == -1) { /* Swap failed with a window drawable. */ return _eglError(EGL_BAD_NATIVE_WINDOW, __func__); } @@ -950,8 +945,7 @@ dri2_x11_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) } static EGLBoolean -dri2_x11_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *draw, +dri2_x11_swap_buffers_region(_EGLDisplay *disp, _EGLSurface *draw, EGLint numRects, const EGLint *rects) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -961,7 +955,7 @@ dri2_x11_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, xcb_rectangle_t rectangles[16]; if (numRects > (int)ARRAY_SIZE(rectangles)) - return dri2_copy_region(drv, disp, draw, dri2_surf->region); + return dri2_copy_region(disp, draw, dri2_surf->region); for (int i = 0; i < numRects; i++) { rectangles[i].x = rects[i * 4]; @@ -972,27 +966,26 @@ dri2_x11_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, region = xcb_generate_id(dri2_dpy->conn); xcb_xfixes_create_region(dri2_dpy->conn, region, numRects, rectangles); - ret = dri2_copy_region(drv, disp, draw, region); + ret = dri2_copy_region(disp, draw, region); xcb_xfixes_destroy_region(dri2_dpy->conn, region); return ret; } static EGLBoolean -dri2_x11_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, - EGLint x, EGLint y, EGLint width, EGLint height) +dri2_x11_post_sub_buffer(_EGLDisplay *disp, _EGLSurface *draw, + EGLint x, EGLint y, EGLint width, EGLint height) { const EGLint rect[4] = { x, y, width, height }; if (x < 0 || y < 0 || width < 0 || height < 0) _eglError(EGL_BAD_PARAMETER, "eglPostSubBufferNV"); - return dri2_x11_swap_buffers_region(drv, disp, draw, 1, rect); + return dri2_x11_swap_buffers_region(disp, draw, 1, rect); } static EGLBoolean -dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint interval) +dri2_x11_swap_interval(_EGLDisplay *disp, _EGLSurface *surf, EGLint interval) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); @@ -1004,8 +997,7 @@ dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, } static EGLBoolean -dri2_x11_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - void *native_pixmap_target) +dri2_x11_copy_buffers(_EGLDisplay *disp, _EGLSurface *surf, void *native_pixmap_target) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); @@ -1015,8 +1007,6 @@ dri2_x11_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_pixmap_target)); target = (uintptr_t) native_pixmap_target; - (void) drv; - dri2_dpy->flush->flush(dri2_surf->dri_drawable); gc = xcb_generate_id(dri2_dpy->conn); @@ -1087,6 +1077,7 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, buffers = xcb_dri2_get_buffers_buffers (buffers_reply); if (buffers == NULL) { + free(buffers_reply); return NULL; } @@ -1096,6 +1087,7 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, _eglError(EGL_BAD_ALLOC, "xcb_get_geometry"); free(error); free(buffers_reply); + free(geometry_reply); return NULL; } @@ -1135,17 +1127,14 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, } static _EGLImage * -dri2_x11_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, - EGLClientBuffer buffer, const EGLint *attr_list) +dri2_x11_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, + EGLClientBuffer buffer, const EGLint *attr_list) { - (void) drv; - switch (target) { case EGL_NATIVE_PIXMAP_KHR: return dri2_create_image_khr_pixmap(disp, ctx, buffer, attr_list); default: - return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list); + return dri2_create_image_khr(disp, ctx, target, buffer, attr_list); } } @@ -1181,14 +1170,8 @@ static const struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = { .destroy_surface = dri2_x11_destroy_surface, .create_image = dri2_create_image_khr, .swap_buffers = dri2_x11_swap_buffers, - .swap_buffers_region = dri2_fallback_swap_buffers_region, - .post_sub_buffer = dri2_fallback_post_sub_buffer, /* XXX: should really implement this since X11 has pixmaps */ - .copy_buffers = dri2_fallback_copy_buffers, - .query_buffer_age = dri2_fallback_query_buffer_age, .query_surface = dri2_query_surface, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, - .get_sync_values = dri2_fallback_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, }; @@ -1201,13 +1184,10 @@ static const struct dri2_egl_display_vtbl dri2_x11_display_vtbl = { .create_image = dri2_x11_create_image_khr, .swap_interval = dri2_x11_swap_interval, .swap_buffers = dri2_x11_swap_buffers, - .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage, .swap_buffers_region = dri2_x11_swap_buffers_region, .post_sub_buffer = dri2_x11_post_sub_buffer, .copy_buffers = dri2_x11_copy_buffers, - .query_buffer_age = dri2_fallback_query_buffer_age, .query_surface = dri2_query_surface, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, .get_sync_values = dri2_x11_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, }; @@ -1231,8 +1211,12 @@ dri2_find_screen_for_display(const _EGLDisplay *disp, int fallback_screen) { const EGLAttrib *attr; - for (attr = disp->Options.Attribs; attr; attr += 2) { - if (attr[0] == EGL_PLATFORM_X11_SCREEN_EXT) + if (!disp->Options.Attribs) + return fallback_screen; + + for (attr = disp->Options.Attribs; attr[0] != EGL_NONE; attr += 2) { + if (attr[0] == EGL_PLATFORM_X11_SCREEN_EXT || + attr[0] == EGL_PLATFORM_XCB_SCREEN_EXT) return attr[1]; } @@ -1240,7 +1224,7 @@ dri2_find_screen_for_display(const _EGLDisplay *disp, int fallback_screen) } static EGLBoolean -dri2_get_xcb_connection(_EGLDriver *drv, _EGLDisplay *disp, +dri2_get_xcb_connection(_EGLDisplay *disp, struct dri2_egl_display *dri2_dpy) { xcb_screen_iterator_t s; @@ -1252,10 +1236,14 @@ dri2_get_xcb_connection(_EGLDriver *drv, _EGLDisplay *disp, dri2_dpy->conn = xcb_connect(NULL, &screen); dri2_dpy->own_device = true; screen = dri2_find_screen_for_display(disp, screen); - } else { + } else if (disp->Platform == _EGL_PLATFORM_X11) { Display *dpy = disp->PlatformDisplay; dri2_dpy->conn = XGetXCBConnection(dpy); screen = DefaultScreen(dpy); + } else { + /* _EGL_PLATFORM_XCB */ + dri2_dpy->conn = disp->PlatformDisplay; + screen = dri2_find_screen_for_display(disp, 0); } if (!dri2_dpy->conn || xcb_connection_has_error(dri2_dpy->conn)) { @@ -1279,7 +1267,7 @@ disconnect: } static EGLBoolean -dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_x11_swrast(_EGLDisplay *disp) { _EGLDevice *dev; struct dri2_egl_display *dri2_dpy; @@ -1289,7 +1277,7 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); dri2_dpy->fd = -1; - if (!dri2_get_xcb_connection(drv, disp, dri2_dpy)) + if (!dri2_get_xcb_connection(disp, dri2_dpy)) goto cleanup; dev = _eglAddDevice(dri2_dpy->fd, true); @@ -1366,7 +1354,7 @@ static const __DRIextension *dri3_image_loader_extensions[] = { }; static EGLBoolean -dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_x11_dri3(_EGLDisplay *disp) { _EGLDevice *dev; struct dri2_egl_display *dri2_dpy; @@ -1376,7 +1364,7 @@ dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); dri2_dpy->fd = -1; - if (!dri2_get_xcb_connection(drv, disp, dri2_dpy)) + if (!dri2_get_xcb_connection(disp, dri2_dpy)) goto cleanup; if (!dri3_x11_connect(dri2_dpy)) @@ -1413,8 +1401,9 @@ dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp) disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE; disp->Extensions.CHROMIUM_sync_control = EGL_TRUE; disp->Extensions.EXT_buffer_age = EGL_TRUE; + disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE; - dri2_set_WL_bind_wayland_display(drv, disp); + dri2_set_WL_bind_wayland_display(disp); if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp, false)) goto cleanup; @@ -1473,7 +1462,7 @@ static const __DRIextension *dri2_loader_extensions[] = { }; static EGLBoolean -dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_x11_dri2(_EGLDisplay *disp) { _EGLDevice *dev; struct dri2_egl_display *dri2_dpy; @@ -1483,7 +1472,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); dri2_dpy->fd = -1; - if (!dri2_get_xcb_connection(drv, disp, dri2_dpy)) + if (!dri2_get_xcb_connection(disp, dri2_dpy)) goto cleanup; if (!dri2_x11_connect(dri2_dpy)) @@ -1524,7 +1513,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) disp->Extensions.NV_post_sub_buffer = EGL_TRUE; disp->Extensions.CHROMIUM_sync_control = EGL_TRUE; - dri2_set_WL_bind_wayland_display(drv, disp); + dri2_set_WL_bind_wayland_display(disp); if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp, true)) goto cleanup; @@ -1544,24 +1533,22 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) } EGLBoolean -dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp) +dri2_initialize_x11(_EGLDisplay *disp) { - EGLBoolean initialized = EGL_FALSE; + if (disp->Options.ForceSoftware) + return dri2_initialize_x11_swrast(disp); - if (!disp->Options.ForceSoftware) { #ifdef HAVE_DRI3 - if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false)) - initialized = dri2_initialize_x11_dri3(drv, disp); + if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false)) + if (dri2_initialize_x11_dri3(disp)) + return EGL_TRUE; #endif - if (!initialized) - initialized = dri2_initialize_x11_dri2(drv, disp); - } - - if (!initialized) - initialized = dri2_initialize_x11_swrast(drv, disp); + if (!env_var_as_boolean("LIBGL_DRI2_DISABLE", false)) + if (dri2_initialize_x11_dri2(disp)) + return EGL_TRUE; - return initialized; + return EGL_FALSE; } void diff --git a/lib/mesa/src/egl/drivers/dri2/platform_x11_dri3.c b/lib/mesa/src/egl/drivers/dri2/platform_x11_dri3.c index ab137195a..e117105fc 100644 --- a/lib/mesa/src/egl/drivers/dri2/platform_x11_dri3.c +++ b/lib/mesa/src/egl/drivers/dri2/platform_x11_dri3.c @@ -28,12 +28,12 @@ #include <xcb/xcb.h> #include <xcb/dri3.h> #include <xcb/present.h> +#include <xcb/xfixes.h> #include <xf86drm.h> #include "util/macros.h" #include "egl_dri2.h" -#include "egl_dri2_fallbacks.h" #include "platform_x11_dri3.h" #include "loader.h" @@ -105,14 +105,12 @@ static const struct loader_dri3_vtable egl_dri3_vtable = { }; static EGLBoolean -dri3_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri3_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf); xcb_drawable_t drawable = dri3_surf->loader_drawable.drawable; - (void) drv; - loader_dri3_drawable_fini(&dri3_surf->loader_drawable); if (surf->Type == EGL_PBUFFER_BIT) @@ -125,8 +123,7 @@ dri3_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } static EGLBoolean -dri3_set_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint interval) +dri3_set_swap_interval(_EGLDisplay *disp, _EGLSurface *surf, EGLint interval) { struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf); @@ -137,9 +134,8 @@ dri3_set_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, } static _EGLSurface * -dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, void *native_surface, - const EGLint *attrib_list) +dri3_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf, + void *native_surface, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); @@ -147,8 +143,6 @@ dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, const __DRIconfig *dri_config; xcb_drawable_t drawable; - (void) drv; - dri3_surf = calloc(1, sizeof *dri3_surf); if (!dri3_surf) { _eglError(EGL_BAD_ALLOC, "dri3_create_surface"); @@ -189,6 +183,15 @@ dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, goto cleanup_pixmap; } + if (dri3_surf->surf.base.ProtectedContent && + dri2_dpy->is_different_gpu) { + _eglError(EGL_BAD_ALLOC, "dri3_surface_create"); + goto cleanup_pixmap; + } + + dri3_surf->loader_drawable.is_protected_content = + dri3_surf->surf.base.ProtectedContent; + return &dri3_surf->surf.base; cleanup_pixmap: @@ -220,38 +223,36 @@ dri3_authenticate(_EGLDisplay *disp, uint32_t id) } /** - * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + * Called via eglCreateWindowSurface(), drv->CreateWindowSurface(). */ static _EGLSurface * -dri3_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_window, - const EGLint *attrib_list) +dri3_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); _EGLSurface *surf; - surf = dri3_create_surface(drv, disp, EGL_WINDOW_BIT, conf, + surf = dri3_create_surface(disp, EGL_WINDOW_BIT, conf, native_window, attrib_list); if (surf != NULL) - dri3_set_swap_interval(drv, disp, surf, dri2_dpy->default_swap_interval); + dri3_set_swap_interval(disp, surf, dri2_dpy->default_swap_interval); return surf; } static _EGLSurface * -dri3_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, void *native_pixmap, - const EGLint *attrib_list) +dri3_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, + void *native_pixmap, const EGLint *attrib_list) { - return dri3_create_surface(drv, disp, EGL_PIXMAP_BIT, conf, + return dri3_create_surface(disp, EGL_PIXMAP_BIT, conf, native_pixmap, attrib_list); } static _EGLSurface * -dri3_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, const EGLint *attrib_list) +dri3_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf, + const EGLint *attrib_list) { - return dri3_create_surface(drv, disp, EGL_PBUFFER_BIT, conf, + return dri3_create_surface(disp, EGL_PBUFFER_BIT, conf, NULL, attrib_list); } @@ -375,8 +376,7 @@ dri3_create_image_khr_pixmap_from_buffers(_EGLDisplay *disp, _EGLContext *ctx, #endif static _EGLImage * -dri3_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, +dri3_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list) { #ifdef HAVE_DRI3_MODIFIERS @@ -392,7 +392,7 @@ dri3_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, #endif return dri3_create_image_khr_pixmap(disp, ctx, buffer, attr_list); default: - return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list); + return dri2_create_image_khr(disp, ctx, target, buffer, attr_list); } } @@ -422,18 +422,25 @@ const __DRIimageLoaderExtension dri3_image_loader_extension = { }; static EGLBoolean -dri3_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +dri3_swap_buffers_with_damage(_EGLDisplay *disp, _EGLSurface *draw, + const EGLint *rects, EGLint n_rects) { struct dri3_egl_surface *dri3_surf = dri3_egl_surface(draw); return loader_dri3_swap_buffers_msc(&dri3_surf->loader_drawable, 0, 0, 0, 0, + rects, n_rects, draw->SwapBehavior == EGL_BUFFER_PRESERVED) != -1; } static EGLBoolean -dri3_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - void *native_pixmap_target) +dri3_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) +{ + return dri3_swap_buffers_with_damage(disp, draw, NULL, 0); +} + +static EGLBoolean +dri3_copy_buffers(_EGLDisplay *disp, _EGLSurface *surf, void *native_pixmap_target) { struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf); xcb_pixmap_t target; @@ -448,7 +455,7 @@ dri3_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, } static int -dri3_query_buffer_age(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +dri3_query_buffer_age(_EGLDisplay *disp, _EGLSurface *surf) { struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf); @@ -456,9 +463,8 @@ dri3_query_buffer_age(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } static EGLBoolean -dri3_query_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint attribute, - EGLint *value) +dri3_query_surface(_EGLDisplay *disp, _EGLSurface *surf, + EGLint attribute, EGLint *value) { struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf); @@ -471,7 +477,7 @@ dri3_query_surface(_EGLDriver *drv, _EGLDisplay *disp, break; } - return _eglQuerySurface(drv, disp, surf, attribute, value); + return _eglQuerySurface(disp, surf, attribute, value); } static __DRIdrawable * @@ -499,13 +505,10 @@ struct dri2_egl_display_vtbl dri3_x11_display_vtbl = { .create_image = dri3_create_image_khr, .swap_interval = dri3_set_swap_interval, .swap_buffers = dri3_swap_buffers, - .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage, - .swap_buffers_region = dri2_fallback_swap_buffers_region, - .post_sub_buffer = dri2_fallback_post_sub_buffer, + .swap_buffers_with_damage = dri3_swap_buffers_with_damage, .copy_buffers = dri3_copy_buffers, .query_buffer_age = dri3_query_buffer_age, .query_surface = dri3_query_surface, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, .get_sync_values = dri3_get_sync_values, .get_dri_drawable = dri3_get_dri_drawable, .close_screen_notify = dri3_close_screen_notify, @@ -530,11 +533,14 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy) xcb_dri3_query_version_cookie_t dri3_query_cookie; xcb_present_query_version_reply_t *present_query; xcb_present_query_version_cookie_t present_query_cookie; + xcb_xfixes_query_version_reply_t *xfixes_query; + xcb_xfixes_query_version_cookie_t xfixes_query_cookie; xcb_generic_error_t *error; const xcb_query_extension_reply_t *extension; xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_dri3_id); xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_present_id); + xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_xfixes_id); extension = xcb_get_extension_data(dri2_dpy->conn, &xcb_dri3_id); if (!(extension && extension->present)) @@ -544,6 +550,10 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy) if (!(extension && extension->present)) return EGL_FALSE; + extension = xcb_get_extension_data(dri2_dpy->conn, &xcb_xfixes_id); + if (!(extension && extension->present)) + return EGL_FALSE; + dri3_query_cookie = xcb_dri3_query_version(dri2_dpy->conn, DRI3_SUPPORTED_MAJOR, DRI3_SUPPORTED_MINOR); @@ -552,6 +562,10 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy) PRESENT_SUPPORTED_MAJOR, PRESENT_SUPPORTED_MINOR); + xfixes_query_cookie = xcb_xfixes_query_version(dri2_dpy->conn, + XCB_XFIXES_MAJOR_VERSION, + XCB_XFIXES_MINOR_VERSION); + dri3_query = xcb_dri3_query_version_reply(dri2_dpy->conn, dri3_query_cookie, &error); if (dri3_query == NULL || error != NULL) { @@ -579,6 +593,18 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy) dri2_dpy->present_minor_version = present_query->minor_version; free(present_query); + xfixes_query = + xcb_xfixes_query_version_reply(dri2_dpy->conn, + xfixes_query_cookie, &error); + if (xfixes_query == NULL || error != NULL || + xfixes_query->major_version < 2) { + _eglLog(_EGL_WARNING, "DRI3: failed to query xfixes version"); + free(error); + free(xfixes_query); + return EGL_FALSE; + } + free(xfixes_query); + dri2_dpy->fd = loader_dri3_open(dri2_dpy->conn, dri2_dpy->screen->root, 0); if (dri2_dpy->fd < 0) { int conn_error = xcb_connection_has_error(dri2_dpy->conn); diff --git a/lib/mesa/src/egl/drivers/haiku/egl_haiku.cpp b/lib/mesa/src/egl/drivers/haiku/egl_haiku.cpp index 6edd551b5..18c73c9cd 100644 --- a/lib/mesa/src/egl/drivers/haiku/egl_haiku.cpp +++ b/lib/mesa/src/egl/drivers/haiku/egl_haiku.cpp @@ -73,10 +73,10 @@ struct haiku_egl_surface /** - * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + * Called via eglCreateWindowSurface(), drv->CreateWindowSurface(). */ static _EGLSurface * -haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, +haiku_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { CALLED(); @@ -113,7 +113,7 @@ haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, static _EGLSurface * -haiku_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, +haiku_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, void *native_pixmap, const EGLint *attrib_list) { return NULL; @@ -121,7 +121,7 @@ haiku_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, static _EGLSurface * -haiku_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, +haiku_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf, const EGLint *attrib_list) { return NULL; @@ -129,7 +129,7 @@ haiku_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, static EGLBoolean -haiku_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +haiku_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) { if (_eglPutSurface(surf)) { // XXX: detach haiku_egl_surface::gl from the native window and destroy it @@ -152,35 +152,34 @@ haiku_add_configs_for_visuals(_EGLDisplay *disp) _eglInitConfig(&conf->base, disp, 1); TRACE("Config inited\n"); - _eglSetConfigKey(&conf->base, EGL_RED_SIZE, 8); - _eglSetConfigKey(&conf->base, EGL_BLUE_SIZE, 8); - _eglSetConfigKey(&conf->base, EGL_GREEN_SIZE, 8); - _eglSetConfigKey(&conf->base, EGL_LUMINANCE_SIZE, 0); - _eglSetConfigKey(&conf->base, EGL_ALPHA_SIZE, 8); - _eglSetConfigKey(&conf->base, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER); - EGLint r = (_eglGetConfigKey(&conf->base, EGL_RED_SIZE) - + _eglGetConfigKey(&conf->base, EGL_GREEN_SIZE) - + _eglGetConfigKey(&conf->base, EGL_BLUE_SIZE) - + _eglGetConfigKey(&conf->base, EGL_ALPHA_SIZE)); - _eglSetConfigKey(&conf->base, EGL_BUFFER_SIZE, r); - _eglSetConfigKey(&conf->base, EGL_CONFIG_CAVEAT, EGL_NONE); - _eglSetConfigKey(&conf->base, EGL_CONFIG_ID, 1); - _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGB, EGL_FALSE); - _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGBA, EGL_FALSE); - _eglSetConfigKey(&conf->base, EGL_STENCIL_SIZE, 0); - _eglSetConfigKey(&conf->base, EGL_TRANSPARENT_TYPE, EGL_NONE); - _eglSetConfigKey(&conf->base, EGL_NATIVE_RENDERABLE, EGL_TRUE); // Let's say yes - _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_ID, 0); // No visual - _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_TYPE, EGL_NONE); // No visual - _eglSetConfigKey(&conf->base, EGL_RENDERABLE_TYPE, 0x8); - _eglSetConfigKey(&conf->base, EGL_SAMPLE_BUFFERS, 0); // TODO: How to get the right value ? - _eglSetConfigKey(&conf->base, EGL_SAMPLES, _eglGetConfigKey(&conf->base, EGL_SAMPLE_BUFFERS) == 0 ? 0 : 0); - _eglSetConfigKey(&conf->base, EGL_DEPTH_SIZE, 24); // TODO: How to get the right value ? - _eglSetConfigKey(&conf->base, EGL_LEVEL, 0); - _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_WIDTH, 0); // TODO: How to get the right value ? - _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_HEIGHT, 0); // TODO: How to get the right value ? - _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_PIXELS, 0); // TODO: How to get the right value ? - _eglSetConfigKey(&conf->base, EGL_SURFACE_TYPE, EGL_WINDOW_BIT /*| EGL_PIXMAP_BIT | EGL_PBUFFER_BIT*/); + conf->base.RedSize = 8; + conf->base.BlueSize = 8; + conf->base.GreenSize = 8; + conf->base.LuminanceSize = 0; + conf->base.AlphaSize = 8; + conf->base.ColorBufferType = EGL_RGB_BUFFER; + conf->base.BufferSize = conf->base.RedSize + + conf->base.GreenSize + + conf->base.BlueSize + + conf->base.AlphaSize; + conf->base.ConfigCaveat = EGL_NONE; + conf->base.ConfigID = 1; + conf->base.BindToTextureRGB = EGL_FALSE; + conf->base.BindToTextureRGBA = EGL_FALSE; + conf->base.StencilSize = 0; + conf->base.TransparentType = EGL_NONE; + conf->base.NativeRenderable = EGL_TRUE; // Let's say yes + conf->base.NativeVisualID = 0; // No visual + conf->base.NativeVisualType = EGL_NONE; // No visual + conf->base.RenderableType = 0x8; + conf->base.SampleBuffers = 0; // TODO: How to get the right value ? + conf->base.Samples = conf->base.SampleBuffers == 0 ? 0 : 0; + conf->base.DepthSize = 24; // TODO: How to get the right value ? + conf->base.Level = 0; + conf->base.MaxPbufferWidth = 0; // TODO: How to get the right value ? + conf->base.MaxPbufferHeight = 0; // TODO: How to get the right value ? + conf->base.MaxPbufferPixels = 0; // TODO: How to get the right value ? + conf->base.SurfaceType = EGL_WINDOW_BIT /*| EGL_PIXMAP_BIT | EGL_PBUFFER_BIT*/; TRACE("Config configuated\n"); if (!_eglValidateConfig(&conf->base, EGL_FALSE)) { @@ -206,7 +205,7 @@ cleanup: extern "C" EGLBoolean -init_haiku(_EGLDriver *drv, _EGLDisplay *disp) +init_haiku(_EGLDisplay *disp) { _EGLDevice *dev; CALLED(); @@ -222,8 +221,6 @@ init_haiku(_EGLDriver *drv, _EGLDisplay *disp) if (!haiku_add_configs_for_visuals(disp)) return EGL_FALSE; - disp->Version = 14; - TRACE("Initialization finished\n"); return EGL_TRUE; @@ -232,7 +229,7 @@ init_haiku(_EGLDriver *drv, _EGLDisplay *disp) extern "C" EGLBoolean -haiku_terminate(_EGLDriver* drv,_EGLDisplay *disp) +haiku_terminate(_EGLDisplay *disp) { return EGL_TRUE; } @@ -240,7 +237,7 @@ haiku_terminate(_EGLDriver* drv,_EGLDisplay *disp) extern "C" _EGLContext* -haiku_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, +haiku_create_context(_EGLDisplay *disp, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) { CALLED(); @@ -266,7 +263,7 @@ cleanup: extern "C" EGLBoolean -haiku_destroy_context(_EGLDriver* drv, _EGLDisplay *disp, _EGLContext* ctx) +haiku_destroy_context(_EGLDisplay *disp, _EGLContext* ctx) { struct haiku_egl_context* context = haiku_egl_context(ctx); @@ -281,7 +278,7 @@ haiku_destroy_context(_EGLDriver* drv, _EGLDisplay *disp, _EGLContext* ctx) extern "C" EGLBoolean -haiku_make_current(_EGLDriver* drv, _EGLDisplay *disp, _EGLSurface *dsurf, +haiku_make_current(_EGLDisplay *disp, _EGLSurface *dsurf, _EGLSurface *rsurf, _EGLContext *ctx) { CALLED(); @@ -302,7 +299,7 @@ haiku_make_current(_EGLDriver* drv, _EGLDisplay *disp, _EGLSurface *dsurf, extern "C" EGLBoolean -haiku_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +haiku_swap_buffers(_EGLDisplay *disp, _EGLSurface *surf) { struct haiku_egl_surface* surface = haiku_egl_surface(surf); @@ -312,27 +309,16 @@ haiku_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } -/** - * This is the main entrypoint into the driver, called by libEGL. - * Gets an _EGLDriver object and init its dispatch table. - */ extern "C" -void -_eglInitDriver(_EGLDriver *driver) -{ - CALLED(); - - driver->API.Initialize = init_haiku; - driver->API.Terminate = haiku_terminate; - driver->API.CreateContext = haiku_create_context; - driver->API.DestroyContext = haiku_destroy_context; - driver->API.MakeCurrent = haiku_make_current; - driver->API.CreateWindowSurface = haiku_create_window_surface; - driver->API.CreatePixmapSurface = haiku_create_pixmap_surface; - driver->API.CreatePbufferSurface = haiku_create_pbuffer_surface; - driver->API.DestroySurface = haiku_destroy_surface; - - driver->API.SwapBuffers = haiku_swap_buffers; - - TRACE("API Calls defined\n"); -} +const _EGLDriver _eglDriver = { + .Initialize = init_haiku, + .Terminate = haiku_terminate, + .CreateContext = haiku_create_context, + .DestroyContext = haiku_destroy_context, + .MakeCurrent = haiku_make_current, + .CreateWindowSurface = haiku_create_window_surface, + .CreatePixmapSurface = haiku_create_pixmap_surface, + .CreatePbufferSurface = haiku_create_pbuffer_surface, + .DestroySurface = haiku_destroy_surface, + .SwapBuffers = haiku_swap_buffers, +}; diff --git a/lib/mesa/src/egl/generate/egl.xml b/lib/mesa/src/egl/generate/egl.xml index 10e342420..106d4f3fa 100644 --- a/lib/mesa/src/egl/generate/egl.xml +++ b/lib/mesa/src/egl/generate/egl.xml @@ -49,6 +49,9 @@ <type name="NativePixmapType" requires="eglplatform"/> <type name="NativeWindowType" requires="eglplatform"/> <type>struct <name>AHardwareBuffer</name>;</type> + <type>struct <name>wl_buffer</name>;</type> + <type>struct <name>wl_display</name>;</type> + <type>struct <name>wl_resource</name>;</type> <!-- Dummy placeholders for non-EGL types --> <type name="Bool"/> <!-- These are actual EGL types. --> @@ -89,7 +92,13 @@ EGLint iHeight; EGLint iStride; };</type> + <!-- Backwards-compatibility hack: Downstream implementations shipped + incorrect function pointer names for some years. --> <type>typedef void (<apientry/> *<name>EGLDEBUGPROCKHR</name>)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message);</type> + <type>#define <name>PFNEGLBINDWAYLANDDISPLAYWL</name> PFNEGLBINDWAYLANDDISPLAYWLPROC</type> + <type>#define <name>PFNEGLUNBINDWAYLANDDISPLAYWL</name> PFNEGLUNBINDWAYLANDDISPLAYWLPROC</type> + <type>#define <name>PFNEGLQUERYWAYLANDBUFFERWL</name> PFNEGLQUERYWAYLANDBUFFERWLPROC</type> + <type>#define <name>PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL</name> PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC</type> </types> <!-- SECTION: EGL enumerant (token) definitions. --> @@ -468,8 +477,20 @@ <unused start="0x3111" end="0x311F"/> </enums> - <enums namespace="EGL" start="0x3120" end="0x312F" vendor="AMD" comment="Reserved for David Garcia (Khronos bug 5149)"> - <unused start="0x3120" end="0x312F"/> + <enums namespace="EGL" start="0x3120" end="0x312F" vendor="QCOM" comment="EGL_QCOM_create_image"> + <enum value="0x3120" name="EGL_NEW_IMAGE_QCOM"/> + <enum value="0x3121" name="EGL_IMAGE_FORMAT_QCOM"/> + <enum value="0x3122" name="EGL_FORMAT_RGBA_8888_QCOM"/> + <enum value="0x3123" name="EGL_FORMAT_RGB_565_QCOM"/> + <enum value="0x3124" name="EGL_FORMAT_YUYV_QCOM"/> + <enum value="0x3125" name="EGL_FORMAT_UYVY_QCOM"/> + <enum value="0x3126" name="EGL_FORMAT_YV12_QCOM"/> + <enum value="0x3127" name="EGL_FORMAT_NV21_QCOM"/> + <enum value="0x3128" name="EGL_FORMAT_NV12_TILED_QCOM"/> + <enum value="0x3129" name="EGL_FORMAT_BGRA_8888_QCOM"/> + <enum value="0x312A" name="EGL_FORMAT_BGRX_8888_QCOM"/> + <unused start="0x312B" end="0x312E"/> + <enum value="0x312F" name="EGL_FORMAT_RGBX_8888_QCOM"/> </enums> <enums namespace="EGL" start="0x3130" end="0x313F" vendor="NV" comment="Reserved for Greg Prisament (Khronos bug 5166)"> @@ -536,8 +557,23 @@ <enum value="0x31BF" name="EGL_LOSE_CONTEXT_ON_RESET_EXT" alias="EGL_LOSE_CONTEXT_ON_RESET"/> </enums> - <enums namespace="EGL" start="0x31C0" end="0x31CF" vendor="QCOM" comment="Reserved for Maurice Ribble (Khronos bug 6644) - EGL_QCOM_create_image spec TBD"> - <unused start="0x31C0" end="0x31CF"/> + <enums namespace="EGL" start="0x31C0" end="0x31CF" vendor="QCOM" comment="Reserved for Maurice Ribble (Khronos bug 6644) - EGL_QCOM_create_image spec"> + <enum value="0x31C0" name="EGL_FORMAT_R8_QCOM"/> + <enum value="0x31C1" name="EGL_FORMAT_RG88_QCOM"/> + <enum value="0x31C2" name="EGL_FORMAT_NV12_QCOM"/> + <enum value="0x31C3" name="EGL_FORMAT_SRGBX_8888_QCOM"/> + <enum value="0x31C4" name="EGL_FORMAT_SRGBA_8888_QCOM"/> + <enum value="0x31C5" name="EGL_FORMAT_YVYU_QCOM"/> + <enum value="0x31C6" name="EGL_FORMAT_VYUY_QCOM"/> + <enum value="0x31C7" name="EGL_FORMAT_IYUV_QCOM"/> + <enum value="0x31C8" name="EGL_FORMAT_RGB_888_QCOM"/> + <enum value="0x31C9" name="EGL_FORMAT_RGBA_5551_QCOM"/> + <enum value="0x31CA" name="EGL_FORMAT_RGBA_4444_QCOM"/> + <enum value="0x31CB" name="EGL_FORMAT_R_16_FLOAT_QCOM"/> + <enum value="0x31CC" name="EGL_FORMAT_RG_1616_FLOAT_QCOM"/> + <enum value="0x31CD" name="EGL_FORMAT_RGBA_16_FLOAT_QCOM"/> + <enum value="0x31CE" name="EGL_FORMAT_RGBA_1010102_QCOM"/> + <enum value="0x31CF" name="EGL_FORMAT_FLAG_QCOM"/> </enums> <enums namespace="EGL" start="0x31D0" end="0x31DF" vendor="MESA" comment="Reserved for Kristian Høgsberg (Khronos bug 6757)"> @@ -554,9 +590,26 @@ <enum value="0x31D7" name="EGL_PLATFORM_GBM_MESA" alias="EGL_PLATFORM_GBM_KHR"/> <enum value="0x31D8" name="EGL_PLATFORM_WAYLAND_KHR"/> <enum value="0x31D8" name="EGL_PLATFORM_WAYLAND_EXT" alias="EGL_PLATFORM_WAYLAND_KHR"/> - <unused start="0x31D9" end="0x31DC"/> + <enum value="0x31DC" name="EGL_PLATFORM_XCB_EXT"/> <enum value="0x31DD" name="EGL_PLATFORM_SURFACELESS_MESA"/> - <unused start="0x31DE" end="0x31DF"/> + <enum value="0x31DE" name="EGL_PLATFORM_XCB_SCREEN_EXT"/> + <unused start="0x31DF" end="0x31DF"/> + </enums> + + <!-- Due to an oversight in development, these enums alias the above MESA + vendor range for EGL the X11/GBM/Wayland/surfaceless platforms. + They are both currently in wide use and cannot be changed, however + the tokens cannot be used in the same contexts and the aliasing is + therefore harmless. Future Wayland tokens should not create further + aliasing in this range.--> + <enums namespace="EGL" start="0x31D5" end="0x31DB" vendor="WL" comment="EGL_WL_bind_wayland_display"> + <enum value="0x31D5" name="EGL_WAYLAND_BUFFER_WL"/> + <enum value="0x31D6" name="EGL_WAYLAND_PLANE_WL"/> + <enum value="0x31D7" name="EGL_TEXTURE_Y_U_V_WL"/> + <enum value="0x31D8" name="EGL_TEXTURE_Y_UV_WL"/> + <enum value="0x31D9" name="EGL_TEXTURE_Y_XUXV_WL"/> + <enum value="0x31DA" name="EGL_TEXTURE_EXTERNAL_WL"/> + <enum value="0x31DB" name="EGL_WAYLAND_Y_INVERTED_WL"/> </enums> <enums namespace="EGL" start="0x31E0" end="0x31EF" vendor="HI" comment="Reserved for Mark Callow (Khronos bug 6799)"> @@ -617,7 +670,9 @@ <enum value="0x322D" name="EGL_BAD_OUTPUT_LAYER_EXT"/> <enum value="0x322E" name="EGL_BAD_OUTPUT_PORT_EXT"/> <enum value="0x322F" name="EGL_SWAP_INTERVAL_EXT"/> - <unused start="0x3230" end="0x3232"/> + <enum value="0x3230" name="EGL_TRIPLE_BUFFER_NV"/> + <enum value="0x3231" name="EGL_QUADRUPLE_BUFFER_NV"/> + <unused start="0x3232"/> <enum value="0x3233" name="EGL_DRM_DEVICE_FILE_EXT"/> <enum value="0x3234" name="EGL_DRM_CRTC_EXT"/> <enum value="0x3235" name="EGL_DRM_PLANE_EXT"/> @@ -690,7 +745,9 @@ <enum value="0x3284" name="EGL_YUV_CHROMA_SITING_0_EXT"/> <enum value="0x3285" name="EGL_YUV_CHROMA_SITING_0_5_EXT"/> <enum value="0x3286" name="EGL_DISCARD_SAMPLES_ARM"/> - <unused start="0x3287" end="0x3289"/> + <enum value="0x3287" name="EGL_COLOR_COMPONENT_TYPE_UNSIGNED_INTEGER_ARM"/> + <enum value="0x3288" name="EGL_COLOR_COMPONENT_TYPE_INTEGER_ARM"/> + <unused start="0x3289" end="0x3289"/> <enum value="0x328A" name="EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM"/> <unused start="0x328B" end="0x328F"/> </enums> @@ -705,8 +762,23 @@ <unused start="0x32A2" end="0x32AF"/> </enums> - <enums namespace="EGL" start="0x32B0" end="0x32BF" vendor="QCOM" comment="Reserved for Jeff Vigil (Bug 10663) - EGL_QCOM_lock_image spec TBD"> - <unused start="0x32B0" end="0x32BF"/> + <enums namespace="EGL" start="0x32B0" end="0x32BF" vendor="QCOM" comment="Reserved for Jeff Vigil (Bug 10663) - EGL_QCOM_lock_image2 spec"> + <enum value="0x32B0" name="EGL_IMAGE_NUM_PLANES_QCOM"/> + <enum value="0x32B1" name="EGL_IMAGE_PLANE_PITCH_0_QCOM"/> + <enum value="0x32B2" name="EGL_IMAGE_PLANE_PITCH_1_QCOM"/> + <enum value="0x32B3" name="EGL_IMAGE_PLANE_PITCH_2_QCOM"/> + <enum value="0x32B4" name="EGL_IMAGE_PLANE_DEPTH_0_QCOM"/> + <enum value="0x32B5" name="EGL_IMAGE_PLANE_DEPTH_1_QCOM"/> + <enum value="0x32B6" name="EGL_IMAGE_PLANE_DEPTH_2_QCOM"/> + <enum value="0x32B7" name="EGL_IMAGE_PLANE_WIDTH_0_QCOM"/> + <enum value="0x32B8" name="EGL_IMAGE_PLANE_WIDTH_1_QCOM"/> + <enum value="0x32B9" name="EGL_IMAGE_PLANE_WIDTH_2_QCOM"/> + <enum value="0x32BA" name="EGL_IMAGE_PLANE_HEIGHT_0_QCOM"/> + <enum value="0x32BB" name="EGL_IMAGE_PLANE_HEIGHT_1_QCOM"/> + <enum value="0x32BC" name="EGL_IMAGE_PLANE_HEIGHT_2_QCOM"/> + <enum value="0x32BD" name="EGL_IMAGE_PLANE_POINTER_0_QCOM"/> + <enum value="0x32BE" name="EGL_IMAGE_PLANE_POINTER_1_QCOM"/> + <enum value="0x32BF" name="EGL_IMAGE_PLANE_POINTER_2_QCOM"/> </enums> <enums namespace="EGL" start="0x32C0" end="0x32CF" vendor="Vivante" comment="Reserved for Yanjun Zhang (Bug 11498)"> @@ -714,8 +786,10 @@ <unused start="0x32C1" end="0x32CF"/> </enums> - <enums namespace="EGL" start="0x32D0" end="0x32EF" vendor="QCOM" comment="Reserved for Jeff Vigil (Bug 11735) - EGL_QCOM_gpu_perf spec TBD + Bug 12286 - EGL_QCOM_content_protection spec TBD"> - <unused start="0x32D0" end="0x32EF"/> + <enums namespace="EGL" start="0x32D0" end="0x32EF" vendor="QCOM" comment="Reserved for Jeff Vigil (Bug 11735) - EGL_QCOM_gpu_perf spec"> + <enum value="0x32D0" name="EGL_GPU_PERF_HINT_QCOM"/> + <enum value="0x32D1" name="EGL_HINT_PERSISTENT_QCOM"/> + <unused start="0x32D2" end="0x32EF"/> </enums> <enums namespace="EGL" start="0x32F0" end="0x32FF" vendor="BCOM" comment="Reserved for Gary Sweet, Broadcom (Bug 12870)"> @@ -804,7 +878,20 @@ <enum value="0x3363" name="EGL_GL_COLORSPACE_DISPLAY_P3_EXT"/> <enum value="0x3364" name="EGL_SYNC_CLIENT_EXT"/> <enum value="0x3365" name="EGL_SYNC_CLIENT_SIGNAL_EXT"/> - <unused start="0x3366" end="0x339F"/> + <enum value="0x3366" name="EGL_STREAM_FRAME_ORIGIN_X_NV"/> + <enum value="0x3367" name="EGL_STREAM_FRAME_ORIGIN_Y_NV"/> + <enum value="0x3368" name="EGL_STREAM_FRAME_MAJOR_AXIS_NV"/> + <enum value="0x3369" name="EGL_CONSUMER_AUTO_ORIENTATION_NV"/> + <enum value="0x336A" name="EGL_PRODUCER_AUTO_ORIENTATION_NV"/> + <enum value="0x336B" name="EGL_LEFT_NV"/> + <enum value="0x336C" name="EGL_RIGHT_NV"/> + <enum value="0x336D" name="EGL_TOP_NV"/> + <enum value="0x336E" name="EGL_BOTTOM_NV"/> + <enum value="0x336F" name="EGL_X_AXIS_NV"/> + <enum value="0x3370" name="EGL_Y_AXIS_NV"/> + <enum value="0x3371" name="EGL_STREAM_DMA_NV"/> + <enum value="0x3372" name="EGL_STREAM_DMA_SERVER_NV"/> + <unused start="0x3373" end="0x339F"/> </enums> <enums namespace="EGL" start="0x33A0" end="0x33AF" vendor="ANGLE" comment="Reserved for Shannon Woods (Bug 13175)"> @@ -834,8 +921,54 @@ <unused start="0x33C0" end="0x33DF"/> </enums> - <enums namespace="EGL" start="0x33E0" end="0x342F" vendor="QCOM" comment="Reserved for Jeff Vigil (Bugs 10663,13364)"> - <unused start="0x33E0" end="0x342F"/> + <enums namespace="EGL" start="0x33E0" end="0x342F" vendor="QCOM" comment="EGL_QCOM_create_image and EGL_QCOM_lock_image2"> + <enum value="0x33E0" name="EGL_FORMAT_FLAG_UBWC_QCOM"/> + <enum value="0x33E1" name="EGL_FORMAT_FLAG_MACROTILE_QCOM"/> + <enum value="0x33E2" name="EGL_FORMAT_ASTC_4X4_QCOM"/> + <enum value="0x33E3" name="EGL_FORMAT_ASTC_5X4_QCOM"/> + <enum value="0x33E4" name="EGL_FORMAT_ASTC_5X5_QCOM"/> + <enum value="0x33E5" name="EGL_FORMAT_ASTC_6X5_QCOM"/> + <enum value="0x33E6" name="EGL_FORMAT_ASTC_6X6_QCOM"/> + <enum value="0x33E7" name="EGL_FORMAT_ASTC_8X5_QCOM"/> + <enum value="0x33E8" name="EGL_FORMAT_ASTC_8X6_QCOM"/> + <enum value="0x33E9" name="EGL_FORMAT_ASTC_8X8_QCOM"/> + <enum value="0x33EA" name="EGL_FORMAT_ASTC_10X5_QCOM"/> + <enum value="0x33EB" name="EGL_FORMAT_ASTC_10X6_QCOM"/> + <enum value="0x33EC" name="EGL_FORMAT_ASTC_10X8_QCOM"/> + <enum value="0x33ED" name="EGL_FORMAT_ASTC_10X10_QCOM"/> + <enum value="0x33EE" name="EGL_FORMAT_ASTC_12X10_QCOM"/> + <enum value="0x33EF" name="EGL_FORMAT_ASTC_12X12_QCOM"/> + <enum value="0x3400" name="EGL_FORMAT_ASTC_4X4_SRGB_QCOM"/> + <enum value="0x3401" name="EGL_FORMAT_ASTC_5X4_SRGB_QCOM"/> + <enum value="0x3402" name="EGL_FORMAT_ASTC_5X5_SRGB_QCOM"/> + <enum value="0x3403" name="EGL_FORMAT_ASTC_6X5_SRGB_QCOM"/> + <enum value="0x3404" name="EGL_FORMAT_ASTC_6X6_SRGB_QCOM"/> + <enum value="0x3405" name="EGL_FORMAT_ASTC_8X5_SRGB_QCOM"/> + <enum value="0x3406" name="EGL_FORMAT_ASTC_8X6_SRGB_QCOM"/> + <enum value="0x3407" name="EGL_FORMAT_ASTC_8X8_SRGB_QCOM"/> + <enum value="0x3408" name="EGL_FORMAT_ASTC_10X5_SRGB_QCOM"/> + <enum value="0x3409" name="EGL_FORMAT_ASTC_10X6_SRGB_QCOM"/> + <enum value="0x340A" name="EGL_FORMAT_ASTC_10X8_SRGB_QCOM"/> + <enum value="0x340B" name="EGL_FORMAT_ASTC_10X10_SRGB_QCOM"/> + <enum value="0x340C" name="EGL_FORMAT_ASTC_12X10_SRGB_QCOM"/> + <enum value="0x340D" name="EGL_FORMAT_ASTC_12X12_SRGB_QCOM"/> + <enum value="0x340E" name="EGL_FORMAT_TP10_QCOM"/> + <enum value="0x340F" name="EGL_FORMAT_NV12_Y_QCOM"/> + <enum value="0x3410" name="EGL_FORMAT_NV12_UV_QCOM"/> + <enum value="0x3411" name="EGL_FORMAT_NV21_VU_QCOM"/> + <enum value="0x3412" name="EGL_FORMAT_NV12_4R_QCOM"/> + <enum value="0x3413" name="EGL_FORMAT_NV12_4R_Y_QCOM"/> + <enum value="0x3414" name="EGL_FORMAT_NV12_4R_UV_QCOM"/> + <enum value="0x3415" name="EGL_FORMAT_P010_QCOM"/> + <enum value="0x3416" name="EGL_FORMAT_P010_Y_QCOM"/> + <enum value="0x3417" name="EGL_FORMAT_P010_UV_QCOM"/> + <enum value="0x3418" name="EGL_FORMAT_TP10_Y_QCOM"/> + <enum value="0x3419" name="EGL_FORMAT_TP10_UV_QCOM"/> + <unused start="0x341A" end="0x341F"/> + <enum value="0x3420" name="EGL_GENERIC_TOKEN_1_QCOM"/> + <enum value="0x3421" name="EGL_GENERIC_TOKEN_2_QCOM"/> + <enum value="0x3422" name="EGL_GENERIC_TOKEN_3_QCOM"/> + <unused start="0x3423" end="0x342F"/> </enums> <enums namespace="EGL" start="0x3430" end="0x343F" vendor="ANDROID" comment="Reserved for Pablo Ceballos (Bug 15874)"> @@ -897,6 +1030,13 @@ <enum value="0x3490" name="EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT"/> <unused start="0x3491" end="0x349F"/> </enums> + <enums namespace="EGL" start="0x34A0" end="0x34AF" vendor="ANGLE" comment="Reserved for Ken Russell - ANGLE (via github pull request)"> + <unused start="0x34A0" end="0x34AF"/> + </enums> + + <enums namespace="EGL" start="0x34B0" end="0x34BF" vendor="ARM" comment="Reserved for Jan-Harald Fredriksen (via github pull request)"> + <unused start="0x34B0" end="0x34BF"/> + </enums> <!-- Please remember that new enumerant allocations must be obtained by request to the Khronos API registrar (see comments at the top of this @@ -907,8 +1047,8 @@ <!-- Reservable for future use. To generate a new range, allocate multiples of 16 starting at the lowest available point in this block. --> - <enums namespace="EGL" start="0x34A0" end="0x3FFF" vendor="KHR" comment="Reserved for future use"> - <unused start="0x34A0" end="0x3FFF"/> + <enums namespace="EGL" start="0x34C0" end="0x3FFF" vendor="KHR" comment="Reserved for future use"> + <unused start="0x34C0" end="0x3FFF"/> </enums> <enums namespace="EGL" start="0x8F70" end="0x8F7F" vendor="HI" comment="For Mark Callow, Khronos bug 4055. Shared with GL."> @@ -1691,14 +1831,14 @@ <proto><ptype>EGLBoolean</ptype> <name>eglSwapBuffersWithDamageEXT</name></proto> <param><ptype>EGLDisplay</ptype> <name>dpy</name></param> <param><ptype>EGLSurface</ptype> <name>surface</name></param> - <param><ptype>EGLint</ptype> *<name>rects</name></param> + <param>const <ptype>EGLint</ptype> *<name>rects</name></param> <param><ptype>EGLint</ptype> <name>n_rects</name></param> </command> <command> <proto><ptype>EGLBoolean</ptype> <name>eglSwapBuffersWithDamageKHR</name></proto> <param><ptype>EGLDisplay</ptype> <name>dpy</name></param> <param><ptype>EGLSurface</ptype> <name>surface</name></param> - <param><ptype>EGLint</ptype> *<name>rects</name></param> + <param>const <ptype>EGLint</ptype> *<name>rects</name></param> <param><ptype>EGLint</ptype> <name>n_rects</name></param> </command> <command> @@ -1795,6 +1935,28 @@ <param><ptype>EGLint</ptype> <name>external_win_id</name></param> <param><ptype>EGLint</ptype> <name>policy</name></param> </command> + <command> + <proto><ptype>EGLBoolean</ptype> <name>eglBindWaylandDisplayWL</name></proto> + <param><ptype>EGLDisplay</ptype> <name>dpy</name></param> + <param>struct <ptype>wl_display</ptype> *<name>display</name></param> + </command> + <command> + <proto><ptype>EGLBoolean</ptype> <name>eglUnbindWaylandDisplayWL</name></proto> + <param><ptype>EGLDisplay</ptype> <name>dpy</name></param> + <param>struct <ptype>wl_display</ptype> *<name>display</name></param> + </command> + <command> + <proto><ptype>EGLBoolean</ptype> <name>eglQueryWaylandBufferWL</name></proto> + <param><ptype>EGLDisplay</ptype> <name>dpy</name></param> + <param>struct <ptype>wl_resource</ptype> *<name>buffer</name></param> + <param><ptype>EGLint</ptype> <name>attribute</name></param> + <param><ptype>EGLint</ptype> *<name>value</name></param> + </command> + <command> + <proto>struct <ptype>wl_buffer</ptype> *<name>eglCreateWaylandBufferFromImageWL</name></proto> + <param><ptype>EGLDisplay</ptype> <name>dpy</name></param> + <param><ptype>EGLImageKHR</ptype> <name>image</name></param> + </command> </commands> <!-- SECTION: EGL API interface definitions. --> @@ -2139,6 +2301,7 @@ <enum name="EGL_RECORDABLE_ANDROID"/> </require> </extension> + <extension name="EGL_ANDROID_GLES_layers" supported="egl"/> <extension name="EGL_ANGLE_d3d_share_handle_client_buffer" supported="egl"> <require> <enum name="EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE"/> @@ -2384,6 +2547,12 @@ <enum name="EGL_PLATFORM_X11_SCREEN_EXT"/> </require> </extension> + <extension name="EGL_EXT_platform_xcb" supported="egl"> + <require> + <enum name="EGL_PLATFORM_XCB_EXT"/> + <enum name="EGL_PLATFORM_XCB_SCREEN_EXT"/> + </require> + </extension> <extension name="EGL_EXT_protected_content" supported="egl"> <require> <enum name="EGL_PROTECTED_CONTENT_EXT"/> @@ -2940,6 +3109,11 @@ <command name="eglPostSubBufferNV"/> </require> </extension> + <extension name="EGL_NV_quadruple_buffer" supported="egl"> + <require> + <enum name="EGL_QUADRUPLE_BUFFER_NV"/> + </require> + </extension> <extension name="EGL_NV_robustness_video_memory_purge" supported="egl"> <require> <enum name="EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV"/> @@ -2980,6 +3154,12 @@ <enum name="EGL_STREAM_CROSS_SYSTEM_NV"/> </require> </extension> + <extension name="EGL_NV_stream_dma" supported="egl"> + <require> + <enum name="EGL_STREAM_DMA_NV"/> + <enum name="EGL_STREAM_DMA_SERVER_NV"/> + </require> + </extension> <extension name="EGL_NV_stream_fifo_next" supported="egl"> <require> <enum name="EGL_PENDING_FRAME_NV"/> @@ -3097,6 +3277,11 @@ <command name="eglGetSystemTimeNV"/> </require> </extension> + <extension name="EGL_NV_triple_buffer" supported="egl"> + <require> + <enum name="EGL_TRIPLE_BUFFER_NV"/> + </require> + </extension> <extension name="EGL_TIZEN_image_native_buffer" supported="egl"> <require> <enum name="EGL_NATIVE_BUFFER_TIZEN"/> @@ -3141,5 +3326,50 @@ <enum name="EGL_FRONT_BUFFER_EXT"/> </require> </extension> + <extension name="EGL_NV_stream_origin" supported="egl"> + <require> + <enum name="EGL_STREAM_FRAME_ORIGIN_X_NV"/> + <enum name="EGL_STREAM_FRAME_ORIGIN_Y_NV"/> + <enum name="EGL_STREAM_FRAME_MAJOR_AXIS_NV"/> + <enum name="EGL_CONSUMER_AUTO_ORIENTATION_NV"/> + <enum name="EGL_PRODUCER_AUTO_ORIENTATION_NV"/> + <enum name="EGL_LEFT_NV"/> + <enum name="EGL_RIGHT_NV"/> + <enum name="EGL_TOP_NV"/> + <enum name="EGL_BOTTOM_NV"/> + <enum name="EGL_X_AXIS_NV"/> + <enum name="EGL_Y_AXIS_NV"/> + </require> + </extension> + <extension name="EGL_WL_bind_wayland_display" supported="egl"> + <require> + <enum name="EGL_WAYLAND_BUFFER_WL"/> + <enum name="EGL_WAYLAND_PLANE_WL"/> + <enum name="EGL_TEXTURE_Y_U_V_WL"/> + <enum name="EGL_TEXTURE_Y_UV_WL"/> + <enum name="EGL_TEXTURE_Y_XUXV_WL"/> + <enum name="EGL_TEXTURE_EXTERNAL_WL"/> + <enum name="EGL_WAYLAND_Y_INVERTED_WL"/> + + <command name="eglBindWaylandDisplayWL"/> + <command name="eglUnbindWaylandDisplayWL"/> + <command name="eglQueryWaylandBufferWL"/> + <type name="PFNEGLBINDWAYLANDDISPLAYWL"/> + <type name="PFNEGLUNBINDWAYLANDDISPLAYWL"/> + <type name="PFNEGLQUERYWAYLANDBUFFERWL"/> + </require> + </extension> + <extension name="EGL_WL_create_wayland_buffer_from_image" supported="egl"> + <require> + <command name="eglCreateWaylandBufferFromImageWL"/> + <type name="PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL"/> + </require> + </extension> + <extension name="EGL_ARM_image_format" supported="egl"> + <require> + <enum name="EGL_COLOR_COMPONENT_TYPE_UNSIGNED_INTEGER_ARM"/> + <enum name="EGL_COLOR_COMPONENT_TYPE_INTEGER_ARM"/> + </require> + </extension> </extensions> </registry> diff --git a/lib/mesa/src/egl/generate/eglFunctionList.py b/lib/mesa/src/egl/generate/eglFunctionList.py index 171e3ddc8..cd6c25982 100644 --- a/lib/mesa/src/egl/generate/eglFunctionList.py +++ b/lib/mesa/src/egl/generate/eglFunctionList.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - """ Contains a list of EGL functions to generate dispatch functions for. diff --git a/lib/mesa/src/egl/main/50_mesa.json b/lib/mesa/src/egl/main/50_mesa.json index 8aaaa100f..5f9c18aad 100644 --- a/lib/mesa/src/egl/main/50_mesa.json +++ b/lib/mesa/src/egl/main/50_mesa.json @@ -1,6 +1,6 @@ { "file_format_version" : "1.0.0", "ICD" : { - "library_path" : "libEGL_mesa.so.0" + "library_path" : "libEGL_@glvnd_vendor_name@.so.0" } } diff --git a/lib/mesa/src/egl/main/README.txt b/lib/mesa/src/egl/main/README.txt deleted file mode 100644 index 1af995997..000000000 --- a/lib/mesa/src/egl/main/README.txt +++ /dev/null @@ -1,70 +0,0 @@ - - -Notes about the EGL library: - - -The EGL code here basically consists of two things: - -1. An EGL API dispatcher. This directly routes all the eglFooBar() API - calls into driver-specific functions. - -2. Fallbacks for EGL API functions. A driver _could_ implement all the - EGL API calls from scratch. But in many cases, the fallbacks provided - in libEGL (such as eglChooseConfig()) will do the job. - - - -Bootstrapping: - -When the apps calls eglInitialize() a device driver is selected and loaded -(look for _eglAddDrivers() and _eglLoadModule() in egldriver.c). - -The built-in driver's entry point function is then called. This driver function -allocates, initializes and returns a new _EGLDriver object (usually a -subclass of that type). - -As part of initialization, the dispatch table in _EGLDriver->API must be -populated with all the EGL entrypoints. Typically, _eglInitDriverFallbacks() -can be used to plug in default/fallback functions. Some functions like -driver->API.Initialize and driver->API.Terminate _must_ be implemented -with driver-specific code (no default/fallback function is possible). - - -Shortly after, the driver->API.Initialize() function is executed. Any additional -driver initialization that wasn't done in the driver entry point should be -done at this point. Typically, this will involve setting up visual configs, etc. - - - -Special Functions: - -Certain EGL functions _must_ be implemented by the driver. This includes: - -eglCreateContext -eglCreateWindowSurface -eglCreatePixmapSurface -eglCreatePBufferSurface -eglMakeCurrent -eglSwapBuffers - -Most of the EGLConfig-related functions can be implemented with the -defaults/fallbacks. Same thing for the eglGet/Query functions. - - - - -Teardown: - -When eglTerminate() is called, the driver->API.Terminate() function is -called. The driver should clean up after itself. eglTerminate() will -then close/unload the driver (shared library). - - - - -Subclassing: - -The internal libEGL data structures such as _EGLDisplay, _EGLContext, -_EGLSurface, etc should be considered base classes from which drivers -will derive subclasses. - diff --git a/lib/mesa/src/egl/main/eglapi.c b/lib/mesa/src/egl/main/eglapi.c index 51557be08..17e36af22 100644 --- a/lib/mesa/src/egl/main/eglapi.c +++ b/lib/mesa/src/egl/main/eglapi.c @@ -89,14 +89,15 @@ #define PUBLIC #endif +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "c99_compat.h" #include "c11/threads.h" +#include "util/debug.h" #include "util/macros.h" -#include "eglapi.h" #include "egldefines.h" #include "eglglobals.h" #include "eglcontext.h" @@ -109,6 +110,7 @@ #include "eglconfig.h" #include "eglimage.h" #include "eglsync.h" +#include "egllog.h" #include "GL/mesa_glinterop.h" @@ -139,31 +141,32 @@ * A bunch of macros and checks to simplify error checking. */ -#define _EGL_CHECK_DISPLAY(disp, ret, drv) \ +#define _EGL_CHECK_DISPLAY(disp, ret) \ do { \ - drv = _eglCheckDisplay(disp, __func__); \ - if (!drv) \ + if (!_eglCheckDisplay(disp, __func__)) \ RETURN_EGL_ERROR(disp, 0, ret); \ } while (0) -#define _EGL_CHECK_OBJECT(disp, type, obj, ret, drv) \ +#define _EGL_CHECK_OBJECT(disp, type, obj, ret) \ do { \ - drv = _eglCheck ## type(disp, obj, __func__); \ - if (!drv) \ + if (!_eglCheck ## type(disp, obj, __func__)) \ RETURN_EGL_ERROR(disp, 0, ret); \ } while (0) -#define _EGL_CHECK_SURFACE(disp, surf, ret, drv) \ - _EGL_CHECK_OBJECT(disp, Surface, surf, ret, drv) +#define _EGL_CHECK_SURFACE(disp, surf, ret) \ + _EGL_CHECK_OBJECT(disp, Surface, surf, ret) -#define _EGL_CHECK_CONTEXT(disp, context, ret, drv) \ - _EGL_CHECK_OBJECT(disp, Context, context, ret, drv) +#define _EGL_CHECK_CONTEXT(disp, context, ret) \ + _EGL_CHECK_OBJECT(disp, Context, context, ret) -#define _EGL_CHECK_CONFIG(disp, conf, ret, drv) \ - _EGL_CHECK_OBJECT(disp, Config, conf, ret, drv) +#define _EGL_CHECK_CONFIG(disp, conf, ret) \ + _EGL_CHECK_OBJECT(disp, Config, conf, ret) -#define _EGL_CHECK_SYNC(disp, s, ret, drv) \ - _EGL_CHECK_OBJECT(disp, Sync, s, ret, drv) +#define _EGL_CHECK_SYNC(disp, s, ret) \ + _EGL_CHECK_OBJECT(disp, Sync, s, ret) + + +extern const _EGLDriver _eglDriver; struct _egl_entrypoint { @@ -172,74 +175,70 @@ struct _egl_entrypoint { }; -static inline _EGLDriver * +static inline bool _eglCheckDisplay(_EGLDisplay *disp, const char *msg) { if (!disp) { _eglError(EGL_BAD_DISPLAY, msg); - return NULL; + return false; } if (!disp->Initialized) { _eglError(EGL_NOT_INITIALIZED, msg); - return NULL; + return false; } - return disp->Driver; + return true; } -static inline _EGLDriver * +static inline bool _eglCheckSurface(_EGLDisplay *disp, _EGLSurface *surf, const char *msg) { - _EGLDriver *drv = _eglCheckDisplay(disp, msg); - if (!drv) - return NULL; + if (!_eglCheckDisplay(disp, msg)) + return false; if (!surf) { _eglError(EGL_BAD_SURFACE, msg); - return NULL; + return false; } - return drv; + return true; } -static inline _EGLDriver * +static inline bool _eglCheckContext(_EGLDisplay *disp, _EGLContext *context, const char *msg) { - _EGLDriver *drv = _eglCheckDisplay(disp, msg); - if (!drv) - return NULL; + if (!_eglCheckDisplay(disp, msg)) + return false; if (!context) { _eglError(EGL_BAD_CONTEXT, msg); - return NULL; + return false; } - return drv; + return true; } -static inline _EGLDriver * +static inline bool _eglCheckConfig(_EGLDisplay *disp, _EGLConfig *conf, const char *msg) { - _EGLDriver *drv = _eglCheckDisplay(disp, msg); - if (!drv) - return NULL; + if (!_eglCheckDisplay(disp, msg)) + return false; if (!conf) { _eglError(EGL_BAD_CONFIG, msg); - return NULL; + return false; } - return drv; + return true; } -static inline _EGLDriver * +static inline bool _eglCheckSync(_EGLDisplay *disp, _EGLSync *s, const char *msg) { - _EGLDriver *drv = _eglCheckDisplay(disp, msg); - if (!drv) - return NULL; + if (!_eglCheckDisplay(disp, msg)) + return false; if (!s) { _eglError(EGL_BAD_PARAMETER, msg); - return NULL; + return false; } - return drv; + return true; } @@ -389,6 +388,11 @@ _eglGetPlatformDisplayCommon(EGLenum platform, void *native_display, disp = _eglGetX11Display((Display*) native_display, attrib_list); break; #endif +#ifdef HAVE_XCB_PLATFORM + case EGL_PLATFORM_XCB_EXT: + disp = _eglGetXcbDisplay((xcb_connection_t*) native_display, attrib_list); + break; +#endif #ifdef HAVE_DRM_PLATFORM case EGL_PLATFORM_GBM_MESA: disp = _eglGetGbmDisplay((struct gbm_device*) native_display, @@ -401,11 +405,9 @@ _eglGetPlatformDisplayCommon(EGLenum platform, void *native_display, attrib_list); break; #endif -#ifdef HAVE_SURFACELESS_PLATFORM case EGL_PLATFORM_SURFACELESS_MESA: disp = _eglGetSurfacelessDisplay(native_display, attrib_list); break; -#endif #ifdef HAVE_ANDROID_PLATFORM case EGL_PLATFORM_ANDROID_KHR: disp = _eglGetAndroidDisplay(native_display, attrib_list); @@ -499,6 +501,7 @@ _eglCreateExtensionsString(_EGLDisplay *disp) _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_protected_surface); _EGL_CHECK_EXTENSION(EXT_surface_CTA861_3_metadata); _EGL_CHECK_EXTENSION(EXT_surface_SMPTE2086_metadata); _EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage); @@ -597,6 +600,11 @@ _eglComputeVersion(_EGLDisplay *disp) disp->Extensions.KHR_gl_colorspace && disp->Extensions.KHR_surfaceless_context) disp->Version = 15; + + /* For Android P and below limit the EGL version to 1.4 */ +#if defined(ANDROID) && ANDROID_API_LEVEL <= 28 + disp->Version = 14; +#endif } /** @@ -614,8 +622,28 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE); if (!disp->Initialized) { - if (!_eglMatchDriver(disp)) - RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); + /* set options */ + disp->Options.ForceSoftware = + env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false); + if (disp->Options.ForceSoftware) + _eglLog(_EGL_DEBUG, "Found 'LIBGL_ALWAYS_SOFTWARE' set, will use a CPU renderer"); + + /** + * Initialize the display using the driver's function. + * If the initialisation fails, try again using only software rendering. + */ + if (!_eglDriver.Initialize(disp)) { + if (disp->Options.ForceSoftware) + RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); + else { + disp->Options.ForceSoftware = EGL_TRUE; + if (!_eglDriver.Initialize(disp)) + RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); + } + } + + disp->Initialized = EGL_TRUE; + disp->Driver = &_eglDriver; /* limit to APIs supported by core */ disp->ClientAPIs &= _EGL_API_ALL_BITS; @@ -670,9 +698,7 @@ eglTerminate(EGLDisplay dpy) RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE); if (disp->Initialized) { - _EGLDriver *drv = disp->Driver; - - drv->API.Terminate(drv, disp); + disp->Driver->Terminate(disp); /* do not reset disp->Driver */ disp->ClientAPIsString[0] = 0; disp->Initialized = EGL_FALSE; @@ -690,19 +716,16 @@ const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) { _EGLDisplay *disp; - _EGLDriver *drv; +#if !USE_LIBGLVND 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); } +#endif disp = _eglLockDisplay(dpy); _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, NULL); - _EGL_CHECK_DISPLAY(disp, NULL, drv); + _EGL_CHECK_DISPLAY(disp, NULL); switch (name) { case EGL_VENDOR: @@ -724,17 +747,16 @@ eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); if (!num_config) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = _eglGetConfigs(drv, disp, configs, config_size, num_config); + ret = _eglGetConfigs(disp, configs, config_size, num_config); RETURN_EGL_EVAL(disp, ret); } @@ -745,17 +767,16 @@ eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); if (!num_config) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = _eglChooseConfig(drv, disp, attrib_list, configs, + ret = _eglChooseConfig(disp, attrib_list, configs, config_size, num_config); RETURN_EGL_EVAL(disp, ret); @@ -768,14 +789,13 @@ eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLConfig *conf = _eglLookupConfig(config, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_CONFIG(disp, conf, EGL_FALSE, drv); + _EGL_CHECK_CONFIG(disp, conf, EGL_FALSE); - ret = _eglGetConfigAttrib(drv, disp, conf, attribute, value); + ret = _eglGetConfigAttrib(disp, conf, attribute, value); RETURN_EGL_EVAL(disp, ret); } @@ -788,23 +808,22 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLConfig *conf = _eglLookupConfig(config, disp); _EGLContext *share = _eglLookupContext(share_list, disp); - _EGLDriver *drv; _EGLContext *context; EGLContext ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_CONTEXT); - _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv); + _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT); if (config != EGL_NO_CONFIG_KHR) - _EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT, drv); + _EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT); else if (!disp->Extensions.KHR_no_config_context) RETURN_EGL_ERROR(disp, EGL_BAD_CONFIG, EGL_NO_CONTEXT); if (!share && share_list != EGL_NO_CONTEXT) RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT); - context = drv->API.CreateContext(drv, disp, conf, share, attrib_list); + context = disp->Driver->CreateContext(disp, conf, share, attrib_list); ret = (context) ? _eglLinkContext(context) : EGL_NO_CONTEXT; RETURN_EGL_EVAL(disp, ret); @@ -816,14 +835,13 @@ eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLContext *context = _eglLookupContext(ctx, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_CONTEXT_KHR, context, EGL_FALSE); - _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv); + _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE); _eglUnlinkContext(context); - ret = drv->API.DestroyContext(drv, disp, context); + ret = disp->Driver->DestroyContext(disp, context); RETURN_EGL_EVAL(disp, ret); } @@ -837,14 +855,12 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, _EGLContext *context = _eglLookupContext(ctx, disp); _EGLSurface *draw_surf = _eglLookupSurface(draw, disp); _EGLSurface *read_surf = _eglLookupSurface(read, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_CONTEXT_KHR, context, EGL_FALSE); if (!disp) RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); - drv = disp->Driver; /* display is allowed to be uninitialized under certain condition */ if (!disp->Initialized) { @@ -852,7 +868,7 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, ctx != EGL_NO_CONTEXT) RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); } - if (!drv) + if (!disp->Driver) RETURN_EGL_SUCCESS(disp, EGL_TRUE); if (!context && ctx != EGL_NO_CONTEXT) @@ -880,8 +896,16 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, 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); + /* EGL_EXT_protected_surface spec says: + * If EGL_PROTECTED_CONTENT_EXT attributes of read is EGL_TRUE and + * EGL_PROTECTED_CONTENT_EXT attributes of draw is EGL_FALSE, an + * EGL_BAD_ACCESS error is generated. + */ + if (read_surf && read_surf->ProtectedContent && + draw_surf && !draw_surf->ProtectedContent) + RETURN_EGL_ERROR(disp, EGL_BAD_ACCESS, EGL_FALSE); - ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context); + ret = disp->Driver->MakeCurrent(disp, draw_surf, read_surf, context); RETURN_EGL_EVAL(disp, ret); } @@ -893,14 +917,13 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLContext *context = _eglLookupContext(ctx, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_CONTEXT_KHR, context, EGL_FALSE); - _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv); + _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE); - ret = _eglQueryContext(drv, disp, context, attribute, value); + ret = _eglQueryContext(context, attribute, value); RETURN_EGL_EVAL(disp, ret); } @@ -937,7 +960,6 @@ _eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config, void *native_window, const EGLint *attrib_list) { _EGLConfig *conf = _eglLookupConfig(config, disp); - _EGLDriver *drv; _EGLSurface *surf; EGLSurface ret; @@ -962,7 +984,7 @@ _eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config, RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); } - _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); + _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE); if ((conf->SurfaceType & EGL_WINDOW_BIT) == 0) RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SURFACE); @@ -970,8 +992,7 @@ _eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config, if (_eglNativeSurfaceAlreadyUsed(disp, native_window)) RETURN_EGL_ERROR(disp, EGL_BAD_ALLOC, EGL_NO_SURFACE); - surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window, - attrib_list); + surf = disp->Driver->CreateWindowSurface(disp, conf, native_window, attrib_list); ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; RETURN_EGL_EVAL(disp, ret); @@ -1067,7 +1088,6 @@ _eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, EGLConfig config, void *native_pixmap, const EGLint *attrib_list) { _EGLConfig *conf = _eglLookupConfig(config, disp); - _EGLDriver *drv; _EGLSurface *surf; EGLSurface ret; @@ -1086,7 +1106,7 @@ _eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, EGLConfig config, RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE); } - _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); + _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE); if ((conf->SurfaceType & EGL_PIXMAP_BIT) == 0) RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SURFACE); @@ -1097,8 +1117,7 @@ _eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, EGLConfig config, if (_eglNativeSurfaceAlreadyUsed(disp, native_pixmap)) RETURN_EGL_ERROR(disp, EGL_BAD_ALLOC, EGL_NO_SURFACE); - surf = drv->API.CreatePixmapSurface(drv, disp, conf, native_pixmap, - attrib_list); + surf = disp->Driver->CreatePixmapSurface(disp, conf, native_pixmap, attrib_list); ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; RETURN_EGL_EVAL(disp, ret); @@ -1160,17 +1179,16 @@ eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLConfig *conf = _eglLookupConfig(config, disp); - _EGLDriver *drv; _EGLSurface *surf; EGLSurface ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE); - _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); + _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE); if ((conf->SurfaceType & EGL_PBUFFER_BIT) == 0) RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SURFACE); - surf = drv->API.CreatePbufferSurface(drv, disp, conf, attrib_list); + surf = disp->Driver->CreatePbufferSurface(disp, conf, attrib_list); ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; RETURN_EGL_EVAL(disp, ret); @@ -1182,13 +1200,12 @@ eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); _eglUnlinkSurface(surf); - ret = drv->API.DestroySurface(drv, disp, surf); + ret = disp->Driver->DestroySurface(disp, surf); RETURN_EGL_EVAL(disp, ret); } @@ -1199,16 +1216,15 @@ eglQuerySurface(EGLDisplay dpy, EGLSurface surface, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); - if (drv->API.QuerySurface) - ret = drv->API.QuerySurface(drv, disp, surf, attribute, value); + if (disp->Driver->QuerySurface) + ret = disp->Driver->QuerySurface(disp, surf, attribute, value); else - ret = _eglQuerySurface(drv, disp, surf, attribute, value); + ret = _eglQuerySurface(disp, surf, attribute, value); RETURN_EGL_EVAL(disp, ret); } @@ -1219,13 +1235,12 @@ eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); - ret = _eglSurfaceAttrib(drv, disp, surf, attribute, value); + ret = _eglSurfaceAttrib(disp, surf, attribute, value); RETURN_EGL_EVAL(disp, ret); } @@ -1236,12 +1251,11 @@ eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); - ret = drv->API.BindTexImage(drv, disp, surf, buffer); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); + ret = disp->Driver->BindTexImage(disp, surf, buffer); RETURN_EGL_EVAL(disp, ret); } @@ -1252,12 +1266,11 @@ eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); - ret = drv->API.ReleaseTexImage(drv, disp, surf, buffer); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); + ret = disp->Driver->ReleaseTexImage(disp, surf, buffer); RETURN_EGL_EVAL(disp, ret); } @@ -1269,11 +1282,10 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval) _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLContext *ctx = _eglGetCurrentContext(); _EGLSurface *surf = ctx ? ctx->DrawSurface : NULL; - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || ctx->Resource.Display != disp) @@ -1289,15 +1301,10 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval) surf->Config->MinSwapInterval, surf->Config->MaxSwapInterval); - if (surf->SwapInterval != interval) { - if (drv->API.SwapInterval) - ret = drv->API.SwapInterval(drv, disp, surf, interval); - else - ret = _eglSwapInterval(drv, disp, surf, interval); - } - else { + if (surf->SwapInterval != interval && disp->Driver->SwapInterval) + ret = disp->Driver->SwapInterval(disp, surf, interval); + else ret = EGL_TRUE; - } if (ret) surf->SwapInterval = interval; @@ -1312,11 +1319,10 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) _EGLContext *ctx = _eglGetCurrentContext(); _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); /* surface must be bound to current context in EGL 1.4 */ #ifndef _EGL_BUILT_IN_DRIVER_HAIKU @@ -1337,7 +1343,7 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) if (surf->Lost) RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE); - ret = drv->API.SwapBuffers(drv, disp, surf); + ret = disp->Driver->SwapBuffers(disp, surf); /* EGL_KHR_partial_update * Frame boundary successfully reached, @@ -1354,13 +1360,12 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) static EGLBoolean _eglSwapBuffersWithDamageCommon(_EGLDisplay *disp, _EGLSurface *surf, - EGLint *rects, EGLint n_rects) + const EGLint *rects, EGLint n_rects) { _EGLContext *ctx = _eglGetCurrentContext(); - _EGLDriver *drv; EGLBoolean ret; - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); /* surface must be bound to current context in EGL 1.4 */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -1373,7 +1378,7 @@ _eglSwapBuffersWithDamageCommon(_EGLDisplay *disp, _EGLSurface *surf, if ((n_rects > 0 && rects == NULL) || n_rects < 0) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.SwapBuffersWithDamageEXT(drv, disp, surf, rects, n_rects); + ret = disp->Driver->SwapBuffersWithDamageEXT(disp, surf, rects, n_rects); /* EGL_KHR_partial_update * Frame boundary successfully reached, @@ -1389,7 +1394,7 @@ _eglSwapBuffersWithDamageCommon(_EGLDisplay *disp, _EGLSurface *surf, static EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface surface, - EGLint *rects, EGLint n_rects) + const EGLint *rects, EGLint n_rects) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); @@ -1399,7 +1404,7 @@ eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface surface, static EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface surface, - EGLint *rects, EGLint n_rects) + const EGLint *rects, EGLint n_rects) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); @@ -1412,7 +1417,7 @@ eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface surface, */ static void -_eglSetDamageRegionKHRClampRects(_EGLDisplay* disp, _EGLSurface* surf, +_eglSetDamageRegionKHRClampRects(_EGLSurface* surf, EGLint *rects, EGLint n_rects) { EGLint i; @@ -1441,9 +1446,8 @@ eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface, _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); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || surf->Type != EGL_WINDOW_BIT || @@ -1459,8 +1463,8 @@ eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface, 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); + _eglSetDamageRegionKHRClampRects(surf, rects, n_rects); + ret = disp->Driver->SetDamageRegion(disp, surf, rects, n_rects); if (ret) surf->SetDamageRegionCalled = EGL_TRUE; @@ -1473,7 +1477,6 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; void *native_pixmap_ptr; @@ -1481,8 +1484,10 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) STATIC_ASSERT(sizeof(void*) == sizeof(target)); native_pixmap_ptr = (void*) target; - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); - ret = drv->API.CopyBuffers(drv, disp, surf, native_pixmap_ptr); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); + if (surf->ProtectedContent) + RETURN_EGL_ERROR(disp, EGL_BAD_ACCESS, EGL_FALSE); + ret = disp->Driver->CopyBuffers(disp, surf, native_pixmap_ptr); RETURN_EGL_EVAL(disp, ret); } @@ -1493,7 +1498,6 @@ _eglWaitClientCommon(void) { _EGLContext *ctx = _eglGetCurrentContext(); _EGLDisplay *disp; - _EGLDriver *drv; EGLBoolean ret; if (!ctx) @@ -1509,8 +1513,7 @@ _eglWaitClientCommon(void) /* a valid current context implies an initialized current display */ assert(disp->Initialized); - drv = disp->Driver; - ret = drv->API.WaitClient(drv, disp, ctx); + ret = disp->Driver->WaitClient(disp, ctx); RETURN_EGL_EVAL(disp, ret); } @@ -1536,7 +1539,6 @@ eglWaitNative(EGLint engine) { _EGLContext *ctx = _eglGetCurrentContext(); _EGLDisplay *disp; - _EGLDriver *drv; EGLBoolean ret; if (!ctx) @@ -1554,8 +1556,7 @@ eglWaitNative(EGLint engine) /* a valid current context implies an initialized current display */ assert(disp->Initialized); - drv = disp->Driver; - ret = drv->API.WaitNative(drv, disp, engine); + ret = disp->Driver->WaitNative(engine); RETURN_EGL_EVAL(disp, ret); } @@ -1686,11 +1687,10 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLConfig *conf = _eglLookupConfig(config, disp); - _EGLDriver *drv; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE); - _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); + _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE); /* OpenVG is not supported */ RETURN_EGL_ERROR(disp, EGL_BAD_ALLOC, EGL_NO_SURFACE); @@ -1709,11 +1709,9 @@ eglReleaseThread(void) if (ctx) { _EGLDisplay *disp = ctx->Resource.Display; - _EGLDriver *drv; mtx_lock(&disp->Mutex); - drv = disp->Driver; - (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); + (void) disp->Driver->MakeCurrent(disp, NULL, NULL, NULL); mtx_unlock(&disp->Mutex); } } @@ -1729,11 +1727,10 @@ _eglCreateImageCommon(_EGLDisplay *disp, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list) { _EGLContext *context = _eglLookupContext(ctx, disp); - _EGLDriver *drv; _EGLImage *img; EGLImage ret; - _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); + _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR); if (!disp->Extensions.KHR_image_base) RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); if (!context && ctx != EGL_NO_CONTEXT) @@ -1744,8 +1741,7 @@ _eglCreateImageCommon(_EGLDisplay *disp, EGLContext ctx, EGLenum target, if (ctx != EGL_NO_CONTEXT && target == EGL_LINUX_DMA_BUF_EXT) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR); - img = drv->API.CreateImageKHR(drv, disp, context, target, - buffer, attr_list); + img = disp->Driver->CreateImageKHR(disp, context, target, buffer, attr_list); ret = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR; RETURN_EGL_EVAL(disp, ret); @@ -1784,17 +1780,16 @@ eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, static EGLBoolean _eglDestroyImageCommon(_EGLDisplay *disp, _EGLImage *img) { - _EGLDriver *drv; EGLBoolean ret; - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); if (!disp->Extensions.KHR_image_base) RETURN_EGL_EVAL(disp, EGL_FALSE); if (!img) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); _eglUnlinkImage(img); - ret = drv->API.DestroyImageKHR(drv, disp, img); + ret = disp->Driver->DestroyImageKHR(disp, img); RETURN_EGL_EVAL(disp, ret); } @@ -1824,11 +1819,10 @@ _eglCreateSync(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list, EGLenum invalid_type_error) { _EGLContext *ctx = _eglGetCurrentContext(); - _EGLDriver *drv; _EGLSync *sync; EGLSync ret; - _EGL_CHECK_DISPLAY(disp, EGL_NO_SYNC_KHR, drv); + _EGL_CHECK_DISPLAY(disp, EGL_NO_SYNC_KHR); if (!disp->Extensions.KHR_cl_event2 && orig_is_EGLAttrib) { /* There exist two EGLAttrib variants of eglCreateSync*: @@ -1878,7 +1872,7 @@ _eglCreateSync(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list, RETURN_EGL_ERROR(disp, invalid_type_error, EGL_NO_SYNC_KHR); } - sync = drv->API.CreateSyncKHR(drv, disp, type, attrib_list); + sync = disp->Driver->CreateSyncKHR(disp, type, attrib_list); ret = (sync) ? _eglLinkSync(sync) : EGL_NO_SYNC_KHR; RETURN_EGL_EVAL(disp, ret); @@ -1937,16 +1931,15 @@ eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) static EGLBoolean _eglDestroySync(_EGLDisplay *disp, _EGLSync *s) { - _EGLDriver *drv; EGLBoolean ret; - _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); + _EGL_CHECK_SYNC(disp, s, EGL_FALSE); assert(disp->Extensions.KHR_reusable_sync || disp->Extensions.KHR_fence_sync || disp->Extensions.ANDROID_native_fence_sync); _eglUnlinkSync(s); - ret = drv->API.DestroySyncKHR(drv, disp, s); + ret = disp->Driver->DestroySyncKHR(disp, s); RETURN_EGL_EVAL(disp, ret); } @@ -1974,10 +1967,9 @@ static EGLint _eglClientWaitSyncCommon(_EGLDisplay *disp, EGLDisplay dpy, _EGLSync *s, EGLint flags, EGLTime timeout) { - _EGLDriver *drv; EGLint ret; - _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); + _EGL_CHECK_SYNC(disp, s, EGL_FALSE); assert(disp->Extensions.KHR_reusable_sync || disp->Extensions.KHR_fence_sync || disp->Extensions.ANDROID_native_fence_sync); @@ -1993,7 +1985,7 @@ _eglClientWaitSyncCommon(_EGLDisplay *disp, EGLDisplay dpy, if (s->Type == EGL_SYNC_REUSABLE_KHR) _eglUnlockDisplay(dpy); - ret = drv->API.ClientWaitSyncKHR(drv, disp, s, flags, timeout); + ret = disp->Driver->ClientWaitSyncKHR(disp, s, flags, timeout); /* * 'disp' is already unlocked for reusable sync type, @@ -2030,10 +2022,9 @@ static EGLint _eglWaitSyncCommon(_EGLDisplay *disp, _EGLSync *s, EGLint flags) { _EGLContext *ctx = _eglGetCurrentContext(); - _EGLDriver *drv; EGLint ret; - _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); + _EGL_CHECK_SYNC(disp, s, EGL_FALSE); assert(disp->Extensions.KHR_wait_sync); /* return an error if the client API doesn't support GL_[OES|MESA]_EGL_sync. */ @@ -2046,7 +2037,7 @@ _eglWaitSyncCommon(_EGLDisplay *disp, _EGLSync *s, EGLint flags) if (flags != 0) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.WaitSyncKHR(drv, disp, s); + ret = disp->Driver->WaitSyncKHR(disp, s); RETURN_EGL_EVAL(disp, ret); } @@ -2080,14 +2071,13 @@ eglSignalSyncKHR(EGLDisplay dpy, EGLSync sync, EGLenum mode) { _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); + _EGL_CHECK_SYNC(disp, s, EGL_FALSE); assert(disp->Extensions.KHR_reusable_sync); - ret = drv->API.SignalSyncKHR(drv, disp, s, mode); + ret = disp->Driver->SignalSyncKHR(disp, s, mode); RETURN_EGL_EVAL(disp, ret); } @@ -2096,15 +2086,14 @@ eglSignalSyncKHR(EGLDisplay dpy, EGLSync sync, EGLenum mode) static EGLBoolean _eglGetSyncAttribCommon(_EGLDisplay *disp, _EGLSync *s, EGLint attribute, EGLAttrib *value) { - _EGLDriver *drv; EGLBoolean ret; - _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); + _EGL_CHECK_SYNC(disp, s, EGL_FALSE); assert(disp->Extensions.KHR_reusable_sync || disp->Extensions.KHR_fence_sync || disp->Extensions.ANDROID_native_fence_sync); - ret = _eglGetSyncAttrib(drv, disp, s, attribute, value); + ret = _eglGetSyncAttrib(disp, s, attribute, value); RETURN_EGL_EVAL(disp, ret); } @@ -2155,8 +2144,7 @@ eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSync *s = _eglLookupSync(sync, disp); - _EGLDriver *drv; - EGLBoolean ret; + EGLint ret; _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE); @@ -2167,11 +2155,11 @@ eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync) 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); + _EGL_CHECK_SYNC(disp, s, EGL_NO_NATIVE_FENCE_FD_ANDROID); assert(disp->Extensions.ANDROID_native_fence_sync); - ret = drv->API.DupNativeFenceFDANDROID(drv, disp, s); + ret = disp->Driver->DupNativeFenceFDANDROID(disp, s); - RETURN_EGL_EVAL(disp, ret); + RETURN_EGL_SUCCESS(disp, ret); } static EGLBoolean EGLAPIENTRY @@ -2181,12 +2169,11 @@ eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, _EGLContext *ctx = _eglGetCurrentContext(); _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); if (!disp->Extensions.NOK_swap_region) RETURN_EGL_EVAL(disp, EGL_FALSE); @@ -2196,7 +2183,7 @@ eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, surf != ctx->DrawSurface) RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); - ret = drv->API.SwapBuffersRegionNOK(drv, disp, surf, numRects, rects); + ret = disp->Driver->SwapBuffersRegionNOK(disp, surf, numRects, rects); RETURN_EGL_EVAL(disp, ret); } @@ -2206,17 +2193,16 @@ static EGLImage EGLAPIENTRY eglCreateDRMImageMESA(EGLDisplay dpy, const EGLint *attr_list) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; _EGLImage *img; EGLImage ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); + _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR); if (!disp->Extensions.MESA_drm_image) RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); - img = drv->API.CreateDRMImageMESA(drv, disp, attr_list); + img = disp->Driver->CreateDRMImageMESA(disp, attr_list); ret = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR; RETURN_EGL_EVAL(disp, ret); @@ -2228,18 +2214,17 @@ eglExportDRMImageMESA(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); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); assert(disp->Extensions.MESA_drm_image); if (!img) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.ExportDRMImageMESA(drv, disp, img, name, handle, stride); + ret = disp->Driver->ExportDRMImageMESA(disp, img, name, handle, stride); RETURN_EGL_EVAL(disp, ret); } @@ -2251,18 +2236,17 @@ static EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); assert(disp->Extensions.WL_bind_wayland_display); if (!display) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.BindWaylandDisplayWL(drv, disp, display); + ret = disp->Driver->BindWaylandDisplayWL(disp, display); RETURN_EGL_EVAL(disp, ret); } @@ -2271,18 +2255,17 @@ static EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); assert(disp->Extensions.WL_bind_wayland_display); if (!display) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.UnbindWaylandDisplayWL(drv, disp, display); + ret = disp->Driver->UnbindWaylandDisplayWL(disp, display); RETURN_EGL_EVAL(disp, ret); } @@ -2292,18 +2275,17 @@ eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); assert(disp->Extensions.WL_bind_wayland_display); if (!buffer) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.QueryWaylandBufferWL(drv, disp, buffer, attribute, value); + ret = disp->Driver->QueryWaylandBufferWL(disp, buffer, attribute, value); RETURN_EGL_EVAL(disp, ret); } @@ -2314,12 +2296,11 @@ eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImage image) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLImage *img; - _EGLDriver *drv; struct wl_buffer *ret; _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, NULL, drv); + _EGL_CHECK_DISPLAY(disp, NULL); if (!disp->Extensions.WL_create_wayland_buffer_from_image) RETURN_EGL_EVAL(disp, NULL); @@ -2328,7 +2309,7 @@ eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImage image) if (!img) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, NULL); - ret = drv->API.CreateWaylandBufferFromImageWL(drv, disp, img); + ret = disp->Driver->CreateWaylandBufferFromImageWL(disp, img); RETURN_EGL_EVAL(disp, ret); } @@ -2339,17 +2320,16 @@ eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); if (!disp->Extensions.NV_post_sub_buffer) RETURN_EGL_EVAL(disp, EGL_FALSE); - ret = drv->API.PostSubBufferNV(drv, disp, surf, x, y, width, height); + ret = disp->Driver->PostSubBufferNV(disp, surf, x, y, width, height); RETURN_EGL_EVAL(disp, ret); } @@ -2361,19 +2341,18 @@ eglGetSyncValuesCHROMIUM(EGLDisplay dpy, EGLSurface surface, { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); - _EGLDriver *drv; EGLBoolean ret; _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE); - _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE); if (!disp->Extensions.CHROMIUM_sync_control) RETURN_EGL_EVAL(disp, EGL_FALSE); if (!ust || !msc || !sbc) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.GetSyncValuesCHROMIUM(disp, surf, ust, msc, sbc); + ret = disp->Driver->GetSyncValuesCHROMIUM(disp, surf, ust, msc, sbc); RETURN_EGL_EVAL(disp, ret); } @@ -2385,19 +2364,17 @@ eglExportDMABUFImageQueryMESA(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); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); assert(disp->Extensions.MESA_image_dma_buf_export); if (!img) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.ExportDMABUFImageQueryMESA(drv, disp, img, fourcc, nplanes, - modifiers); + ret = disp->Driver->ExportDMABUFImageQueryMESA(disp, img, fourcc, nplanes, modifiers); RETURN_EGL_EVAL(disp, ret); } @@ -2408,18 +2385,17 @@ eglExportDMABUFImageMESA(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); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); assert(disp->Extensions.MESA_image_dma_buf_export); if (!img) RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); - ret = drv->API.ExportDMABUFImageMESA(drv, disp, img, fds, strides, offsets); + ret = disp->Driver->ExportDMABUFImageMESA(disp, img, fds, strides, offsets); RETURN_EGL_EVAL(disp, ret); } @@ -2576,15 +2552,13 @@ 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); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); - ret = drv->API.QueryDmaBufFormatsEXT(drv, disp, max_formats, formats, - num_formats); + ret = disp->Driver->QueryDmaBufFormatsEXT(disp, max_formats, formats, num_formats); RETURN_EGL_EVAL(disp, ret); } @@ -2595,16 +2569,14 @@ eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint format, EGLint max_modifiers, 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); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); - ret = drv->API.QueryDmaBufModifiersEXT(drv, disp, format, max_modifiers, - modifiers, external_only, - num_modifiers); + ret = disp->Driver->QueryDmaBufModifiersEXT(disp, format, max_modifiers, modifiers, + external_only, num_modifiers); RETURN_EGL_EVAL(disp, ret); } @@ -2623,8 +2595,7 @@ eglSetBlobCacheFuncsANDROID(EGLDisplay *dpy, EGLSetBlobFuncANDROID set, return; } - _EGLDriver *drv = _eglCheckDisplay(disp, __func__); - if (!drv) { + if (!_eglCheckDisplay(disp, __func__)) { if (disp) _eglUnlockDisplay(disp); return; @@ -2647,7 +2618,7 @@ eglSetBlobCacheFuncsANDROID(EGLDisplay *dpy, EGLSetBlobFuncANDROID set, disp->BlobCacheSet = set; disp->BlobCacheGet = get; - drv->API.SetBlobCacheFuncsANDROID(drv, disp, set, get); + disp->Driver->SetBlobCacheFuncsANDROID(disp, set, get); _eglUnlockDisplay(disp); } @@ -2700,10 +2671,9 @@ eglQueryDisplayAttribEXT(EGLDisplay dpy, EGLAttrib *value) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE); - _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + _EGL_CHECK_DISPLAY(disp, EGL_FALSE); switch (attribute) { case EGL_DEVICE_EXT: @@ -2719,15 +2689,14 @@ static char * EGLAPIENTRY eglGetDisplayDriverConfig(EGLDisplay dpy) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; char *ret; _EGL_FUNC_START(disp, EGL_NONE, NULL, NULL); - _EGL_CHECK_DISPLAY(disp, NULL, drv); + _EGL_CHECK_DISPLAY(disp, NULL); assert(disp->Extensions.MESA_query_driver); - ret = drv->API.QueryDriverConfig(disp); + ret = disp->Driver->QueryDriverConfig(disp); RETURN_EGL_EVAL(disp, ret); } @@ -2735,15 +2704,14 @@ static const char * EGLAPIENTRY eglGetDisplayDriverName(EGLDisplay dpy) { _EGLDisplay *disp = _eglLockDisplay(dpy); - _EGLDriver *drv; const char *ret; _EGL_FUNC_START(disp, EGL_NONE, NULL, NULL); - _EGL_CHECK_DISPLAY(disp, NULL, drv); + _EGL_CHECK_DISPLAY(disp, NULL); assert(disp->Extensions.MESA_query_driver); - ret = drv->API.QueryDriverName(disp); + ret = disp->Driver->QueryDriverName(disp); RETURN_EGL_EVAL(disp, ret); } @@ -2772,16 +2740,15 @@ eglGetProcAddress(const char *procname) ret = entrypoint->function; } - if (!ret) - ret = _eglGetDriverProc(procname); + if (!ret && _eglDriver.GetProcAddress) + ret = _eglDriver.GetProcAddress(procname); RETURN_EGL_SUCCESS(NULL, ret); } static int _eglLockDisplayInterop(EGLDisplay dpy, EGLContext context, - _EGLDisplay **disp, _EGLDriver **drv, - _EGLContext **ctx) + _EGLDisplay **disp, _EGLContext **ctx) { *disp = _eglLockDisplay(dpy); @@ -2791,8 +2758,6 @@ _eglLockDisplayInterop(EGLDisplay dpy, EGLContext context, return MESA_GLINTEROP_INVALID_DISPLAY; } - *drv = (*disp)->Driver; - *ctx = _eglLookupContext(context, *disp); if (!*ctx || ((*ctx)->ClientAPI != EGL_OPENGL_API && @@ -2809,16 +2774,15 @@ MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy, EGLContext context, struct mesa_glinterop_device_info *out) { _EGLDisplay *disp; - _EGLDriver *drv; _EGLContext *ctx; int ret; - ret = _eglLockDisplayInterop(dpy, context, &disp, &drv, &ctx); + ret = _eglLockDisplayInterop(dpy, context, &disp, &ctx); if (ret != MESA_GLINTEROP_SUCCESS) return ret; - if (drv->API.GLInteropQueryDeviceInfo) - ret = drv->API.GLInteropQueryDeviceInfo(disp, ctx, out); + if (disp->Driver->GLInteropQueryDeviceInfo) + ret = disp->Driver->GLInteropQueryDeviceInfo(disp, ctx, out); else ret = MESA_GLINTEROP_UNSUPPORTED; @@ -2832,16 +2796,15 @@ MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context, struct mesa_glinterop_export_out *out) { _EGLDisplay *disp; - _EGLDriver *drv; _EGLContext *ctx; int ret; - ret = _eglLockDisplayInterop(dpy, context, &disp, &drv, &ctx); + ret = _eglLockDisplayInterop(dpy, context, &disp, &ctx); if (ret != MESA_GLINTEROP_SUCCESS) return ret; - if (drv->API.GLInteropExportObject) - ret = drv->API.GLInteropExportObject(disp, ctx, in, out); + if (disp->Driver->GLInteropExportObject) + ret = disp->Driver->GLInteropExportObject(disp, ctx, in, out); else ret = MESA_GLINTEROP_UNSUPPORTED; diff --git a/lib/mesa/src/egl/main/eglapi.h b/lib/mesa/src/egl/main/eglapi.h deleted file mode 100644 index 968f4b277..000000000 --- a/lib/mesa/src/egl/main/eglapi.h +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> - * Copyright 2010-2011 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 EGLAPI_INCLUDED -#define EGLAPI_INCLUDED - -#include "egltypedefs.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * A generic function ptr type - */ -typedef void (*_EGLProc)(void); - -struct wl_display; -struct mesa_glinterop_device_info; -struct mesa_glinterop_export_in; -struct mesa_glinterop_export_out; - -/** - * The API dispatcher jumps through these functions - */ -struct _egl_api -{ - /* driver funcs */ - EGLBoolean (*Initialize)(_EGLDriver *, _EGLDisplay *disp); - EGLBoolean (*Terminate)(_EGLDriver *, _EGLDisplay *disp); - const char *(*QueryDriverName)(_EGLDisplay *disp); - char *(*QueryDriverConfig)(_EGLDisplay *disp); - - /* context funcs */ - _EGLContext *(*CreateContext)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *config, _EGLContext *share_list, - const EGLint *attrib_list); - EGLBoolean (*DestroyContext)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx); - /* this is the only function (other than Initialize) that may be called - * with an uninitialized display - */ - EGLBoolean (*MakeCurrent)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *draw, _EGLSurface *read, - _EGLContext *ctx); - - /* surface funcs */ - _EGLSurface *(*CreateWindowSurface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *config, void *native_window, - const EGLint *attrib_list); - _EGLSurface *(*CreatePixmapSurface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *config, void *native_pixmap, - const EGLint *attrib_list); - _EGLSurface *(*CreatePbufferSurface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *config, - const EGLint *attrib_list); - EGLBoolean (*DestroySurface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface); - EGLBoolean (*QuerySurface)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, EGLint attribute, - EGLint *value); - EGLBoolean (*BindTexImage)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, EGLint buffer); - EGLBoolean (*ReleaseTexImage)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, EGLint buffer); - EGLBoolean (*SwapInterval)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint interval); - EGLBoolean (*SwapBuffers)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *draw); - EGLBoolean (*CopyBuffers)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, void *native_pixmap_target); - EGLBoolean (*SetDamageRegion)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, EGLint *rects, EGLint n_rects); - - /* misc functions */ - EGLBoolean (*WaitClient)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx); - EGLBoolean (*WaitNative)(_EGLDriver *drv, _EGLDisplay *disp, - EGLint engine); - - /* this function may be called from multiple threads at the same time */ - _EGLProc (*GetProcAddress)(_EGLDriver *drv, const char *procname); - - _EGLImage *(*CreateImageKHR)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLContext *ctx, EGLenum target, - EGLClientBuffer buffer, - const EGLint *attr_list); - EGLBoolean (*DestroyImageKHR)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLImage *image); - - _EGLSync *(*CreateSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, EGLenum type, - const EGLAttrib *attrib_list); - EGLBoolean (*DestroySyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSync *sync); - EGLint (*ClientWaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSync *sync, EGLint flags, EGLTime timeout); - EGLint (*WaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync); - EGLBoolean (*SignalSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSync *sync, EGLenum mode); - EGLint (*DupNativeFenceFDANDROID)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSync *sync); - - EGLBoolean (*SwapBuffersRegionNOK)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surf, EGLint numRects, - const EGLint *rects); - - _EGLImage *(*CreateDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp, - const EGLint *attr_list); - EGLBoolean (*ExportDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLImage *img, EGLint *name, - EGLint *handle, EGLint *stride); - - EGLBoolean (*BindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp, - struct wl_display *display); - EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp, - struct wl_display *display); - EGLBoolean (*QueryWaylandBufferWL)(_EGLDriver *drv, _EGLDisplay *displ, - struct wl_resource *buffer, - EGLint attribute, EGLint *value); - - struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDriver *drv, - _EGLDisplay *disp, - _EGLImage *img); - - EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, - const EGLint *rects, EGLint n_rects); - - EGLBoolean (*PostSubBufferNV)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLSurface *surface, EGLint x, EGLint y, - EGLint width, EGLint height); - - EGLint (*QueryBufferAge)(_EGLDriver *drv, - _EGLDisplay *disp, _EGLSurface *surface); - EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *disp, _EGLSurface *surface, - EGLuint64KHR *ust, EGLuint64KHR *msc, - EGLuint64KHR *sbc); - - EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLImage *img, EGLint *fourcc, - EGLint *nplanes, - EGLuint64KHR *modifiers); - EGLBoolean (*ExportDMABUFImageMESA)(_EGLDriver *drv, _EGLDisplay *disp, - _EGLImage *img, EGLint *fds, - EGLint *strides, EGLint *offsets); - - int (*GLInteropQueryDeviceInfo)(_EGLDisplay *disp, _EGLContext *ctx, - struct mesa_glinterop_device_info *out); - int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx, - struct mesa_glinterop_export_in *in, - struct mesa_glinterop_export_out *out); - - EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *disp, - EGLint max_formats, EGLint *formats, - EGLint *num_formats); - EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay *disp, - EGLint format, EGLint max_modifiers, - EGLuint64KHR *modifiers, - EGLBoolean *external_only, - EGLint *num_modifiers); - - void (*SetBlobCacheFuncsANDROID) (_EGLDriver *drv, _EGLDisplay *disp, - EGLSetBlobFuncANDROID set, - EGLGetBlobFuncANDROID get); -}; - -#ifdef __cplusplus -} -#endif - -#endif /* EGLAPI_INCLUDED */ diff --git a/lib/mesa/src/egl/main/eglconfig.c b/lib/mesa/src/egl/main/eglconfig.c index 0a95e8ee0..17d8f3555 100644 --- a/lib/mesa/src/egl/main/eglconfig.c +++ b/lib/mesa/src/egl/main/eglconfig.c @@ -790,7 +790,7 @@ _eglFallbackCompare(const _EGLConfig *conf1, const _EGLConfig *conf2, * Typical fallback routine for eglChooseConfig */ EGLBoolean -_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list, +_eglChooseConfig(_EGLDisplay *disp, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_configs) { _EGLConfig criteria; @@ -809,7 +809,7 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list, * Fallback for eglGetConfigAttrib. */ EGLBoolean -_eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, +_eglGetConfigAttrib(_EGLDisplay *disp, _EGLConfig *conf, EGLint attribute, EGLint *value) { if (!_eglIsConfigAttribValid(conf, attribute)) @@ -845,7 +845,7 @@ _eglFlattenConfig(void *elem, void *buffer) * Fallback for eglGetConfigs. */ EGLBoolean -_eglGetConfigs(_EGLDriver *drv, _EGLDisplay *disp, EGLConfig *configs, +_eglGetConfigs(_EGLDisplay *disp, EGLConfig *configs, EGLint config_size, EGLint *num_config) { *num_config = _eglFlattenArray(disp->Configs, (void *) configs, diff --git a/lib/mesa/src/egl/main/eglcontext.c b/lib/mesa/src/egl/main/eglcontext.c index bb11b8f91..15de7c994 100644 --- a/lib/mesa/src/egl/main/eglcontext.c +++ b/lib/mesa/src/egl/main/eglcontext.c @@ -334,8 +334,8 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *disp, /* 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) { + if (((api != EGL_OPENGL_API && api != EGL_OPENGL_ES_API) || + ctx->ClientMajorVersion < 2) && val == EGL_TRUE) { err = EGL_BAD_ATTRIBUTE; break; } @@ -671,12 +671,8 @@ _eglQueryContextRenderBuffer(_EGLContext *ctx) EGLBoolean -_eglQueryContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *c, - EGLint attribute, EGLint *value) +_eglQueryContext(_EGLContext *c, EGLint attribute, EGLint *value) { - (void) drv; - (void) disp; - if (!value) return _eglError(EGL_BAD_PARAMETER, "eglQueryContext"); diff --git a/lib/mesa/src/egl/main/eglcontext.h b/lib/mesa/src/egl/main/eglcontext.h index 2c6ebd19c..06029e812 100644 --- a/lib/mesa/src/egl/main/eglcontext.h +++ b/lib/mesa/src/egl/main/eglcontext.h @@ -74,7 +74,7 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *disp, extern EGLBoolean -_eglQueryContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx, EGLint attribute, EGLint *value); +_eglQueryContext(_EGLContext *ctx, EGLint attribute, EGLint *value); extern EGLBoolean diff --git a/lib/mesa/src/egl/main/egldisplay.c b/lib/mesa/src/egl/main/egldisplay.c index f6e85c79a..765618f0d 100644 --- a/lib/mesa/src/egl/main/egldisplay.c +++ b/lib/mesa/src/egl/main/egldisplay.c @@ -39,6 +39,7 @@ #include <fcntl.h> #include "c11/threads.h" #include "util/macros.h" +#include "util/os_file.h" #include "util/u_atomic.h" #include "eglcontext.h" @@ -69,6 +70,7 @@ static const struct { const char *name; } egl_platforms[] = { { _EGL_PLATFORM_X11, "x11" }, + { _EGL_PLATFORM_XCB, "xcb" }, { _EGL_PLATFORM_WAYLAND, "wayland" }, { _EGL_PLATFORM_DRM, "drm" }, { _EGL_PLATFORM_ANDROID, "android" }, @@ -254,33 +256,34 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy, for (disp = _eglGlobal.DisplayList; disp; disp = disp->Next) { if (disp->Platform == plat && disp->PlatformDisplay == plat_dpy && _eglSameAttribs(disp->Options.Attribs, attrib_list)) - break; + goto out; } /* create a new display */ - if (!disp) { - disp = calloc(1, sizeof(_EGLDisplay)); - if (disp) { - mtx_init(&disp->Mutex, mtx_plain); - disp->Platform = plat; - disp->PlatformDisplay = plat_dpy; - num_attribs = _eglNumAttribs(attrib_list); - if (num_attribs) { - disp->Options.Attribs = calloc(num_attribs, sizeof(EGLAttrib)); - if (!disp->Options.Attribs) { - free(disp); - disp = NULL; - goto out; - } - memcpy(disp->Options.Attribs, attrib_list, - num_attribs * sizeof(EGLAttrib)); - } - /* add to the display list */ - disp->Next = _eglGlobal.DisplayList; - _eglGlobal.DisplayList = disp; + assert(!disp); + disp = calloc(1, sizeof(_EGLDisplay)); + if (!disp) + goto out; + + mtx_init(&disp->Mutex, mtx_plain); + disp->Platform = plat; + disp->PlatformDisplay = plat_dpy; + num_attribs = _eglNumAttribs(attrib_list); + if (num_attribs) { + disp->Options.Attribs = calloc(num_attribs, sizeof(EGLAttrib)); + if (!disp->Options.Attribs) { + free(disp); + disp = NULL; + goto out; } + memcpy(disp->Options.Attribs, attrib_list, + num_attribs * sizeof(EGLAttrib)); } + /* add to the display list */ + disp->Next = _eglGlobal.DisplayList; + _eglGlobal.DisplayList = disp; + out: mtx_unlock(_eglGlobal.Mutex); @@ -292,9 +295,10 @@ out: * Destroy the contexts and surfaces that are linked to the display. */ void -_eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display) +_eglReleaseDisplayResources(_EGLDisplay *display) { _EGLResource *list; + const _EGLDriver *drv = display->Driver; list = display->ResourceLists[_EGL_RESOURCE_CONTEXT]; while (list) { @@ -302,7 +306,7 @@ _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display) list = list->Next; _eglUnlinkContext(ctx); - drv->API.DestroyContext(drv, display, ctx); + drv->DestroyContext(display, ctx); } assert(!display->ResourceLists[_EGL_RESOURCE_CONTEXT]); @@ -312,7 +316,7 @@ _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display) list = list->Next; _eglUnlinkSurface(surf); - drv->API.DestroySurface(drv, display, surf); + drv->DestroySurface(display, surf); } assert(!display->ResourceLists[_EGL_RESOURCE_SURFACE]); @@ -322,7 +326,7 @@ _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display) list = list->Next; _eglUnlinkImage(image); - drv->API.DestroyImageKHR(drv, display, image); + drv->DestroyImageKHR(display, image); } assert(!display->ResourceLists[_EGL_RESOURCE_IMAGE]); @@ -332,7 +336,7 @@ _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display) list = list->Next; _eglUnlinkSync(sync); - drv->API.DestroySyncKHR(drv, display, sync); + drv->DestroySyncKHR(display, sync); } assert(!display->ResourceLists[_EGL_RESOURCE_SYNC]); } @@ -503,6 +507,27 @@ _eglGetX11Display(Display *native_display, } #endif /* HAVE_X11_PLATFORM */ +#ifdef HAVE_XCB_PLATFORM +_EGLDisplay* +_eglGetXcbDisplay(xcb_connection_t *native_display, + const EGLAttrib *attrib_list) +{ + /* EGL_EXT_platform_xcb recognizes exactly one attribute, + * EGL_PLATFORM_XCB_SCREEN_EXT, which is optional. + */ + if (attrib_list != NULL) { + for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) { + if (attrib_list[i] != EGL_PLATFORM_XCB_SCREEN_EXT) { + _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay"); + return NULL; + } + } + } + + return _eglFindDisplay(_EGL_PLATFORM_XCB, native_display, attrib_list); +} +#endif /* HAVE_XCB_PLATFORM */ + #ifdef HAVE_DRM_PLATFORM _EGLDisplay* _eglGetGbmDisplay(struct gbm_device *native_display, @@ -533,7 +558,6 @@ _eglGetWaylandDisplay(struct wl_display *native_display, } #endif /* HAVE_WAYLAND_PLATFORM */ -#ifdef HAVE_SURFACELESS_PLATFORM _EGLDisplay* _eglGetSurfacelessDisplay(void *native_display, const EGLAttrib *attrib_list) @@ -553,7 +577,6 @@ _eglGetSurfacelessDisplay(void *native_display, return _eglFindDisplay(_EGL_PLATFORM_SURFACELESS, native_display, attrib_list); } -#endif /* HAVE_SURFACELESS_PLATFORM */ #ifdef HAVE_ANDROID_PLATFORM _EGLDisplay* @@ -618,7 +641,7 @@ _eglGetDeviceDisplay(void *native_display, * The new fd is guaranteed to be 3 or greater. */ if (fd != -1 && display->Options.fd == 0) { - display->Options.fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); + display->Options.fd = os_dupfd_cloexec(fd); if (display->Options.fd == -1) { /* Do not (really) need to teardown the display */ _eglError(EGL_BAD_ALLOC, "eglGetPlatformDisplay"); diff --git a/lib/mesa/src/egl/main/egldisplay.h b/lib/mesa/src/egl/main/egldisplay.h index 02ac4fb9a..4d2afbc71 100644 --- a/lib/mesa/src/egl/main/egldisplay.h +++ b/lib/mesa/src/egl/main/egldisplay.h @@ -45,6 +45,7 @@ extern "C" { enum _egl_platform_type { _EGL_PLATFORM_X11, + _EGL_PLATFORM_XCB, _EGL_PLATFORM_WAYLAND, _EGL_PLATFORM_DRM, _EGL_PLATFORM_ANDROID, @@ -106,6 +107,7 @@ struct _egl_extensions EGLBoolean EXT_image_dma_buf_import; EGLBoolean EXT_image_dma_buf_import_modifiers; EGLBoolean EXT_pixel_format_float; + EGLBoolean EXT_protected_surface; EGLBoolean EXT_surface_CTA861_3_metadata; EGLBoolean EXT_surface_SMPTE2086_metadata; EGLBoolean EXT_swap_buffers_with_damage; @@ -161,7 +163,7 @@ struct _egl_display void *PlatformDisplay; /**< A pointer to the platform display */ _EGLDevice *Device; /**< Device backing the display */ - _EGLDriver *Driver; /**< Matched driver of the display */ + const _EGLDriver *Driver; /**< Matched driver of the display */ EGLBoolean Initialized; /**< True if the display is initialized */ /* options that affect how the driver initializes the display */ @@ -207,7 +209,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy, const EGLAttrib *attr); extern void -_eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *disp); +_eglReleaseDisplayResources(_EGLDisplay *disp); extern void @@ -293,6 +295,12 @@ _EGLDisplay* _eglGetX11Display(Display *native_display, const EGLAttrib *attrib_list); #endif +#ifdef HAVE_XCB_PLATFORM +typedef struct xcb_connection_t xcb_connection_t; +_EGLDisplay* +_eglGetXcbDisplay(xcb_connection_t *native_display, const EGLAttrib *attrib_list); +#endif + #ifdef HAVE_DRM_PLATFORM struct gbm_device; @@ -309,11 +317,9 @@ _eglGetWaylandDisplay(struct wl_display *native_display, const EGLAttrib *attrib_list); #endif -#ifdef HAVE_SURFACELESS_PLATFORM _EGLDisplay* _eglGetSurfacelessDisplay(void *native_display, const EGLAttrib *attrib_list); -#endif #ifdef HAVE_ANDROID_PLATFORM _EGLDisplay* diff --git a/lib/mesa/src/egl/main/egldriver.c b/lib/mesa/src/egl/main/egldriver.c deleted file mode 100644 index b9b21dec5..000000000 --- a/lib/mesa/src/egl/main/egldriver.c +++ /dev/null @@ -1,352 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> - * Copyright 2010-2011 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. - * - **************************************************************************/ - - -/** - * Functions for choosing and opening/loading device drivers. - */ - - -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include "c11/threads.h" - -#include "egldefines.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "egllog.h" - -typedef struct _egl_module { - char *Name; - _EGLMain_t BuiltIn; - _EGLDriver *Driver; -} _EGLModule; - -static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP; -static _EGLArray *_eglModules; - -const struct { - const char *name; - _EGLMain_t main; -} _eglBuiltInDrivers[] = { -#ifdef _EGL_BUILT_IN_DRIVER_DRI2 - { "egl_dri2", _eglBuiltInDriverDRI2 }, -#endif -#ifdef _EGL_BUILT_IN_DRIVER_HAIKU - { "egl_haiku", _eglBuiltInDriverHaiku }, -#endif - { NULL, NULL } -}; - -/** - * Load a module and create the driver object. - */ -static EGLBoolean -_eglLoadModule(_EGLModule *mod) -{ - _EGLDriver *drv; - - if (mod->Driver) - return EGL_TRUE; - - if (!mod->BuiltIn) - return EGL_FALSE; - - drv = mod->BuiltIn(NULL); - if (!drv || !drv->Name) - return EGL_FALSE; - - mod->Driver = drv; - - return EGL_TRUE; -} - - -/** - * Unload a module. - */ -static void -_eglUnloadModule(_EGLModule *mod) -{ - /* destroy the driver */ - if (mod->Driver && mod->Driver->Unload) - mod->Driver->Unload(mod->Driver); - - mod->Driver = NULL; -} - - -/** - * Add a module to the module array. - */ -static _EGLModule * -_eglAddModule(const char *name) -{ - _EGLModule *mod; - EGLint i; - - if (!_eglModules) { - _eglModules = _eglCreateArray("Module", 8); - if (!_eglModules) - return NULL; - } - - /* find duplicates */ - for (i = 0; i < _eglModules->Size; i++) { - mod = _eglModules->Elements[i]; - if (strcmp(mod->Name, name) == 0) - return mod; - } - - /* allocate a new one */ - mod = calloc(1, sizeof(*mod)); - if (mod) { - mod->Name = strdup(name); - if (!mod->Name) { - free(mod); - mod = NULL; - } - } - if (mod) { - _eglAppendArray(_eglModules, (void *) mod); - _eglLog(_EGL_DEBUG, "added %s to module array", mod->Name); - } - - return mod; -} - - -/** - * Free a module. - */ -static void -_eglFreeModule(void *module) -{ - _EGLModule *mod = (_EGLModule *) module; - - _eglUnloadModule(mod); - free(mod->Name); - free(mod); -} - - -/** - * Add the user driver to the module array. - * - * The user driver is specified by EGL_DRIVER. - */ -static EGLBoolean -_eglAddUserDriver(void) -{ - char *env; - - env = getenv("EGL_DRIVER"); - if (env) { - EGLint i; - - for (i = 0; _eglBuiltInDrivers[i].name; i++) { - if (!strcmp(_eglBuiltInDrivers[i].name, env)) { - _EGLModule *mod = _eglAddModule(env); - if (mod) - mod->BuiltIn = _eglBuiltInDrivers[i].main; - - return EGL_TRUE; - } - } - } - - return EGL_FALSE; -} - - -/** - * Add built-in drivers to the module array. - */ -static void -_eglAddBuiltInDrivers(void) -{ - _EGLModule *mod; - EGLint i; - - for (i = 0; _eglBuiltInDrivers[i].name; i++) { - mod = _eglAddModule(_eglBuiltInDrivers[i].name); - if (mod) - mod->BuiltIn = _eglBuiltInDrivers[i].main; - } -} - - -/** - * Add drivers to the module array. Drivers will be loaded as they are matched - * to displays. - */ -static EGLBoolean -_eglAddDrivers(void) -{ - if (_eglModules) - return EGL_TRUE; - - if (!_eglAddUserDriver()) { - /* - * Add other drivers only when EGL_DRIVER is not set. The order here - * decides the priorities. - */ - _eglAddBuiltInDrivers(); - } - - return (_eglModules != NULL); -} - - -/** - * A helper function for _eglMatchDriver. It finds the first driver that can - * initialize the display and return. - */ -static _EGLDriver * -_eglMatchAndInitialize(_EGLDisplay *dpy) -{ - _EGLDriver *drv = NULL; - EGLint i = 0; - - if (!_eglAddDrivers()) { - _eglLog(_EGL_WARNING, "failed to find any driver"); - return NULL; - } - - if (dpy->Driver) { - drv = dpy->Driver; - /* no re-matching? */ - if (!drv->API.Initialize(drv, dpy)) - drv = NULL; - return drv; - } - - while (i < _eglModules->Size) { - _EGLModule *mod = (_EGLModule *) _eglModules->Elements[i]; - - if (!_eglLoadModule(mod)) { - /* remove invalid modules */ - _eglEraseArray(_eglModules, i, _eglFreeModule); - continue; - } - - if (mod->Driver->API.Initialize(mod->Driver, dpy)) { - drv = mod->Driver; - break; - } - else { - i++; - } - } - - return drv; -} - - -/** - * Match a display to a driver. The display is initialized unless test_only is - * true. The matching is done by finding the first driver that can initialize - * the display. - */ -_EGLDriver * -_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) -{ - _EGLDriver *best_drv; - - assert(!dpy->Initialized); - - mtx_lock(&_eglModuleMutex); - - /* set options */ - dpy->Options.TestOnly = test_only; - dpy->Options.UseFallback = EGL_FALSE; - - best_drv = _eglMatchAndInitialize(dpy); - if (!best_drv) { - dpy->Options.UseFallback = EGL_TRUE; - best_drv = _eglMatchAndInitialize(dpy); - } - - mtx_unlock(&_eglModuleMutex); - - if (best_drv) { - _eglLog(_EGL_DEBUG, "the best driver is %s%s", - best_drv->Name, (test_only) ? " (test only) " : ""); - if (!test_only) { - dpy->Driver = best_drv; - dpy->Initialized = EGL_TRUE; - } - } - - return best_drv; -} - - -__eglMustCastToProperFunctionPointerType -_eglGetDriverProc(const char *procname) -{ - EGLint i; - _EGLProc proc = NULL; - - if (!_eglModules) { - /* load the driver for the default display */ - EGLDisplay egldpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - _EGLDisplay *dpy = _eglLookupDisplay(egldpy); - if (!dpy || !_eglMatchDriver(dpy, EGL_TRUE)) - return NULL; - } - - for (i = 0; i < _eglModules->Size; i++) { - _EGLModule *mod = (_EGLModule *) _eglModules->Elements[i]; - - if (!mod->Driver) - break; - proc = mod->Driver->API.GetProcAddress(mod->Driver, procname); - if (proc) - break; - } - - return proc; -} - - -/** - * Unload all drivers. - */ -void -_eglUnloadDrivers(void) -{ - /* this is called at atexit time */ - if (_eglModules) { - _eglDestroyArray(_eglModules, _eglFreeModule); - _eglModules = NULL; - } -} diff --git a/lib/mesa/src/egl/main/eglglobals.c b/lib/mesa/src/egl/main/eglglobals.c index 8a8c03c92..dd2b07c0d 100644 --- a/lib/mesa/src/egl/main/eglglobals.c +++ b/lib/mesa/src/egl/main/eglglobals.c @@ -37,7 +37,6 @@ #include "eglglobals.h" #include "egldevice.h" #include "egldisplay.h" -#include "egldriver.h" #include "util/macros.h" @@ -54,41 +53,52 @@ struct _egl_global _eglGlobal = .Mutex = &_eglGlobalMutex, .DisplayList = NULL, .DeviceList = &_eglSoftwareDevice, - .NumAtExitCalls = 3, + .NumAtExitCalls = 2, .AtExitCalls = { /* default AtExitCalls, called in reverse order */ _eglFiniDevice, /* always called last */ - _eglUnloadDrivers, _eglFiniDisplay, }, +#if USE_LIBGLVND .ClientOnlyExtensionString = +#else + .ClientExtensionString = +#endif "EGL_EXT_client_extensions" " EGL_EXT_device_base" " EGL_EXT_device_enumeration" " EGL_EXT_device_query" " EGL_EXT_platform_base" " EGL_KHR_client_get_all_proc_addresses" - " EGL_KHR_debug", + " EGL_KHR_debug" +#if USE_LIBGLVND + , .PlatformExtensionString = +#else + " " +#endif + + "EGL_EXT_platform_device" #ifdef HAVE_WAYLAND_PLATFORM " EGL_EXT_platform_wayland" + " EGL_KHR_platform_wayland" #endif #ifdef HAVE_X11_PLATFORM " EGL_EXT_platform_x11" + " EGL_KHR_platform_x11" +#endif +#ifdef HAVE_XCB_PLATFORM + " EGL_MESA_platform_xcb" #endif #ifdef HAVE_DRM_PLATFORM " EGL_MESA_platform_gbm" + " EGL_KHR_platform_gbm" #endif -#ifdef HAVE_SURFACELESS_PLATFORM " EGL_MESA_platform_surfaceless" -#endif - " EGL_EXT_platform_device" "", - .ClientExtensionString = NULL, - .debugCallback = NULL, .debugTypesEnabled = _EGL_DEBUG_BIT_CRITICAL | _EGL_DEBUG_BIT_ERROR, }; @@ -123,40 +133,6 @@ _eglAddAtExitCall(void (*func)(void)) } } -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) { diff --git a/lib/mesa/src/egl/main/eglglobals.h b/lib/mesa/src/egl/main/eglglobals.h index 63bea4ebc..fc3b6bd62 100644 --- a/lib/mesa/src/egl/main/eglglobals.h +++ b/lib/mesa/src/egl/main/eglglobals.h @@ -61,13 +61,15 @@ struct _egl_global /* * 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. + * strings, one for platform extensions, and one for everything else. + * For a non-glvnd build create a concatenated one. */ +#if USE_LIBGLVND const char *ClientOnlyExtensionString; const char *PlatformExtensionString; - char *ClientExtensionString; +#else + const char *ClientExtensionString; +#endif EGLDEBUGPROCKHR debugCallback; unsigned int debugTypesEnabled; @@ -86,9 +88,6 @@ 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. */ diff --git a/lib/mesa/src/egl/main/eglglvnd.c b/lib/mesa/src/egl/main/eglglvnd.c index 6b984ed6c..81fdb4508 100644 --- a/lib/mesa/src/egl/main/eglglvnd.c +++ b/lib/mesa/src/egl/main/eglglvnd.c @@ -24,15 +24,8 @@ __eglGLVNDQueryString(EGLDisplay dpy, EGLenum 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; - } + if (name == __EGL_VENDOR_STRING_PLATFORM_EXTENSIONS) + return _eglGlobal.PlatformExtensionString; return NULL; } diff --git a/lib/mesa/src/egl/main/eglimage.c b/lib/mesa/src/egl/main/eglimage.c index 9df6b6511..64bf7f2bf 100644 --- a/lib/mesa/src/egl/main/eglimage.c +++ b/lib/mesa/src/egl/main/eglimage.c @@ -58,6 +58,12 @@ _eglParseKHRImageAttribs(_EGLImageAttribs *attrs, _EGLDisplay *disp, attrs->GLTextureZOffset = val; break; + case EGL_PROTECTED_CONTENT_EXT: + if (!disp->Extensions.EXT_protected_surface) + return EGL_BAD_PARAMETER; + + attrs->ProtectedContent = val; + break; default: return EGL_BAD_PARAMETER; } diff --git a/lib/mesa/src/egl/main/eglimage.h b/lib/mesa/src/egl/main/eglimage.h index 6d2e7ba8a..9837f05da 100644 --- a/lib/mesa/src/egl/main/eglimage.h +++ b/lib/mesa/src/egl/main/eglimage.h @@ -79,6 +79,9 @@ struct _egl_image_attribs struct _egl_image_attrib_int DMABufSampleRangeHint; struct _egl_image_attrib_int DMABufChromaHorizontalSiting; struct _egl_image_attrib_int DMABufChromaVerticalSiting; + + /* EGL_EXT_protected_surface */ + EGLBoolean ProtectedContent; }; /** diff --git a/lib/mesa/src/egl/main/eglsurface.c b/lib/mesa/src/egl/main/eglsurface.c index 22257391d..aee521789 100644 --- a/lib/mesa/src/egl/main/eglsurface.c +++ b/lib/mesa/src/egl/main/eglsurface.c @@ -303,6 +303,14 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) } surf->MipmapTexture = !!val; break; + case EGL_PROTECTED_CONTENT_EXT: + if (!disp->Extensions.EXT_protected_surface) { + err = EGL_BAD_ATTRIBUTE; + break; + } + surf->ProtectedContent = val; + break; + /* no pixmap surface specific attributes */ default: err = EGL_BAD_ATTRIBUTE; @@ -383,6 +391,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, surf->VGAlphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; surf->VGColorspace = EGL_VG_COLORSPACE_sRGB; surf->GLColorspace = EGL_GL_COLORSPACE_LINEAR_KHR; + surf->ProtectedContent = EGL_FALSE; surf->MipmapLevel = 0; surf->MultisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT; @@ -429,7 +438,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, EGLBoolean -_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, +_eglQuerySurface(_EGLDisplay *disp, _EGLSurface *surface, EGLint attribute, EGLint *value) { switch (attribute) { @@ -534,7 +543,7 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); _EGLContext *ctx = _eglGetCurrentContext(); - EGLint result = drv->API.QueryBufferAge(drv, disp, surface); + EGLint result = disp->Driver->QueryBufferAge(disp, surface); /* error happened */ if (result < 0) return EGL_FALSE; @@ -581,6 +590,11 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT: *value = surface->HdrMetadata.max_fall; break; + case EGL_PROTECTED_CONTENT_EXT: + if (!disp->Extensions.EXT_protected_surface) + return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); + *value = surface->ProtectedContent; + break; default: return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); } @@ -593,7 +607,7 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, * Default fallback routine - drivers might override this. */ EGLBoolean -_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, +_eglSurfaceAttrib(_EGLDisplay *disp, _EGLSurface *surface, EGLint attribute, EGLint value) { EGLint confval; @@ -718,8 +732,7 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, EGLBoolean -_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, - EGLint buffer) +_eglBindTexImage(_EGLDisplay *disp, _EGLSurface *surface, EGLint buffer) { EGLint texture_type = EGL_PBUFFER_BIT; @@ -748,8 +761,7 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, } EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint buffer) +_eglReleaseTexImage(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer) { /* Just do basic error checking and return success/fail. * Drivers must implement the real stuff. @@ -783,14 +795,6 @@ _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, return EGL_TRUE; } - -EGLBoolean -_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint interval) -{ - return EGL_TRUE; -} - EGLBoolean _eglSurfaceHasMutableRenderBuffer(_EGLSurface *surf) { diff --git a/lib/mesa/src/egl/main/eglsurface.h b/lib/mesa/src/egl/main/eglsurface.h index 903957a6e..7f419cbf7 100644 --- a/lib/mesa/src/egl/main/eglsurface.h +++ b/lib/mesa/src/egl/main/eglsurface.h @@ -169,6 +169,8 @@ struct _egl_surface EGLBoolean PostSubBufferSupportedNV; + EGLBoolean ProtectedContent; + struct _egl_hdr_metadata HdrMetadata; void *NativeSurface; @@ -182,22 +184,19 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, extern EGLBoolean -_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint attribute, EGLint *value); +_eglQuerySurface(_EGLDisplay *disp, _EGLSurface *surf, EGLint attribute, EGLint *value); extern EGLBoolean -_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint attribute, EGLint value); +_eglSurfaceAttrib(_EGLDisplay *disp, _EGLSurface *surf, EGLint attribute, EGLint value); extern EGLBoolean -_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer); +_eglBindTexImage(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer); extern EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer); - +_eglReleaseTexImage(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer); -extern EGLBoolean -_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint interval); extern EGLBoolean _eglSurfaceHasMutableRenderBuffer(_EGLSurface *surf); diff --git a/lib/mesa/src/egl/main/eglsync.c b/lib/mesa/src/egl/main/eglsync.c index d3c0cf4aa..ccad83bb2 100644 --- a/lib/mesa/src/egl/main/eglsync.c +++ b/lib/mesa/src/egl/main/eglsync.c @@ -120,7 +120,7 @@ _eglInitSync(_EGLSync *sync, _EGLDisplay *disp, EGLenum type, EGLBoolean -_eglGetSyncAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, +_eglGetSyncAttrib(_EGLDisplay *disp, _EGLSync *sync, EGLint attribute, EGLAttrib *value) { switch (attribute) { @@ -134,7 +134,7 @@ _eglGetSyncAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, sync->Type == EGL_SYNC_CL_EVENT_KHR || sync->Type == EGL_SYNC_REUSABLE_KHR || sync->Type == EGL_SYNC_NATIVE_FENCE_ANDROID)) - drv->API.ClientWaitSyncKHR(drv, disp, sync, 0, 0); + disp->Driver->ClientWaitSyncKHR(disp, sync, 0, 0); *value = sync->SyncStatus; break; diff --git a/lib/mesa/src/egl/main/eglsync.h b/lib/mesa/src/egl/main/eglsync.h index fdb122beb..4fdf15f23 100644 --- a/lib/mesa/src/egl/main/eglsync.h +++ b/lib/mesa/src/egl/main/eglsync.h @@ -58,7 +58,7 @@ _eglInitSync(_EGLSync *sync, _EGLDisplay *disp, EGLenum type, extern EGLBoolean -_eglGetSyncAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, +_eglGetSyncAttrib(_EGLDisplay *disp, _EGLSync *sync, EGLint attribute, EGLAttrib *value); diff --git a/lib/mesa/src/egl/main/egltypedefs.h b/lib/mesa/src/egl/main/egltypedefs.h index 4809cf5d7..935fd023b 100644 --- a/lib/mesa/src/egl/main/egltypedefs.h +++ b/lib/mesa/src/egl/main/egltypedefs.h @@ -40,8 +40,6 @@ extern "C" { #endif -typedef struct _egl_api _EGLAPI; - typedef struct _egl_array _EGLArray; typedef struct _egl_config _EGLConfig; diff --git a/lib/mesa/src/egl/wayland/wayland-drm/wayland-drm.c b/lib/mesa/src/egl/wayland/wayland-drm/wayland-drm.c index 51cdd2cb8..29558ea91 100644 --- a/lib/mesa/src/egl/wayland/wayland-drm/wayland-drm.c +++ b/lib/mesa/src/egl/wayland/wayland-drm/wayland-drm.c @@ -180,10 +180,11 @@ drm_authenticate(struct wl_client *client, { struct wl_drm *drm = wl_resource_get_user_data(resource); - if (drm->callbacks.authenticate(drm->user_data, id) < 0) + if (!drm->callbacks.authenticate || + drm->callbacks.authenticate(drm->user_data, id) < 0) wl_resource_post_error(resource, WL_DRM_ERROR_AUTHENTICATE_FAIL, - "authenicate failed"); + "authenticate failed"); else wl_resource_post_event(resource, WL_DRM_AUTHENTICATED); } |