[Mesa-dev] [android-x86-devel] [RFC 7/7] android: support swrast

Rob Herring robherring2 at gmail.com
Fri Apr 29 13:25:13 UTC 2016


On Thu, Apr 28, 2016 at 2:35 AM, Chih-Wei Huang <cwhuang at android-x86.org> wrote:
> From: WuZhen <wuzhen at jidemail.com>
>
> System boots up with gles_mesa/softpipe/llvmpipe.
>
> NO_REF_TASK
> tested: local run
>
> Change-Id: I629ed0ca9fad12e32270eb8e8bfa9f7681b68474
> Signed-off-by: Chih-Wei Huang <cwhuang at linux.org.tw>
> ---
>  Android.mk                                     |   2 +-
>  include/GL/internal/dri_interface.h            |   9 +-
>  src/egl/Android.mk                             |   1 +
>  src/egl/drivers/dri2/egl_dri2.c                |   1 +
>  src/egl/drivers/dri2/platform_android.c        | 386 ++++++++++++++++++++++++-
>  src/gallium/Android.mk                         |   2 +-
>  src/gallium/drivers/llvmpipe/Android.mk        |  37 +++
>  src/gallium/include/state_tracker/drm_driver.h |  10 +-
>  src/gallium/state_trackers/dri/dri2.c          |   6 +-
>  src/gallium/state_trackers/dri/drisw.c         |  46 +++
>  src/gallium/targets/dri/Android.mk             |   8 +-
>  src/gallium/winsys/sw/dri/Android.mk           |   2 +
>  src/gallium/winsys/sw/dri/dri_sw_winsys.c      |  64 ++++
>  src/mesa/drivers/dri/common/dri_util.c         |   4 +-
>  src/mesa/drivers/dri/common/dri_util.h         |   2 +-
>  15 files changed, 555 insertions(+), 25 deletions(-)
>  create mode 100644 src/gallium/drivers/llvmpipe/Android.mk

I had started some work on this and needed some changes I don't see
here. I didn't get beyond getting r600 to build though.

I'm on AOSP master which probably means a different LLVM version.
First, I had to enable several LLVM libs to build for the target and
not just the host. In mesa, I had to set the LLVM version to 3.7 from
3.5, add libLLVMExecutionEngine to libmesa_nir and use libLLVM shared
lib instead of r600 static libraries. I'm surprised similar changes
aren't needed.

[...]

> +#ifdef HAVE_ANDROID_PLATFORM
> +const struct gralloc_module_t* get_gralloc()
> +{
> +   static const struct gralloc_module_t* gr_module = NULL;
> +   const hw_module_t *mod;
> +   int err;
> +
> +   if (!gr_module) {
> +      err =  hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod);
> +      if (!err) {
> +         gr_module = (gralloc_module_t *) mod;
> +      }
> +   }
> +   return gr_module;
> +}
> +#endif
> +
>  struct dri_sw_winsys
>  {
>     struct sw_winsys base;
> @@ -125,6 +151,12 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws,
>  {
>     struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
>
> +#ifdef HAVE_ANDROID_PLATFORM
> +   if (dri_sw_dt->androidBuffer) {
> +      dri_sw_dt->androidBuffer->common.decRef(&dri_sw_dt->androidBuffer->common);
> +   }
> +#endif
> +
>     align_free(dri_sw_dt->data);
>
>     FREE(dri_sw_dt);
> @@ -136,6 +168,17 @@ dri_sw_displaytarget_map(struct sw_winsys *ws,
>                           unsigned flags)
>  {
>     struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
> +#ifdef HAVE_ANDROID_PLATFORM
> +   if (dri_sw_dt->androidBuffer) {
> +      if (!get_gralloc()->lock(get_gralloc(), dri_sw_dt->androidBuffer->handle,
> +                              GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
> +                              0, 0, dri_sw_dt->androidBuffer->width, dri_sw_dt->androidBuffer->height,
> +                              (void**)&dri_sw_dt->mapped)) {
> +         dri_sw_dt->map_flags = flags;
> +         return dri_sw_dt->mapped;
> +      }
> +   }
> +#endif

I'm trying to eliminate the gralloc dependencies in mesa, so I don't
like adding more. We should be able to call into GBM directly here
once the map support is in place.

Rob


More information about the mesa-dev mailing list