From 255935949f29d4a503bdd2e4594a959085492749 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sun, 26 Feb 2012 17:00:13 +0000 Subject: [PATCH 2/2] readpix: Don't use the fast path for luminance types When deciding whether to use the fast memcpy path for the fallback implementation of glReadPixels, it now explicitly ignores luminance types because in that case the conversion to and from RGB does not end up with exactly the same values. Although it seems counter-intuitive, the spec implies that even when the source and dest formats are a luminance type, it will temporarily convert to RGB by storing the luminance value in every component and then convert back to luminance by adding all of the components together. This effectively means the luminance values must be multiplied by three to conform to the spec. --- src/mesa/main/readpix.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index cddab43..77ea82d 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -234,6 +234,17 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx, if (transferOps) return GL_FALSE; + /* This can't handle luminance buffers because it would effectively + need to multiply the luminance values by 3. The spec says it + should convert to RGB by setting all of the components to the + luminance value and then convert back to luminance by adding all + of the components together. */ + switch (_mesa_get_format_base_format(rb->Format)) { + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + return GL_FALSE; + } + dstStride = _mesa_image_row_stride(packing, width, format, type); dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, format, type, 0, 0); -- 1.7.3.16.g9464b