[Mesa-dev] [PATCH] mesa: Fix swizzling for luminance/intensity in _mesa_readpixels

Chris Wilson chris at chris-wilson.co.uk
Mon Jul 31 21:42:42 UTC 2017


Luminance/Intensity when converted to RGBA should be replicated to fill
the RGB channels.

Fixes:5038d839b8e4 ("mesa: use _mesa_format_convert to implement glReadPixels.")
Cc: Iago Toral Quiroga <itoral at igalia.com>
Cc: Jason Ekstrand <jason.ekstrand at intel.com>
---
 src/mesa/main/readpix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 6ce340ddf9..2d6c7521ef 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -474,14 +474,14 @@ read_rgba_pixels( struct gl_context *ctx,
    if (rb->_BaseFormat == GL_LUMINANCE || rb->_BaseFormat == GL_INTENSITY) {
       needs_rebase = true;
       rebase_swizzle[0] = MESA_FORMAT_SWIZZLE_X;
-      rebase_swizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
-      rebase_swizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+      rebase_swizzle[1] = MESA_FORMAT_SWIZZLE_X;
+      rebase_swizzle[2] = MESA_FORMAT_SWIZZLE_X;
       rebase_swizzle[3] = MESA_FORMAT_SWIZZLE_ONE;
    } else if (rb->_BaseFormat == GL_LUMINANCE_ALPHA) {
       needs_rebase = true;
       rebase_swizzle[0] = MESA_FORMAT_SWIZZLE_X;
-      rebase_swizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
-      rebase_swizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+      rebase_swizzle[1] = MESA_FORMAT_SWIZZLE_X;
+      rebase_swizzle[2] = MESA_FORMAT_SWIZZLE_X;
       rebase_swizzle[3] = MESA_FORMAT_SWIZZLE_W;
    } else if (_mesa_get_format_base_format(rb_format) != rb->_BaseFormat) {
       needs_rebase =
-- 
2.13.3



More information about the mesa-dev mailing list