From 27ccf77405328aae7da83636222c639bd6de7b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 24 Apr 2016 11:51:52 +0200 Subject: [PATCH] st/dri: fix format translation from a visual to a pipe format Look at the red mask. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95071 --- src/gallium/state_trackers/dri/dri_screen.c | 46 +++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 2856ec0..68479c6 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -252,19 +252,41 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, if (!mode) return; - if (mode->redBits == 8) { - if (mode->alphaBits == 8) - if (mode->sRGBCapable) - stvis->color_format = PIPE_FORMAT_BGRA8888_SRGB; - else - stvis->color_format = PIPE_FORMAT_BGRA8888_UNORM; - else - if (mode->sRGBCapable) - stvis->color_format = PIPE_FORMAT_BGRX8888_SRGB; - else - stvis->color_format = PIPE_FORMAT_BGRX8888_UNORM; - } else { + /* Deduce the color format. */ + switch (mode->redMask) { + case 0x00FF0000: + if (mode->alphaMask) { + assert(mode->alphaMask == 0xFF000000); + stvis->color_format = mode->sRGBCapable ? + PIPE_FORMAT_BGRA8888_SRGB : + PIPE_FORMAT_BGRA8888_UNORM; + } else { + stvis->color_format = mode->sRGBCapable ? + PIPE_FORMAT_BGRX8888_SRGB : + PIPE_FORMAT_BGRX8888_UNORM; + } + break; + + case 0x000000FF: + if (mode->alphaMask) { + assert(mode->alphaMask == 0xFF000000); + stvis->color_format = mode->sRGBCapable ? + PIPE_FORMAT_RGBA8888_SRGB : + PIPE_FORMAT_RGBA8888_UNORM; + } else { + stvis->color_format = mode->sRGBCapable ? + PIPE_FORMAT_RGBX8888_SRGB : + PIPE_FORMAT_RGBX8888_UNORM; + } + break; + + case 0x0000F800: stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM; + break; + + default: + assert(!"unsupported visual: invalid red mask"); + return; } if (mode->sampleBuffers) { -- 2.5.0