[Mesa-dev] [PATCH 10/11] i965: Allow creating planar YUV __DRIimages

Jordan Justen jordan.l.justen at intel.com
Mon May 16 19:50:46 UTC 2016


On 2016-05-11 12:22:43, Kristian Høgsberg wrote:
> From: Kristian Høgsberg Kristensen <kristian.h.kristensen at intel.com>
> 
> Lift the resctriction we had before and allow creation of images with
> multiple planes. We still require all the planes to be within the same
> bo.
> ---
>  src/mesa/drivers/dri/i965/intel_screen.c | 33 ++++++++++++++++++--------------
>  1 file changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index f9b5484..599ec19 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -676,9 +676,14 @@ intel_create_image_from_fds(__DRIscreen *screen,
>     __DRIimage *image;
>     int i, index;
>  
> -   if (fds == NULL || num_fds != 1)
> +   if (fds == NULL || num_fds < 1)
>        return NULL;
>  
> +   /* We only support all planes from the same bo */
> +   for (i = 0; i < num_fds; i++)
> +      if (fds[0] != fds[i])
> +         return NULL;
> +
>     f = intel_image_format_lookup(fourcc);
>     if (f == NULL)
>        return NULL;

How about checking num_fds == f->nplanes?

> @@ -691,22 +696,28 @@ intel_create_image_from_fds(__DRIscreen *screen,
>     if (image == NULL)
>        return NULL;
>  
> -   image->bo = drm_intel_bo_gem_create_from_prime(intelScreen->bufmgr,
> -                                                  fds[0],
> -                                                  height * strides[0]);
> -   if (image->bo == NULL) {
> -      free(image);
> -      return NULL;
> -   }
>     image->width = width;
>     image->height = height;
>     image->pitch = strides[0];
>  
>     image->planar_format = f;
> +   int size = 0;
>     for (i = 0; i < f->nplanes; i++) {
>        index = f->planes[i].buffer_index;
>        image->offsets[index] = offsets[index];
>        image->strides[index] = strides[index];
> +
> +      const int height = height >> f->planes[i].height_shift;
> +      const int end = offsets[index] + height * strides[index];
> +      if (size < end)
> +         size = end;
> +   }
> +
> +   image->bo = drm_intel_bo_gem_create_from_prime(intelScreen->bufmgr,
> +                                                  fds[0], size);
> +   if (image->bo == NULL) {
> +      free(image);
> +      return NULL;
>     }
>  
>     if (f->nplanes == 1) {
> @@ -732,12 +743,6 @@ intel_create_image_from_dma_bufs(__DRIscreen *screen,
>     __DRIimage *image;
>     struct intel_image_format *f = intel_image_format_lookup(fourcc);
>  
> -   /* For now only packed formats that have native sampling are supported. */
> -   if (!f || f->nplanes != 1) {

Could f->nplanes != num_fds be used?

Series Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

> -      *error = __DRI_IMAGE_ERROR_BAD_MATCH;
> -      return NULL;
> -   }
> -
>     image = intel_create_image_from_fds(screen, width, height, fourcc, fds,
>                                         num_fds, strides, offsets,
>                                         loaderPrivate);
> -- 
> 2.5.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list