X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fegl%2Fdrivers%2Fdri2%2Fegl_dri2.c;h=0825e1c6541daa142115a9bbed9e7e069edc71c1;hb=d202fd6596c08fb8cbd745192f547d98f3e5ec84;hp=4fc8d40199102ac9338d2c03cdee4c0c1135a3a1;hpb=cc03448008b86e2eacb95eddf27522dd6d6a2f99;p=mesa.git diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 4fc8d401991..0825e1c6541 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -644,7 +644,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, } EGLBoolean -dri2_add_pbuffer_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp) +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 }; @@ -1142,7 +1142,7 @@ dri2_setup_extensions(_EGLDisplay *disp) * 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); @@ -1168,22 +1168,22 @@ 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); + 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."); @@ -1311,10 +1311,10 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf) * 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); @@ -1466,7 +1466,7 @@ dri2_fill_context_attribs(struct dri2_egl_context *dri2_ctx, * 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; @@ -1481,8 +1481,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"); @@ -1641,7 +1639,7 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, * 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); @@ -1695,14 +1693,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 @@ -1756,7 +1754,7 @@ dri2_create_drawable(struct dri2_egl_display *dri2_dpy, * 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); @@ -1768,33 +1766,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); @@ -1807,46 +1795,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); + + _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++; + } } - dri2_destroy_surface(drv, disp, old_dsurf); - dri2_destroy_surface(drv, disp, old_rsurf); - - 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 @@ -1874,51 +1898,48 @@ dri2_surface_get_dri_drawable(_EGLSurface *surf) * Called from eglGetProcAddress() via drv->GetProcAddress(). */ static _EGLProc -dri2_get_proc_address(_EGLDriver *drv, const char *procname) +dri2_get_proc_address(const _EGLDriver *drv, 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); if (!dri2_dpy->vtbl->create_pixmap_surface) return NULL; - return dri2_dpy->vtbl->create_pixmap_surface(drv, disp, conf, native_pixmap, + 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); if (!dri2_dpy->vtbl->create_pbuffer_surface) return NULL; - return dri2_dpy->vtbl->create_pbuffer_surface(drv, disp, conf, attrib_list); + 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); } /** @@ -1958,7 +1979,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); @@ -1967,7 +1988,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. @@ -1980,8 +2001,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); @@ -1992,10 +2012,10 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *disp, if (ctx && surf) dri2_surf_update_fence_fd(ctx, disp, surf); if (dri2_dpy->vtbl->swap_buffers_with_damage) - ret = dri2_dpy->vtbl->swap_buffers_with_damage(drv, disp, surf, + ret = dri2_dpy->vtbl->swap_buffers_with_damage(disp, surf, rects, n_rects); else - 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. @@ -2008,7 +2028,7 @@ 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); @@ -2017,7 +2037,7 @@ dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, if (!dri2_dpy->vtbl->swap_buffers_region) return EGL_FALSE; - ret = dri2_dpy->vtbl->swap_buffers_region(drv, disp, surf, numRects, rects); + 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. @@ -2030,7 +2050,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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint *rects, EGLint n_rects) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -2044,7 +2064,7 @@ 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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint x, EGLint y, EGLint width, EGLint height) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -2054,17 +2074,16 @@ dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, } 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); if (!dri2_dpy->vtbl->copy_buffers) return _eglError(EGL_BAD_NATIVE_PIXMAP, "no support for native pixmaps"); - return dri2_dpy->vtbl->copy_buffers(drv, disp, surf, native_pixmap_target); + 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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); if (!dri2_dpy->vtbl->query_buffer_age) @@ -2073,7 +2092,7 @@ dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } static EGLBoolean -dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) +dri2_wait_client(const _EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); _EGLSurface *surf = ctx->DrawSurface; @@ -2091,7 +2110,7 @@ dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) } static EGLBoolean -dri2_wait_native(_EGLDriver *drv, _EGLDisplay *disp, EGLint engine) +dri2_wait_native(const _EGLDriver *drv, _EGLDisplay *disp, EGLint engine) { (void) drv; (void) disp; @@ -2104,8 +2123,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; @@ -2116,7 +2134,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) { @@ -2148,8 +2166,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; @@ -2160,7 +2177,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) { @@ -2181,7 +2198,7 @@ dri2_release_tex_image(_EGLDriver *drv, } static _EGLImage* -dri2_create_image(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx, +dri2_create_image(const _EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list) { @@ -2451,17 +2468,17 @@ 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, +dri2_create_wayland_buffer_from_image(const _EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -2731,7 +2748,7 @@ dri2_check_dma_buf_format(const _EGLImageAttribs *attrs) } static EGLBoolean -dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp, +dri2_query_dma_buf_formats(const _EGLDriver *drv, _EGLDisplay *disp, EGLint max, EGLint *formats, EGLint *count) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -2762,7 +2779,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(const _EGLDriver *drv, _EGLDisplay *disp, EGLint format, EGLint max, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *count) { @@ -2891,7 +2908,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, return res; } static _EGLImage * -dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, +dri2_create_drm_image_mesa(const _EGLDriver *drv, _EGLDisplay *disp, const EGLint *attr_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -2963,7 +2980,7 @@ 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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *name, EGLint *handle, EGLint *stride) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3009,7 +3026,7 @@ dri2_can_export_dma_buf_image(_EGLDisplay *disp, _EGLImage *img) } static EGLBoolean -dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp, +dri2_export_dma_buf_image_query_mesa(const _EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fourcc, EGLint *nplanes, EGLuint64KHR *modifiers) @@ -3054,7 +3071,7 @@ 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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, int *fds, EGLint *strides, EGLint *offsets) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3102,7 +3119,7 @@ dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *im #endif _EGLImage * -dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, +dri2_create_image_khr(const _EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list) { @@ -3137,7 +3154,7 @@ dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_destroy_image_khr(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *image) +dri2_destroy_image_khr(const _EGLDriver *drv, _EGLDisplay *disp, _EGLImage *image) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img = dri2_egl_image(image); @@ -3206,7 +3223,7 @@ dri2_wl_release_buffer(void *user_data, struct wl_drm_buffer *buffer) } static EGLBoolean -dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, +dri2_bind_wayland_display_wl(const _EGLDriver *drv, _EGLDisplay *disp, struct wl_display *wl_dpy) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3248,7 +3265,7 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, +dri2_unbind_wayland_display_wl(const _EGLDriver *drv, _EGLDisplay *disp, struct wl_display *wl_dpy) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3265,7 +3282,7 @@ dri2_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp, +dri2_query_wayland_buffer_wl(const _EGLDriver *drv, _EGLDisplay *disp, struct wl_resource *buffer_resource, EGLint attribute, EGLint *value) { @@ -3325,7 +3342,7 @@ dri2_egl_unref_sync(struct dri2_egl_display *dri2_dpy, } static _EGLSync * -dri2_create_sync(_EGLDriver *drv, _EGLDisplay *disp, +dri2_create_sync(const _EGLDriver *drv, _EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list) { _EGLContext *ctx = _eglGetCurrentContext(); @@ -3426,7 +3443,7 @@ dri2_create_sync(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_destroy_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) +dri2_destroy_sync(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync); @@ -3455,7 +3472,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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync); @@ -3480,7 +3497,7 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) } static void -dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *disp, +dri2_set_blob_cache_funcs(const _EGLDriver *drv, _EGLDisplay *disp, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get) { @@ -3491,7 +3508,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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, EGLint flags, EGLTime timeout) { _EGLContext *ctx = _eglGetCurrentContext(); @@ -3583,7 +3600,7 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, } static EGLBoolean -dri2_signal_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, +dri2_signal_sync(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync, EGLenum mode) { struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync); @@ -3609,7 +3626,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(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync) { _EGLContext *ctx = _eglGetCurrentContext(); struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -3648,62 +3665,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->Initialize = dri2_initialize; - dri2_drv->Terminate = dri2_terminate; - dri2_drv->CreateContext = dri2_create_context; - dri2_drv->DestroyContext = dri2_destroy_context; - dri2_drv->MakeCurrent = dri2_make_current; - dri2_drv->CreateWindowSurface = dri2_create_window_surface; - dri2_drv->CreatePixmapSurface = dri2_create_pixmap_surface; - dri2_drv->CreatePbufferSurface = dri2_create_pbuffer_surface; - dri2_drv->DestroySurface = dri2_destroy_surface; - dri2_drv->GetProcAddress = dri2_get_proc_address; - dri2_drv->WaitClient = dri2_wait_client; - dri2_drv->WaitNative = dri2_wait_native; - dri2_drv->BindTexImage = dri2_bind_tex_image; - dri2_drv->ReleaseTexImage = dri2_release_tex_image; - dri2_drv->SwapInterval = dri2_swap_interval; - dri2_drv->SwapBuffers = dri2_swap_buffers; - dri2_drv->SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage; - dri2_drv->SwapBuffersRegionNOK = dri2_swap_buffers_region; - dri2_drv->SetDamageRegion = dri2_set_damage_region; - dri2_drv->PostSubBufferNV = dri2_post_sub_buffer; - dri2_drv->CopyBuffers = dri2_copy_buffers, - dri2_drv->QueryBufferAge = dri2_query_buffer_age; - dri2_drv->CreateImageKHR = dri2_create_image; - dri2_drv->DestroyImageKHR = dri2_destroy_image_khr; - dri2_drv->CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image; - dri2_drv->QuerySurface = dri2_query_surface; - dri2_drv->QueryDriverName = dri2_query_driver_name; - dri2_drv->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->CreateDRMImageMESA = dri2_create_drm_image_mesa; - dri2_drv->ExportDRMImageMESA = dri2_export_drm_image_mesa; - dri2_drv->ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa; - dri2_drv->ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa; - dri2_drv->QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats; - dri2_drv->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->BindWaylandDisplayWL = dri2_bind_wayland_display_wl; - dri2_drv->UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl; - dri2_drv->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->GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium; - dri2_drv->CreateSyncKHR = dri2_create_sync; - dri2_drv->ClientWaitSyncKHR = dri2_client_wait_sync; - dri2_drv->SignalSyncKHR = dri2_signal_sync; - dri2_drv->WaitSyncKHR = dri2_server_wait_sync; - dri2_drv->DestroySyncKHR = dri2_destroy_sync; - dri2_drv->GLInteropQueryDeviceInfo = dri2_interop_query_device_info; - dri2_drv->GLInteropExportObject = dri2_interop_export_object; - dri2_drv->DupNativeFenceFDANDROID = dri2_dup_native_fence_fd; - dri2_drv->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, +};