diff options
author | Derek Foreman <derek.foreman@collabora.com> | 2021-10-08 08:55:44 -0500 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2021-10-20 20:40:58 +0100 |
commit | 3c0c2465f3557d864971a807a54b94df9051e7a2 (patch) | |
tree | 09a76033becbd4f1d4e5ac4aa28657c477da8c4a | |
parent | 118131c071305fb5a702d8cba5bf100577aebc75 (diff) |
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@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13270>
(cherry picked from commit 28d12716e8ff04b50a443ecaa6c7b519117303a5)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 1 | ||||
-rw-r--r-- | 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 e2a9eff71ef..4b4cded0d8b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -994,7 +994,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) { |