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

Haixia Shi hshi at chromium.org
Mon Apr 4 23:39:36 UTC 2016


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.

Furthermore when parameter |sRGBCapable| is set to false, we should be using
UNORM format by default.

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 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index c6eb50a..a5ec3bf 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1001,14 +1001,14 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
    }
 
    if (mesaVis->redBits == 5)
-      rgbFormat = MESA_FORMAT_B5G6R5_UNORM;
+      rgbFormat = mesaVis->redMask == 0x1f ? MESA_FORMAT_R5G6B5_UNORM : MESA_FORMAT_B5G6R5_UNORM;
    else if (mesaVis->sRGBCapable)
-      rgbFormat = MESA_FORMAT_B8G8R8A8_SRGB;
+      rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8A8_SRGB : MESA_FORMAT_B8G8R8A8_SRGB;
    else if (mesaVis->alphaBits == 0)
-      rgbFormat = MESA_FORMAT_B8G8R8X8_UNORM;
+      rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8X8_UNORM : MESA_FORMAT_B8G8R8X8_UNORM;
    else {
-      rgbFormat = MESA_FORMAT_B8G8R8A8_SRGB;
-      fb->Visual.sRGBCapable = true;
+      rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8A8_UNORM : MESA_FORMAT_B8G8R8A8_UNORM;
+      fb->Visual.sRGBCapable = false;
    }
 
    /* setup the hardware-based renderbuffers */
-- 
2.8.0.rc3.226.g39d4020



More information about the mesa-dev mailing list