[Mesa-dev] [PATCH] gbm/drm: Pick the oldest available buffer in get_back_bo

Derek Foreman derekf at osg.samsung.com
Wed Nov 9 20:57:22 UTC 2016


We find the oldest backbuffer we can, on the grounds that clients are
only going to keep a fixed history queue, so this gives them the
greatest chance of being able to use that queue via making sure
the age is ~always less than the depth of the swapchain

Reviewed-by: Daniel Stone <daniels at collabora.com>
Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 src/egl/drivers/dri2/platform_drm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 2099314..f812ab5 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -215,13 +215,15 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf->base.Resource.Display);
    struct gbm_dri_surface *surf = dri2_surf->gbm_surf;
+   int age = 0;
    unsigned i;
 
    if (dri2_surf->back == NULL) {
       for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
-	 if (!dri2_surf->color_buffers[i].locked) {
+	 if (!dri2_surf->color_buffers[i].locked &&
+	      dri2_surf->color_buffers[i].age >= age) {
 	    dri2_surf->back = &dri2_surf->color_buffers[i];
-	    break;
+	    age = dri2_surf->color_buffers[i].age;
 	 }
       }
    }
-- 
2.10.2



More information about the mesa-dev mailing list