Re: [Mesa-dev] [PATCH v3] wayland: Add support for eglSwapInterval

2013-09-16 Thread Pekka Paalanen
On Fri, 13 Sep 2013 17:04:38 +0100
Neil Roberts n...@linux.intel.com wrote:

 Here is another version of the patch which brings back the blocking
 when there are no buffers available to cope with the situation where
 the compositor isn't immediately releasing buffers. Maybe we could
 leave the decision about whether to increase the buffer count to 4 as
 a separate patch.

Hi Neil,

yes, I think this approach is how it should work. There are a few
details commented below.

 
 -- 8 --
 
 The Wayland EGL platform now respects the eglSwapInterval value. The value is
 clamped to either 0 or 1 because it is difficult (and probably not useful) to
 sync to more than 1 redraw.
 
 The main change is that if the swap interval is 0 then instead of installing a
 frame callback it will just call the display sync method and throttle itself
 to that. When the application is not running fullscreen the compositor is
 likely to release the previous buffer immediately so this gives the
 application the best chance of reusing the buffer.
 
 If there are no buffers available then instead of returning with an error,
 get_back_bo will now block until a buffer becomes available. This is necessary
 if the compositor is not releasing buffers immediately. As there are only
 three buffers, this could actually mean that the client ends up throttled to
 the vblank anyway because Weston can hold on to three buffers when the client
 is fullscreen. We could fix this by increasing the buffer count to 4 or
 changing Weston and KMS to allow cancelling a pending buffer swap, but for now
 this patch ignores that problem.

A good explanation, cool.

 This also moves the vblank configuration defines from platform_x11.c to the
 common egl_dri2.h header so they can be shared by both platforms.

This little part could be a separate patch, so it could go in already.

 ---
  src/egl/drivers/dri2/egl_dri2.h |   7 ++
  src/egl/drivers/dri2/platform_wayland.c | 159 
 
  src/egl/drivers/dri2/platform_x11.c |   6 --
  3 files changed, 147 insertions(+), 25 deletions(-)
 
 diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
 index fba5f81..cc657ba 100644
 --- a/src/egl/drivers/dri2/egl_dri2.h
 +++ b/src/egl/drivers/dri2/egl_dri2.h
 @@ -175,6 +175,7 @@ struct dri2_egl_surface
 intdx;
 intdy;
 struct wl_callback*frame_callback;
 +   struct wl_callback*throttle_callback;
 int format;
  #endif
  
 @@ -221,6 +222,12 @@ struct dri2_egl_image
 __DRIimage *dri_image;
  };
  
 +/* From xmlpool/options.h, user exposed so should be stable */
 +#define DRI_CONF_VBLANK_NEVER 0
 +#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
 +#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
 +#define DRI_CONF_VBLANK_ALWAYS_SYNC 3
 +
  /* standard typecasts */
  _EGL_DRIVER_STANDARD_TYPECASTS(dri2_egl)
  _EGL_DRIVER_TYPECAST(dri2_egl_image, _EGLImage, obj)
 diff --git a/src/egl/drivers/dri2/platform_wayland.c 
 b/src/egl/drivers/dri2/platform_wayland.c
 index ffc5959..6ee6ffb 100644
 --- a/src/egl/drivers/dri2/platform_wayland.c
 +++ b/src/egl/drivers/dri2/platform_wayland.c
 @@ -180,8 +180,16 @@ dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay 
 *disp,
  _EGLConfig *conf, EGLNativeWindowType window,
  const EGLint *attrib_list)
  {
 -   return dri2_create_surface(drv, disp, EGL_WINDOW_BIT, conf,
 +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
 +   _EGLSurface *surf;
 +
 +   surf = dri2_create_surface(drv, disp, EGL_WINDOW_BIT, conf,
 window, attrib_list);
 +
 +   if (surf != NULL)
 +  drv-API.SwapInterval(drv, disp, surf, 
 dri2_dpy-default_swap_interval);
 +
 +   return surf;
  }
  
  /**
 @@ -216,6 +224,8 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
 _EGLSurface *surf)
  
 if (dri2_surf-frame_callback)
wl_callback_destroy(dri2_surf-frame_callback);
 +   if (dri2_surf-throttle_callback)
 +  wl_callback_destroy(dri2_surf-throttle_callback);
  
 if (dri2_surf-base.Type == EGL_WINDOW_BIT) {
dri2_surf-wl_win-private = NULL;
 @@ -261,24 +271,46 @@ get_back_bo(struct dri2_egl_surface *dri2_surf, 
 __DRIbuffer *buffer)
 __DRIimage *image;
 int i, name, pitch;
  
 -   /* There might be a buffer release already queued that wasn't processed */
 -   wl_display_dispatch_queue_pending(dri2_dpy-wl_dpy, dri2_dpy-wl_queue);
 +   if (dri2_surf-throttle_callback == NULL) {
 +  /* There might be a buffer release already queued that wasn't 
 processed */
 +  wl_display_dispatch_queue_pending(dri2_dpy-wl_dpy, 
 dri2_dpy-wl_queue);
 +   } else {
 +  /* If we aren't throttling to the frame callbacks then the compositor
 +   * may have sent a release event after the last attach so we'll wait
 +   * until the sync for the commit request completes in order to have the
 +   * best chance 

Re: [Mesa-dev] [PATCH v3] wayland: Add support for eglSwapInterval

2013-09-13 Thread Neil Roberts
Oh no, I meant to send this to the wayland-devel list. git send-email is
hard. Sorry about that!

- Neil
-
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev