[Mesa-dev] [PATCH v2 3/7] egl/android: Fix support for pbuffers (v2)

Rob Herring robh at kernel.org
Tue Aug 2 17:32:46 UTC 2016


On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa <tfiga at chromium.org> wrote:
> From: Nicolas Boichat <drinkcat at chromium.org>
>
> Existing image loader code supports creating images only for window
> surfaces. Moreover droid_create_surface() passes wrong surface type to
> dri2_get_dri_config(), resulting in incorrect configs being returned for
> pbuffers. This patch fixes these issues.
>
> In addition, the config generation code is fixed to include single
> buffered contexts required for pbuffers and make sure that generated
> configs support only surfaces which can handle their supported buffering
> modes.
>
> v2: Return error only in case of real error condition and ignore requests
>     of unavailable buffers.
>     Improve coding style.

This still breaks Android for me. Just adding the hunks below is
enough to break things. It results in get_buffers() being called with
type == EGL_WINDOW_BIT and buffer_mask == __DRI_IMAGE_BUFFER_FRONT. I
don't see any requests for the front buffer without this change. I've
looked through the tree, but don't really see what would cause
buffer_mask to change.



> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 4577875..3da6bef 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -291,6 +291,7 @@ struct dri2_egl_surface
>     struct ANativeWindow *window;
>     struct ANativeWindowBuffer *buffer;
>     __DRIimage *dri_image;
> +   __DRIimage *dri_front_image;
>
>     /* EGL-owned buffers */
>     __DRIbuffer           *local_buffers[__DRI_BUFFER_COUNT];
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index d78c06d..420436c 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -286,7 +286,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
>        window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height);
>     }
>
> -   config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
> +   config = dri2_get_dri_config(dri2_conf, type,
>                                  dri2_surf->base.GLColorspace);
>     if (!config)
>        goto cleanup_surface;
> @@ -347,6 +347,9 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
>        dri2_surf->window->common.decRef(&dri2_surf->window->common);
>     }
>
> +   if (dri2_surf->dri_front_image)
> +      dri2_dpy->image->destroyImage(dri2_surf->dri_front_image);
> +
>     (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
>
>     free(dri2_surf);

> @@ -696,14 +725,6 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
>        for (j = 0; dri2_dpy->driver_configs[j]; j++) {
>           const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
>           struct dri2_egl_config *dri2_conf;
> -         unsigned int double_buffered = 0;
> -
> -         dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[j],
> -            __DRI_ATTRIB_DOUBLE_BUFFER, &double_buffered);
> -
> -         /* support only double buffered configs */
> -         if (!double_buffered)
> -            continue;
>
>           dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j],
>                 count + 1, surface_type, config_attrs, visuals[i].rgba_masks);
> @@ -726,6 +747,19 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
>        /* there is no front buffer so no OpenGL */
>        dri2_conf->base.RenderableType &= ~EGL_OPENGL_BIT;
>        dri2_conf->base.Conformant &= ~EGL_OPENGL_BIT;
> +
> +      for (j = 0; j < 2; j++) {
> +         /* Unsupported color space variants should not affect surface type. */
> +         if (!dri2_conf->dri_single_config[j] && !dri2_conf->dri_double_config[j])
> +            continue;
> +
> +         /* Pbuffers support only single buffering. */
> +         if (!dri2_conf->dri_single_config[j])
> +            dri2_conf->base.SurfaceType &= ~EGL_PBUFFER_BIT;
> +         /* Windows support only double buffering. */
> +         if (!dri2_conf->dri_double_config[j])
> +            dri2_conf->base.SurfaceType &= ~EGL_WINDOW_BIT;
> +      }
>     }
>
>     return (count != 0);
> --
> 2.8.0.rc3.226.g39d4020
>


More information about the mesa-dev mailing list