Mesa (staging/21.3): egl/wayland: Properly clear stale buffers on resize

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 18 20:57:13 UTC 2021


Module: Mesa
Branch: staging/21.3
Commit: 05020779f53344dda61ce46cf838832e0c06dc6c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=05020779f53344dda61ce46cf838832e0c06dc6c

Author: Derek Foreman <derek.foreman at collabora.com>
Date:   Fri Oct  8 08:55:44 2021 -0500

egl/wayland: Properly clear stale buffers on resize

The following chain of events results in an incorrectly sized buffer
persisting beyond its useful lifetime, and causing visual artifacts.

buffer is attached at size A
window is resized to size B
rendering takes place for size B
window is resized back to size A
swapbuffers with damage is called

In this scenario, update_buffers fails to recognize that the surface it's
about to commit is a different size than it has rendered. The
attached_width and attached_height are set incorrectly, and periodic
flickering is observed.

Instead, we set a boolean flag at time of resize and use this at the time
we latch the window dimensions as surface dimensions to decide whether to
discard stale buffers.

Signed-off-by: Derek Foreman <derek.foreman at collabora.com>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13270>
(cherry picked from commit 28d12716e8ff04b50a443ecaa6c7b519117303a5)

---

 .pick_status.json                       | 2 +-
 src/egl/drivers/dri2/egl_dri2.h         | 1 +
 src/egl/drivers/dri2/platform_wayland.c | 9 +++++----
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 280c13132e7..7e0a6c2cf00 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -391,7 +391,7 @@
         "description": "egl/wayland: Properly clear stale buffers on resize",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 98fdc1e2e2d..9acc846687b 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -302,6 +302,7 @@ struct dri2_egl_surface
    struct wl_drm         *wl_drm_wrapper;
    struct wl_callback    *throttle_callback;
    int                    format;
+   bool                   resized;
 #endif
 
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index e37579995e5..e1f445e1de3 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -279,6 +279,8 @@ resize_callback(struct wl_egl_window *wl_win, void *data)
        dri2_surf->base.Height == wl_win->height)
       return;
 
+   dri2_surf->resized = true;
+
    /* 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.
@@ -714,10 +716,9 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
       dri2_surf->dy = dri2_surf->wl_win->dy;
    }
 
-   if (dri2_surf->wl_win &&
-       (dri2_surf->base.Width != dri2_surf->wl_win->attached_width ||
-        dri2_surf->base.Height != dri2_surf->wl_win->attached_height)) {
-      dri2_wl_release_buffers(dri2_surf);
+   if (dri2_surf->resized) {
+       dri2_wl_release_buffers(dri2_surf);
+       dri2_surf->resized = false;
    }
 
    if (get_back_bo(dri2_surf) < 0) {



More information about the mesa-commit mailing list