[Mesa-dev] [PATCH] gallium/dri2: Fix RGB565 EGLImage creation

Michel Dänzer michel at daenzer.net
Fri Jan 8 01:55:57 PST 2016


On 08.01.2016 01:53, Nicolas Dufresne wrote:
> When creating egl images we do a bytes to pixel conversion by deviding
> by 4 regardless of the pixel format. This does not work for RGB565. In
> this patch, we avoid useless conversion and use proper API when the
> conversion cannot be avoided.
> 
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

[...]

> diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
> index a11a6cb..7b5a755 100644
> --- a/src/gallium/state_trackers/dri/dri2.c
> +++ b/src/gallium/state_trackers/dri/dri2.c
> @@ -101,6 +101,31 @@ static int convert_to_fourcc(int format)
>     return format;
>  }
>  
> +static enum pipe_format dri2_format_to_pipe_format (int format)
> +{
> +   enum pipe_format pf;
> +
> +   switch (format) {
> +   case __DRI_IMAGE_FORMAT_RGB565:
> +      pf = PIPE_FORMAT_B5G6R5_UNORM;
> +      break;
> +   case __DRI_IMAGE_FORMAT_XRGB8888:
> +      pf = PIPE_FORMAT_BGRX8888_UNORM;
> +      break;
> +   case __DRI_IMAGE_FORMAT_ARGB8888:
> +      pf = PIPE_FORMAT_BGRA8888_UNORM;
> +      break;
> +   case __DRI_IMAGE_FORMAT_ABGR8888:
> +      pf = PIPE_FORMAT_RGBA8888_UNORM;
> +      break;
> +   default:
> +      pf = PIPE_FORMAT_NONE;
> +      break;
> +   }
> +
> +   return pf;
> +}

The addition of this function and refactoring of existing code to use it
should be split out into a separate patch.

Other than that, looks good to me.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list