[Mesa-dev] [PATCH v2 2/3] egl/wayland: Pull color buffers from dri2_surf->color_buffers pool
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Mon Jan 14 05:49:32 PST 2013
On 01/09/2013 04:45 PM, Kristian Høgsberg wrote:
> We used to keep the color buffers in the dri_buffers array and
> swap __DRI_BUFFER_BACK_LEFT and __DRI_BUFFER_FRONT_LEFT around there
> and swap third_buffer in in case we needed to triple buffer. That
> gets a little fidgety with all the swaps, so lets use the
> color_buffers pool like the gbm platform does. We track the color buffers,
> their corresponding wl_buffer and locked status here and just plug
> a free one into dri2_surf->buffers when we need to.
>
> This is a nice clean-up in itself, but it also sets us up to track
> buffer age in the color_buffers structs.
> ---
> src/egl/drivers/dri2/egl_dri2.h | 23 +-
> src/egl/drivers/dri2/platform_wayland.c | 379 +++++++++++--------------------
> 2 files changed, 150 insertions(+), 252 deletions(-)
>
[...]
> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
> index a8069ba..5b5c849 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
[...]
> @@ -243,173 +228,95 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
[...]
> +static int
> +get_back_bo(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer)
> {
> struct dri2_egl_display *dri2_dpy =
> dri2_egl_display(dri2_surf->base.Resource.Display);
> - struct wl_callback *callback;
> int i;
>
> - if (dri2_surf->third_buffer) {
> - dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
> - dri2_surf->third_buffer);
> - dri2_surf->third_buffer = 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);
>
> - for (i = 0; i < __DRI_BUFFER_COUNT; ++i) {
> - if (dri2_surf->dri_buffers[i]) {
> - switch (i) {
> - case __DRI_BUFFER_FRONT_LEFT:
> - if (dri2_surf->pending_buffer)
> - roundtrip(dri2_dpy);
> - dri2_surf->pending_buffer = dri2_surf->dri_buffers[i];
> - callback = wl_display_sync(dri2_dpy->wl_dpy);
> - wl_callback_add_listener(callback,
> - &release_buffer_listener, dri2_surf);
> - wl_proxy_set_queue((struct wl_proxy *) callback,
> - dri2_dpy->wl_queue);
> - break;
> - default:
> - dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
> - dri2_surf->dri_buffers[i]);
> - break;
> - }
> - dri2_surf->dri_buffers[i] = NULL;
> + if (dri2_surf->back == NULL) {
> + for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
> + /* Get an unlocked buffer, preferrably one with a dri_buffer already
> + * allocated. */
> + if (dri2_surf->color_buffers[i].locked)
> + continue;
> + if (dri2_surf->back == NULL)
> + dri2_surf->back = &dri2_surf->color_buffers[i];
> + else if (dri2_surf->back->dri_buffer == NULL)
> + dri2_surf->back = &dri2_surf->color_buffers[i];
Some lines in this hunk are indented with only spaces and others with
tabs and spaces.
> }
> }
> -}
>
> -static inline void
> -pointer_swap(const void **p1, const void **p2)
> -{
> - const void *tmp = *p1;
> - *p1 = *p2;
> - *p2 = tmp;
> -}
> -
> -static void
> -destroy_third_buffer(struct dri2_egl_surface *dri2_surf)
> -{
> - struct dri2_egl_display *dri2_dpy =
> - dri2_egl_display(dri2_surf->base.Resource.Display);
> -
> - if (dri2_surf->third_buffer == NULL)
> - return;
> -
> - dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
> - dri2_surf->third_buffer);
> - dri2_surf->third_buffer = NULL;
> -
> - if (dri2_surf->wl_drm_buffer[WL_BUFFER_THIRD])
> - wl_buffer_destroy(dri2_surf->wl_drm_buffer[WL_BUFFER_THIRD]);
> - dri2_surf->wl_drm_buffer[WL_BUFFER_THIRD] = NULL;
> - dri2_surf->wl_buffer_lock[WL_BUFFER_THIRD] = 0;
> -}
> + if (dri2_surf->back == NULL)
> + return -1;
> + if (dri2_surf->back->dri_buffer == NULL) {
> + dri2_surf->back->dri_buffer =
The line above has trailing white space.
Anyway,
Reviewed-by: Ander Conselvan de Oliveira <conselvan2 at gmail.com>
More information about the mesa-dev
mailing list