[Mesa-dev] [Mesa-stable] [PATCH 1/1] i965: return the fourcc saved in __DRIimage when possible

Xiong, James james.xiong at intel.com
Mon Apr 9 18:24:40 UTC 2018


Hi Mark,

We need add a dmabuf export test case in piglit, unfortunately I don't have time to work on it at the moment, it's on my to-do list.

Thanks,
James

-----Original Message-----
From: Janes, Mark A 
Sent: Monday, April 9, 2018 11:17 AM
To: Xiong, James <james.xiong at intel.com>; mesa-dev at lists.freedesktop.org
Cc: Xiong, James <james.xiong at intel.com>; mesa-stable at lists.freedesktop.org; Palli, Tapani <tapani.palli at intel.com>
Subject: Re: [Mesa-stable] [PATCH 1/1] i965: return the fourcc saved in __DRIimage when possible

Hi James,

Would it be possible to create a piglit test to exercise the bug referenced in your commit message?  If possible, we want to prevent future regressions for this use case.

thanks,

Mark


James Xiong <james.xiong at intel.com> writes:

> From: "Xiong, James" <james.xiong at intel.com>
>
> When creating a image from a texture, the image's dri_format is set to 
> the first plane's format, and used to look up for the fourcc. e.g. for 
> FOURCC_NV12 texture, the dri_format is set to __DRI_IMAGE_FORMAT_R8, 
> we end up with a wrong entry in function
> intel_lookup_fourcc():
>    { __DRI_IMAGE_FOURCC_R8, __DRI_IMAGE_COMPONENTS_R, 1,
>      { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 }, } }, instead of the 
> corret one:
>    { __DRI_IMAGE_FOURCC_NV12, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
>      { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
>        { 1, 1, 1, __DRI_IMAGE_FORMAT_GR88, 2 } } }, as a result, a 
> wrong fourcc __DRI_IMAGE_FOURCC_R8 was returned.
>
> To fix this bug, the image inherits the texture's planar_format that 
> has the original fourcc; Upon querying, if planar_format is set, 
> return the saved fourcc; Otherwise fall back to the old way.
>
> v3: add a bug description and "cc mesa-stable" tag (Jason)
>   remove abandunt null pointer check (Tapani)
>   squash 2 patches into one (James)
> v2: fall back to intel_lookup_fourcc() when planar_format is NULL
>   (Dongwon & Matt Roper)
>
> Cc: mesa-stable at lists.freedesktop.org
> Signed-off-by: Xiong, James <james.xiong at intel.com>
> ---
>  src/mesa/drivers/dri/i965/intel_screen.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
> b/src/mesa/drivers/dri/i965/intel_screen.c
> index dcb98da..29cb7ad 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -388,10 +388,16 @@ intel_image_format_lookup(int fourcc)
>     return NULL;
>  }
>  
> -static boolean intel_lookup_fourcc(int dri_format, int *fourcc)
> +static boolean
> +intel_image_get_fourcc(__DRIimage *image, int *fourcc)
>  {
> +   if (image->planar_format) {
> +      *fourcc = image->planar_format->fourcc;
> +      return true;
> +   }
> +
>     for (unsigned i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
> -      if (intel_image_formats[i].planes[0].dri_format == dri_format) {
> +      if (intel_image_formats[i].planes[0].dri_format == 
> + image->dri_format) {
>           *fourcc = intel_image_formats[i].fourcc;
>           return true;
>        }
> @@ -578,6 +584,7 @@ intel_create_image_from_texture(__DRIcontext *context, int target,
>     intel_setup_image_from_mipmap_tree(brw, image, iobj->mt, level, zoffset);
>     image->dri_format = driGLFormatToImageFormat(image->format);
>     image->has_depthstencil = iobj->mt->stencil_mt? true : false;
> +   image->planar_format = iobj->planar_format;
>     if (image->dri_format == MESA_FORMAT_NONE) {
>        *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
>        free(image);
> @@ -869,7 +876,7 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
>     case __DRI_IMAGE_ATTRIB_FD:
>        return !brw_bo_gem_export_to_prime(image->bo, value);
>     case __DRI_IMAGE_ATTRIB_FOURCC:
> -      return intel_lookup_fourcc(image->dri_format, value);
> +      return intel_image_get_fourcc(image, value);
>     case __DRI_IMAGE_ATTRIB_NUM_PLANES:
>        if (isl_drm_modifier_has_aux(image->modifier)) {
>           assert(!image->planar_format || 
> image->planar_format->nplanes == 1);
> --
> 2.7.4
>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-stable


More information about the mesa-dev mailing list