[Mesa-dev] [PATCH v3 06/10] egl: add dri2_surface_update_age() helper (v3)

Gwan-gyeong Mun elongbug at gmail.com
Tue Oct 24 21:45:00 UTC 2017


To share common update buffer age code.
This updates old buffer's age and sets current back buffer's age to 1.

In preparation to adding of new platform which uses this helper.

v2:
 - Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
      same patch.
 - Fixes from Rob's review:
   Remove unneeded ifdef block

v3: Fixes from Emil and Gurchetan's review
  - Follow the naming convention which prevents too verbose name of functions.
    a) use a dri2_surface_$action_$object naming convention
    b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".

Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/egl/drivers/dri2/egl_dri2.c         | 16 ++++++++++++++++
 src/egl/drivers/dri2/egl_dri2.h         |  3 +++
 src/egl/drivers/dri2/platform_android.c | 11 +----------
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index a504978fda..d381e52e86 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1126,6 +1126,22 @@ dri2_surface_set_back_buffer(_EGLSurface *surf, void *buffer)
    }
 }
 
+void
+dri2_surface_update_age(_EGLSurface *surf)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+      if (dri2_surf->color_buffers[i].age > 0)
+         dri2_surf->color_buffers[i].age++;
+   }
+
+   /* "XXX: we don't use get_back_bo() since it causes regressions in
+    * several dEQP tests.
+    */
+   if (dri2_surf->back)
+      dri2_surf->back->age = 1;
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 4c01959324..58f8082509 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -457,6 +457,9 @@ dri2_surface_fixup(_EGLSurface *surf, int width, int height);
 void
 dri2_surface_set_back_buffer(_EGLSurface *surf, void *buffer);
 
+void
+dri2_surface_update_age(_EGLSurface *surf);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
         _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 559672ff21..45af871555 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -567,16 +567,7 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
    if (dri2_surf->base.Type != EGL_WINDOW_BIT)
       return EGL_TRUE;
 
-   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
-      if (dri2_surf->color_buffers[i].age > 0)
-         dri2_surf->color_buffers[i].age++;
-   }
-
-   /* "XXX: we don't use get_back_bo() since it causes regressions in
-    * several dEQP tests.
-    */
-   if (dri2_surf->back)
-      dri2_surf->back->age = 1;
+   dri2_surface_update_age(draw);
 
    dri2_flush_drawable_for_swapbuffers(disp, draw);
 
-- 
2.14.2



More information about the mesa-dev mailing list