[Mesa-dev] [PATCH 2/3] egl_dri2: add support for Android

Chad Versace chad at chad-versace.us
Wed Aug 24 17:58:16 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Comments below.

On 08/23/2011 08:10 PM, Chia-I Wu wrote:
> Add platform_android.c that supports _EGL_PLAFORM_ANDROID.  It works
> with drm_gralloc, where back buffers of windows are backed by GEM
> objects.
> 
> In Android a native window has a queue of back buffers allocated by the
> server, through drm_gralloc.  For each frame, EGL needs to
> 
>   dequeue the next back buffer
>   render to the buffer
>   enqueue the buffer
> 
> After enqueuing, the buffer is no longer valid to EGL.  A window has no
> depth buffer or other aux buffers.  They need to be allocated locally by
> EGL.
> ---
>  src/egl/drivers/dri2/egl_dri2.c         |   89 +++++
>  src/egl/drivers/dri2/egl_dri2.h         |   18 +
>  src/egl/drivers/dri2/platform_android.c |  588 +++++++++++++++++++++++++++++++
>  3 files changed, 695 insertions(+), 0 deletions(-)
>  create mode 100644 src/egl/drivers/dri2/platform_android.c
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index ba728a1..33c2330 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c

[snip]

> +static _EGLImage *
> +dri2_create_image_android_native_buffer(_EGLDisplay *disp,
> +                                        EGLClientBuffer buffer)

To reiterate Benjamin, I think dri2_create_image_android_native_buffer should go
in android_platform.c.

[snip] 

> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> new file mode 100644
> index 0000000..d0de94c
> --- /dev/null
> +++ b/src/egl/drivers/dri2/platform_android.c

[snip]

> +static _EGLSurface *
> +droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
> +		    _EGLConfig *conf, EGLNativeWindowType window,
> +		    const EGLint *attrib_list)
> +{
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +   struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
> +   struct dri2_egl_surface *dri2_surf;
> +   int format;
> +
> +   (void) drv;
> +
> +   if (!window || window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
> +      _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
> +      return NULL;
> +   }
> +   if (window->query(window, NATIVE_WINDOW_FORMAT, &format)) {
> +      _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
> +      return NULL;
> +   }
> +   if (format != dri2_conf->base.NativeVisualID) {
> +      _eglLog(_EGL_WARNING, "Native format mismatch: 0x%x != 0x%x",
> +            format, dri2_conf->base.NativeVisualID);
> +   }
> +
> +   dri2_surf = calloc(1, sizeof *dri2_surf);
> +   if (!dri2_surf) {
> +      _eglError(EGL_BAD_ALLOC, "droid_create_surface");
> +      return NULL;
> +   }
> +
> +   if (!_eglInitSurface(&dri2_surf->base, disp, type, conf, attrib_list))
> +      goto cleanup_surf;

It seems that droid_get_buffers_with_format() only supports single-buffered
surfaces. So eglCreateWindowSurface should reject requests for which
EGL_RENDER_BUFFER != EGL_SINGLE_BUFFER.

      if (dri2_surf->base.RenderBuffer != EGL_SINGLE_BUFFER)
         goto cleanup_surf;

I think the DRI2 surface type needs to be set here too.

      dri2_surf->type = DRI2_WINDOW_SURFACE;

> +
> +   dri2_surf->dri_drawable =
> +      (*dri2_dpy->dri2->createNewDrawable)(dri2_dpy->dri_screen,
> +					   dri2_conf->dri_double_config,
> +                                           dri2_surf);
> +   if (dri2_surf->dri_drawable == NULL) {
> +      _eglError(EGL_BAD_ALLOC, "dri2->createNewDrawable");
> +      goto cleanup_surf;
> +   }
> +
> +   window->common.incRef(&window->common);
> +   window->query(window, NATIVE_WINDOW_WIDTH, &dri2_surf->base.Width);
> +   window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height);
> +
> +   dri2_surf->window = window;
> +
> +   return &dri2_surf->base;
> +
> +cleanup_surf:
> +   free(dri2_surf);
> +
> +   return NULL;
> +}

[snip]

> +#include <xf86drm.h>
> +/* for i915 */
> +#include <i915_drm.h>
> +/* for radeon */
> +#include <radeon_drm.h>

These includes should be moved to the top of the file.

- -- 
Chad Versace
chad at chad-versace.us
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOVZ4oAAoJEAIvNt057x8ibNwP/R+Y7zo3yhh0v4sLlrkbKiox
GbuVRg4L00vi7IZk9ia/YZK4yHJIfku8f5Kf62lnNGL+8XwiqPc+fLFsTqLgg8yy
b0lTlHcUbvqyGokpwpECATvmXQ/eUupHbN3F7LN4fT7DUyuONmAmUHM6DFgcAu8C
rrywDtZqqigCxvPwJ8WGqtebfBtn0893tneem4t4fS13C+jgxns9RuZ4x1f+5OxA
+jlQz207M7YLT7FZZSBRBq8KGlik+0rp3CNTJ9OWu3YrQaqQxt24Dn9deopw3SeZ
jzKxQfuDqZbMVY9z91kjlo/N+CnmmAi8OV56Y7XVOdlwOw70vbvdD6olirIE7JK6
JOCvKqJucFf1cR/4dUXFOPLCl1V4UymHc3m5+KMSeqK5sp1UGjFGZCpsGlsbnWuP
Ygtbmw0lOqg0Gk15D2Xs8moAr8YI414aGCCyTXftxyf7qHR5OxxeD28cS3RIXq/o
fYvB37TKmkPyQ4dZxWZSfx/Rhqs8b0ZGFLswZpTa08AjFRnSLYUggsBy/zgqSEI8
ZoAwV8dMidyi2hdfEfIbUA0wIY56QbZ5Lrw5R1iGl7lk1HOPe6r+d17V52h94Jvm
AZChsK5SEKuONmtpcn9Cqgs26URWakJ92oXP/eNY9x7HdGykr61LCMkrKWGV6eUn
kN3X/Gil4t/CJrc0xKHi
=+Lyq
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list