[Mesa-dev] [PATCH 05/25] egl/dri2: Dispatch eglSwapInterval by display, not driver

Ian Romanick idr at freedesktop.org
Tue Feb 11 18:39:46 PST 2014


On 02/09/2014 01:37 PM, Chad Versace wrote:
> Add dri2_egl_display_vtbl::swap_interval, set it for each platform, and
> let egl_dri2 dispatch eglSwapInterval to that.
> 
> This prepares for the EGL platform extensions.

Same formatting comment as on patch 2.

> 
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
>  src/egl/drivers/dri2/egl_dri2.c           |  9 ++++++++
>  src/egl/drivers/dri2/egl_dri2.h           |  4 ++++
>  src/egl/drivers/dri2/egl_dri2_fallbacks.h | 34 +++++++++++++++++++++++++++++++
>  src/egl/drivers/dri2/platform_android.c   |  2 ++
>  src/egl/drivers/dri2/platform_drm.c       |  2 ++
>  src/egl/drivers/dri2/platform_wayland.c   |  3 ++-
>  src/egl/drivers/dri2/platform_x11.c       |  4 +++-
>  7 files changed, 56 insertions(+), 2 deletions(-)
>  create mode 100644 src/egl/drivers/dri2/egl_dri2_fallbacks.h
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 308b49b..0e3a4ea 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -1013,6 +1013,14 @@ dri2_get_proc_address(_EGLDriver *drv, const char *procname)
>  }
>  
>  static EGLBoolean
> +dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
> +                   EGLint interval)
> +{
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
> +   return dri2_dpy->vtbl->swap_interval(drv, dpy, surf, interval);
> +}
> +
> +static EGLBoolean
>  dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
>  {
>     struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> @@ -2035,6 +2043,7 @@ _eglBuiltInDriverDRI2(const char *args)
>     dri2_drv->base.API.WaitNative = dri2_wait_native;
>     dri2_drv->base.API.BindTexImage = dri2_bind_tex_image;
>     dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
> +   dri2_drv->base.API.SwapInterval = dri2_swap_interval;
>     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 3411883..a521c7e 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -87,6 +87,10 @@ struct dri2_egl_driver
>  struct dri2_egl_display_vtbl {
>     int
>     (*authenticate)(_EGLDisplay *disp, uint32_t id);
> +
> +   EGLBoolean
> +   (*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
> +                    EGLint interval);
>  };
>  
>  struct dri2_egl_display
> diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
> new file mode 100644
> index 0000000..e09a3b8
> --- /dev/null
> +++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
> @@ -0,0 +1,34 @@
> +/*
> + * Copyright 2014 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +#pragma once
> +
> +#include "egltypedefs.h"
> +
> +static inline EGLBoolean
> +dri2_fallback_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
> +                            _EGLSurface *surf, EGLint interval)
> +{
> +   return EGL_FALSE;
> +}
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 73aff4f..b03cca3 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -36,6 +36,7 @@
>  
>  #include "loader.h"
>  #include "egl_dri2.h"
> +#include "egl_dri2_fallbacks.h"
>  #include "gralloc_drm.h"
>  
>  static int
> @@ -654,6 +655,7 @@ droid_log(EGLint level, const char *msg)
>  
>  static struct dri2_egl_display_vtbl droid_display_vtbl = {
>     .authenticate = NULL,
> +   .swap_interval = dri2_fallback_swap_interval,
>  };
>  
>  EGLBoolean
> diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
> index a387417..8544bf5 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -36,6 +36,7 @@
>  #include <unistd.h>
>  
>  #include "egl_dri2.h"
> +#include "egl_dri2_fallbacks.h"
>  #include "loader.h"
>  
>  static struct gbm_bo *
> @@ -442,6 +443,7 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
>  
>  static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
>     .authenticate = dri2_drm_authenticate,
> +   .swap_interval = dri2_fallback_swap_interval,
>  };
>  
>  EGLBoolean
> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
> index f710efa..e5f9c9a 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -36,6 +36,7 @@
>  #include <xf86drm.h>
>  
>  #include "egl_dri2.h"
> +#include "egl_dri2_fallbacks.h"
>  #include "loader.h"
>  
>  #include <wayland-client.h>
> @@ -957,6 +958,7 @@ dri2_wl_setup_swap_interval(struct dri2_egl_display *dri2_dpy)
>  
>  static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
>     .authenticate = dri2_wl_authenticate,
> +   .swap_interval = dri2_wl_swap_interval,
>  };
>  
>  EGLBoolean
> @@ -977,7 +979,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
>     drv->API.DestroySurface = dri2_wl_destroy_surface;
>     drv->API.SwapBuffers = dri2_wl_swap_buffers;
>     drv->API.SwapBuffersWithDamageEXT = dri2_wl_swap_buffers_with_damage;
> -   drv->API.SwapInterval = dri2_wl_swap_interval;
>     drv->API.Terminate = dri2_wl_terminate;
>     drv->API.QueryBufferAge = dri2_wl_query_buffer_age;
>  
> diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
> index ea871fd..9bc2afb 100644
> --- a/src/egl/drivers/dri2/platform_x11.c
> +++ b/src/egl/drivers/dri2/platform_x11.c
> @@ -40,6 +40,7 @@
>  #include <sys/stat.h>
>  
>  #include "egl_dri2.h"
> +#include "egl_dri2_fallbacks.h"
>  
>  static EGLBoolean
>  dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
> @@ -993,10 +994,12 @@ dri2_x11_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
>  
>  static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = {
>     .authenticate = NULL,
> +   .swap_interval = dri2_fallback_swap_interval,
>  };
>  
>  static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
>     .authenticate = dri2_x11_authenticate,
> +   .swap_interval = dri2_x11_swap_interval,
>  };
>  
>  static EGLBoolean
> @@ -1139,7 +1142,6 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
>     drv->API.CreateImageKHR = dri2_x11_create_image_khr;
>     drv->API.SwapBuffersRegionNOK = dri2_x11_swap_buffers_region;
>     drv->API.PostSubBufferNV = dri2_x11_post_sub_buffer;
> -   drv->API.SwapInterval = dri2_x11_swap_interval;
>  
>     dri2_dpy = calloc(1, sizeof *dri2_dpy);
>     if (!dri2_dpy)
> 



More information about the mesa-dev mailing list