mesa: Set green, blue channels to zero only for formats with these components
authorAnuj Phogat <anuj.phogat@gmail.com>
Thu, 11 Jun 2015 23:44:45 +0000 (16:44 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Fri, 24 Jul 2015 17:48:58 +0000 (10:48 -0700)
This is an optimization which avoids setting pixel transfer operations
when not required. _mesa_ReadPixels falls back to slower path if
transfer operations are set.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/mesa/drivers/common/meta.c

index ca10bbe81f69681c718e004726caa9f45f12745d..826f2239d11e3d0884449ed8ceed716af16c9a25 100644 (file)
@@ -3159,9 +3159,16 @@ decompress_texture_image(struct gl_context *ctx,
        * returned as red and two-channel texture values are returned as
        * red/alpha.
        */
-      if ((baseTexFormat == GL_LUMINANCE ||
-           baseTexFormat == GL_LUMINANCE_ALPHA ||
-           baseTexFormat == GL_INTENSITY) ||
+      if (((baseTexFormat == GL_LUMINANCE ||
+            baseTexFormat == GL_LUMINANCE_ALPHA ||
+            baseTexFormat == GL_INTENSITY) &&
+           (destBaseFormat == GL_RGBA ||
+            destBaseFormat == GL_RGB ||
+            destBaseFormat == GL_RG ||
+            destBaseFormat == GL_GREEN ||
+            destBaseFormat == GL_BLUE ||
+            destBaseFormat == GL_BGRA ||
+            destBaseFormat == GL_BGR)) ||
           /* If we're reading back an RGB(A) texture (using glGetTexImage) as
           * luminance then we need to return L=tex(R).
           */