[Mesa-dev] [PATCH 12/25] egl/dri2: Dispatch API.QueryBufferAge by display, not driver

Chad Versace chad.versace at linux.intel.com
Sun Feb 9 13:37:48 PST 2014


Add dri2_egl_display_vtbl::query_buffer_age, set it for each
platform, and let egl_dri2 dispatch API.QueryBufferAge to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c           | 8 ++++++++
 src/egl/drivers/dri2/egl_dri2.h           | 2 ++
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 7 +++++++
 src/egl/drivers/dri2/platform_android.c   | 1 +
 src/egl/drivers/dri2/platform_drm.c       | 2 +-
 src/egl/drivers/dri2/platform_wayland.c   | 2 +-
 src/egl/drivers/dri2/platform_x11.c       | 2 ++
 7 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 3526aa7..f6fd94b 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1072,6 +1072,13 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *dpy,
                                                    rects, n_rects);
 }
 
+static EGLint
+dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->query_buffer_age(drv, dpy, surf);
+}
+
 static EGLBoolean
 dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
 {
@@ -2102,6 +2109,7 @@ _eglBuiltInDriverDRI2(const char *args)
    dri2_drv->base.API.SwapInterval = dri2_swap_interval;
    dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
    dri2_drv->base.API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
+   dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
    dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
    dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index fe779df..2adb862 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -116,6 +116,8 @@ struct dri2_egl_display_vtbl {
    (*swap_buffers_with_damage)(_EGLDriver *drv, _EGLDisplay *dpy,
                                _EGLSurface *surface,
                                const EGLint *rects, EGLint n_rects);
+   EGLint
+   (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index a416157..f903998 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -57,3 +57,10 @@ dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *dpy,
 {
    return EGL_FALSE;
 }
+
+static inline EGLint
+dri2_fallback_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy,
+                               _EGLSurface *surf)
+{
+   return 0;
+}
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index eb5706c..d60e54e 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -648,6 +648,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
    .swap_interval = dri2_fallback_swap_interval,
    .swap_buffers = droid_swap_buffers,
    .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index b380c42..45c856b 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -450,6 +450,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
    .swap_interval = dri2_fallback_swap_interval,
    .swap_buffers = dri2_drm_swap_buffers,
    .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .query_buffer_age = dri2_drm_query_buffer_age,
 };
 
 EGLBoolean
@@ -545,7 +546,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
    }
 
    drv->API.CreateImageKHR = dri2_drm_create_image_khr;
-   drv->API.QueryBufferAge = dri2_drm_query_buffer_age;
 
    disp->Extensions.EXT_buffer_age = EGL_TRUE;
 
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index e23c117..c2b39d6 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -965,6 +965,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
    .swap_interval = dri2_wl_swap_interval,
    .swap_buffers = dri2_wl_swap_buffers,
    .swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
+   .query_buffer_age = dri2_wl_query_buffer_age,
 };
 
 EGLBoolean
@@ -982,7 +983,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
    loader_set_logger(_eglLog);
 
    drv->API.Terminate = dri2_wl_terminate;
-   drv->API.QueryBufferAge = dri2_wl_query_buffer_age;
 
    drv->API.CreateWaylandBufferFromImageWL =
       dri2_wl_create_wayland_buffer_from_image_wl;
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 6133c8b..2427d6a 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1000,6 +1000,7 @@ static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = {
    .destroy_surface = dri2_x11_destroy_surface,
    .swap_interval = dri2_fallback_swap_interval,
    .swap_buffers = dri2_x11_swap_buffers,
+   .query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
 static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
@@ -1011,6 +1012,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
    .swap_interval = dri2_x11_swap_interval,
    .swap_buffers = dri2_x11_swap_buffers,
    .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
 static EGLBoolean
-- 
1.8.5.3



More information about the mesa-dev mailing list