[Mesa-dev] [PATCH v3] dri/i965: fix incorrect rgbFormat in intelCreateBuffer().

Kristian Høgsberg krh at bitplanet.net
Wed Apr 6 23:51:11 UTC 2016


On Tue, Apr 5, 2016 at 6:20 PM, Haixia Shi <hshi at chromium.org> wrote:
> It is incorrect to assume that pixel format is always in BGR byte order.
> We need to check bitmask parameters (such as |redMask|) to determine whether
> the RGB or BGR byte order is requested.

It still seems like something is missing here. The driver never
creates fb configs with the other RGB ordering. driCreateConfigs()
only ever creates a red mask of 0xf800, 0xff0000, or 0x3ff00000. Are
you also patching driCreateConfigs() to generate those? Maybe we
should add that part as well and make sure we filter out the visuals
that don't match the display server in libGL or libEGL.

Kristian

> v2: reformat code to stay within 80 character per line limit.
> v3: just fix the byte order problem first and investigate SRGB later.
>
> Signed-off-by: Haixia Shi <hshi at chromium.org>
> Reviewed-by: Stéphane Marchesin <marcheu at chromium.org>
> Cc: kenneth.w.graunke at intel.com
>
> Change-Id: Ib75087aef1fbfb51baa72517207fed410dcd7b1e
> ---
>  src/mesa/drivers/dri/i965/intel_screen.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index c6eb50a..bc8c5d3 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -1000,14 +1000,18 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
>        fb->Visual.samples = num_samples;
>     }
>
> -   if (mesaVis->redBits == 5)
> -      rgbFormat = MESA_FORMAT_B5G6R5_UNORM;
> -   else if (mesaVis->sRGBCapable)
> -      rgbFormat = MESA_FORMAT_B8G8R8A8_SRGB;
> -   else if (mesaVis->alphaBits == 0)
> -      rgbFormat = MESA_FORMAT_B8G8R8X8_UNORM;
> -   else {
> -      rgbFormat = MESA_FORMAT_B8G8R8A8_SRGB;
> +   if (mesaVis->redBits == 5) {
> +      rgbFormat = mesaVis->redMask == 0x1f ? MESA_FORMAT_R5G6B5_UNORM
> +                                           : MESA_FORMAT_B5G6R5_UNORM;
> +   } else if (mesaVis->sRGBCapable) {
> +      rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8A8_SRGB
> +                                           : MESA_FORMAT_B8G8R8A8_SRGB;
> +   } else if (mesaVis->alphaBits == 0) {
> +      rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8X8_UNORM
> +                                           : MESA_FORMAT_B8G8R8X8_UNORM;
> +   } else {
> +      rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8A8_SRGB
> +                                           : MESA_FORMAT_B8G8R8A8_SRGB;
>        fb->Visual.sRGBCapable = true;
>     }
>
> --
> 2.8.0.rc3.226.g39d4020
>
> _______________________________________________
> 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