From 57667b4bfd0726a69e7ee057fb8c280e35f35a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Mon, 19 Dec 2016 11:47:47 +0200 Subject: [PATCH] egl: syncronize surface information with driver RFC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes sure that the values we return are in sync what the driver currently has. Together with dEQP change bug #98327 this fixes following test: dEQP-EGL.functional.resize.surface_size.grow v2: implement callback also for dri3 v3: make optional for dri2 drivers, only x11 dri2 seems to require this right now Signed-off-by: Tapani Pälli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98327 --- src/egl/drivers/dri2/egl_dri2.c | 12 ++++++++++++ src/egl/drivers/dri2/egl_dri2.h | 2 ++ src/egl/drivers/dri2/platform_x11.c | 31 +++++++++++++++++++++++++++++++ src/egl/main/eglapi.h | 2 ++ src/egl/main/eglfallbacks.c | 1 + src/egl/main/eglsurface.c | 3 +++ 6 files changed, 51 insertions(+) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 52fbdff..112c6ad 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1264,6 +1264,17 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) return dri2_dpy->vtbl->destroy_surface(drv, dpy, surf); } +static EGLBoolean +dri2_sync_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); + + if (dri2_dpy->vtbl->sync_surface) + return dri2_dpy->vtbl->sync_surface(drv, dpy, surf); + + return EGL_TRUE; +} + /** * Called via eglMakeCurrent(), drv->API.MakeCurrent(). */ @@ -2942,6 +2953,7 @@ _eglBuiltInDriverDRI2(const char *args) dri2_drv->base.API.CreatePixmapSurface = dri2_create_pixmap_surface; dri2_drv->base.API.CreatePbufferSurface = dri2_create_pbuffer_surface; dri2_drv->base.API.DestroySurface = dri2_destroy_surface; + dri2_drv->base.API.SyncSurface = dri2_sync_surface; dri2_drv->base.API.GetProcAddress = dri2_get_proc_address; dri2_drv->base.API.WaitClient = dri2_wait_client; dri2_drv->base.API.WaitNative = dri2_wait_native; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index eac58f3..d5cc9b8 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -110,6 +110,8 @@ struct dri2_egl_display_vtbl { EGLBoolean (*destroy_surface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface); + EGLBoolean (*sync_surface)(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surface); EGLBoolean (*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index db7d3b9..4986ec8 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -395,6 +395,36 @@ dri2_x11_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } /** + * Syncronize surface geometry with server + */ +static EGLBoolean +dri2_x11_sync_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); + xcb_get_geometry_cookie_t cookie; + xcb_get_geometry_reply_t *reply; + EGLBoolean result = EGL_TRUE; + xcb_generic_error_t *error; + + cookie = xcb_get_geometry (dri2_dpy->conn, dri2_surf->drawable); + reply = xcb_get_geometry_reply (dri2_dpy->conn, cookie, &error); + if (reply == NULL) + return false; + + if (error != NULL) { + _eglLog(_EGL_WARNING, "error in xcb_get_geometry"); + result = EGL_FALSE; + free(error); + } else { + surf->Width = reply->width; + surf->Height = reply->height; + } + free(reply); + return result; +} + +/** * Process list of buffer received from the server * * Processes the list of buffers received in a reply from the server to either @@ -1124,6 +1154,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = { .create_pixmap_surface = dri2_x11_create_pixmap_surface, .create_pbuffer_surface = dri2_x11_create_pbuffer_surface, .destroy_surface = dri2_x11_destroy_surface, + .sync_surface = dri2_x11_sync_surface, .create_image = dri2_x11_create_image_khr, .swap_interval = dri2_x11_swap_interval, .swap_buffers = dri2_x11_swap_buffers, diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 710c5d8..5152b93 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -94,6 +94,8 @@ struct _egl_api const EGLint *attrib_list); EGLBoolean (*DestroySurface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface); + EGLBoolean (*SyncSurface)(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surface); EGLBoolean (*QuerySurface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint *value); diff --git a/src/egl/main/eglfallbacks.c b/src/egl/main/eglfallbacks.c index 017d337..53b42b8 100644 --- a/src/egl/main/eglfallbacks.c +++ b/src/egl/main/eglfallbacks.c @@ -70,6 +70,7 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.CreatePbufferFromClientBuffer = (void*) _eglReturnFalse; drv->API.DestroySurface = (void*) _eglReturnFalse; + drv->API.SyncSurface = NULL; drv->API.QuerySurface = _eglQuerySurface; drv->API.SurfaceAttrib = _eglSurfaceAttrib; diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 04f42ca..e8f9f40 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -338,6 +338,9 @@ EGLBoolean _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint *value) { + /* Syncronize surface information with the driver. */ + drv->API.SyncSurface(drv, dpy, surface); + switch (attribute) { case EGL_WIDTH: *value = surface->Width; -- 2.9.3