Mesa (7.11): mesa: fix format selection for meta CopyTexSubImage()

Ian Romanick idr at kemper.freedesktop.org
Fri Nov 18 20:20:30 UTC 2011


Module: Mesa
Branch: 7.11
Commit: 21364bd09d6133f5da12986678fa995fa0aea7e4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=21364bd09d6133f5da12986678fa995fa0aea7e4

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Jul 28 09:51:30 2011 -0600

mesa: fix format selection for meta CopyTexSubImage()

When we do a glReadPixels into the temporary buffer, we don't want to
use GL_LUMINANCE, GL_LUMINANCE_ALPHA or GL_INTENSITY since they will
compute L=R+G+B which is not what we want.

This bug has existed all along but was only exposed by the elimination
of the driver hook for glCopyTexImage() in
5874890c26f434f54e9218b83fae4eb8175c24e9.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=39604
Tested-by: Ian Romanick <ian.d.romanick at intel.com>
(cherry picked from commit e4fdc95277bd323d8945e20635d3a1702a2e695d)

(cherry-pick note: This patch and the one before it combine to fix
CopyTexImage from RGBA window to LA texture.  This was believed to
already be fixed by commit 296e6b9, but these changes were also
necessary.)

---

 src/mesa/drivers/common/meta.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index a578797..48df1f5 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2842,6 +2842,16 @@ copy_tex_sub_image(struct gl_context *ctx,
 
    /* Choose format/type for temporary image buffer */
    format = _mesa_get_format_base_format(texImage->TexFormat);
+   if (format == GL_LUMINANCE ||
+       format == GL_LUMINANCE_ALPHA ||
+       format == GL_INTENSITY) {
+      /* We don't want to use GL_LUMINANCE, GL_INTENSITY, etc. for the
+       * temp image buffer because glReadPixels will do L=R+G+B which is
+       * not what we want (should be L=R).
+       */
+      format = GL_RGBA;
+   }
+
    type = get_temp_image_type(ctx, format);
    bpp = _mesa_bytes_per_pixel(format, type);
    if (bpp <= 0) {




More information about the mesa-commit mailing list