swrast: Don't try to adjust_colors for <8bpc when handling R16, RG1616.
authorEric Anholt <eric@anholt.net>
Sat, 16 Apr 2011 02:55:38 +0000 (19:55 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 18 Apr 2011 18:19:54 +0000 (11:19 -0700)
The GL_RED and GL_RG were tricking this code into executing, but it's
totally unprepared for a 16-bit channel and just rescaled the values
down to 0.  We don't have anything with <8bit channels alongside >8bit
channels, so disabling it should be safe.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/swrast/s_readpix.c

index cca7ec008024987fbe516247acfad734799e3608..5604c2e937e74caf940f8fc60ba5180b95e0beac 100644 (file)
@@ -344,9 +344,9 @@ read_rgba_pixels( struct gl_context *ctx,
          _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, rgba);
 
          /* apply fudge factor for shallow color buffers */
-         if (fb->Visual.redBits < 8 ||
-             fb->Visual.greenBits < 8 ||
-             fb->Visual.blueBits < 8) {
+         if ((fb->Visual.redBits < 8 && fb->Visual.redBits != 0) ||
+             (fb->Visual.greenBits < 8 && fb->Visual.greenBits != 0) ||
+            (fb->Visual.blueBits < 8 && fb->Visual.blueBits != 0)) {
             adjust_colors(fb, width, rgba);
          }