Mesa (staging/22.0): egl/wayland: Reset buffer age when destroying buffers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 8 05:53:11 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 2ce020120ab2efbdbb5c79170020f59c784e8984
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ce020120ab2efbdbb5c79170020f59c784e8984

Author: Daniel Stone <daniels at collabora.com>
Date:   Fri Feb  4 10:42:19 2022 +0000

egl/wayland: Reset buffer age when destroying buffers

A buffer age of 0 means that the buffer is uninitialised or has unknown
content. We rely on the buffer age initially being 0 through zalloc when
the surface is first created; when they are first used for a swap, we
set their age to 1, and then we increment the age of every buffer in the
chain with a non-zero age when we swap.

Now that we can release buffers, both through dmabuf-feedback as well as
detecting when we're using a deeper swapchain than the compositor needs,
make sure to reset their age as they are released. Without doing this,
the age will stay as it was before it was released and be incremented,
returning the wrong age to the user the first time a previously-released
buffer slot has been reused.

Signed-off-by: Daniel Stone <daniels at collabora.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5977
Fixes: 22d796feb828 ("egl/wayland: break double/tripple buffering feedback loops")
Fixes: b5848b2dac14 ("egl/wayland: use surface dma-buf feedback to allocate surface buffers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14873>
(cherry picked from commit 3da8300562efeeeeea6c80bce98c830b0da28622)

---

 .pick_status.json                       | 2 +-
 src/egl/drivers/dri2/platform_wayland.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index d89300e1d7e..d1e6a9bc3dd 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -157,7 +157,7 @@
         "description": "egl/wayland: Reset buffer age when destroying buffers",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "22d796feb828daad7c8d600adf271e19a82d67c8"
     },
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 93dac2fd09d..5ff83cce08a 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -256,6 +256,7 @@ wl_buffer_release(void *data, struct wl_buffer *buffer)
       wl_buffer_destroy(buffer);
       dri2_surf->color_buffers[i].wl_release = false;
       dri2_surf->color_buffers[i].wl_buffer = NULL;
+      dri2_surf->color_buffers[i].age = 0;
    }
 
    dri2_surf->color_buffers[i].locked = false;
@@ -863,6 +864,7 @@ dri2_wl_release_buffers(struct dri2_egl_surface *dri2_surf)
       dri2_surf->color_buffers[i].dri_image = NULL;
       dri2_surf->color_buffers[i].linear_copy = NULL;
       dri2_surf->color_buffers[i].data = NULL;
+      dri2_surf->color_buffers[i].age = 0;
    }
 
    if (dri2_dpy->dri2)
@@ -1145,6 +1147,7 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
          dri2_surf->color_buffers[i].wl_buffer = NULL;
          dri2_surf->color_buffers[i].dri_image = NULL;
          dri2_surf->color_buffers[i].linear_copy = NULL;
+         dri2_surf->color_buffers[i].age = 0;
       }
    }
 
@@ -2342,6 +2345,7 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf)
                 dri2_surf->color_buffers[i].data_size);
          dri2_surf->color_buffers[i].wl_buffer = NULL;
          dri2_surf->color_buffers[i].data = NULL;
+         dri2_surf->color_buffers[i].age = 0;
       }
    }
 



More information about the mesa-commit mailing list