[Mesa-stable] [PATCH] egl/wayland: Set width/height of EGLSurface at creation
Chad Versace
chadversary at chromium.org
Tue Aug 7 18:07:10 UTC 2018
Fixes dEQP-EGL.functional.color_clears.single_context.gles2.rgb565_window.
After initializing _EGLSurface::Width and ::Height to 0, Mesa did not
update the width and height again until the DRI driver fetched its
buffers. This produced weird behavior:
* Immediately after surface creation, eglQuerySurface(EGL_WIDTH)
would return 0.
* At some non-deterministic time between surface creation and before
the first eglSwapBuffers, likely triggered by a GL call that coerced
the driver to call DRI*::getBuffers, eglQuerySurface(EGL_WIDTH)
would return the actual width.
The dEQP test assertion-failed because eglQuerySurface(EGL_WIDTH)
returned 0 even though the native window had non-zero extent.
Cc: mesa-stable at lists.freedesktop.org
---
src/egl/drivers/dri2/platform_wayland.c | 26 +++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index dca099500a8..eda17cda903 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -224,6 +224,15 @@ get_wl_surface_proxy(struct wl_egl_window *window)
return wl_proxy_create_wrapper(window->surface);
}
+static void
+update_size(struct dri2_egl_surface *dri2_surf)
+{
+ dri2_surf->base.Width = dri2_surf->wl_win->width;
+ dri2_surf->base.Height = dri2_surf->wl_win->height;
+ dri2_surf->dx = dri2_surf->wl_win->dx;
+ dri2_surf->dy = dri2_surf->wl_win->dy;
+}
+
/**
* Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
*/
@@ -306,6 +315,11 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
if (dri2_dpy->flush)
dri2_surf->wl_win->resize_callback = resize_callback;
+ /* Set width so eglQuerySurface(EGL_WIDTH) will return non-zero. Same for
+ * height.
+ */
+ update_size(dri2_surf);
+
if (dri2_dpy->image_driver)
createNewDrawable = dri2_dpy->image_driver->createNewDrawable;
else if (dri2_dpy->dri2)
@@ -581,11 +595,7 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
dri2_surf->base.Height != dri2_surf->wl_win->height) {
dri2_wl_release_buffers(dri2_surf);
-
- dri2_surf->base.Width = dri2_surf->wl_win->width;
- dri2_surf->base.Height = dri2_surf->wl_win->height;
- dri2_surf->dx = dri2_surf->wl_win->dx;
- dri2_surf->dy = dri2_surf->wl_win->dy;
+ update_size(dri2_surf);
}
if (get_back_bo(dri2_surf) < 0) {
@@ -1636,11 +1646,7 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf)
dri2_surf->base.Height != dri2_surf->wl_win->height) {
dri2_wl_release_buffers(dri2_surf);
-
- dri2_surf->base.Width = dri2_surf->wl_win->width;
- dri2_surf->base.Height = dri2_surf->wl_win->height;
- dri2_surf->dx = dri2_surf->wl_win->dx;
- dri2_surf->dy = dri2_surf->wl_win->dy;
+ update_size(dri2_surf);
dri2_surf->current = NULL;
}
--
2.18.0.597.ga71716f1ad-goog
More information about the mesa-stable
mailing list