Mesa (master): meta: Fix glCopyTexImage(GL_LUMINANCE) from non-GL_LUMINANCE source.
Eric Anholt
anholt at kemper.freedesktop.org
Mon Jun 13 22:57:12 UTC 2011
Module: Mesa
Branch: master
Commit: 296e6b9038131cd246226881208ffebe3c2683c3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=296e6b9038131cd246226881208ffebe3c2683c3
Author: Eric Anholt <eric at anholt.net>
Date: Wed Jun 8 13:00:51 2011 -0700
meta: Fix glCopyTexImage(GL_LUMINANCE) from non-GL_LUMINANCE source.
glReadPixels() was performing RGB -> L conversion differently from the
glTexImage() style conversion appropriate for glCopyTexImage().
Fixes gles2conform copy_texture.
---
src/mesa/drivers/common/meta.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 979926a..0e58aec 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2691,12 +2691,26 @@ copy_tex_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
GLenum format, type;
GLint bpp;
void *buf;
+ struct gl_renderbuffer *read_rb = ctx->ReadBuffer->_ColorReadBuffer;
texObj = _mesa_get_current_tex_object(ctx, target);
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
/* Choose format/type for temporary image buffer */
format = _mesa_base_tex_format(ctx, internalFormat);
+
+ if (format == GL_LUMINANCE &&
+ _mesa_get_format_base_format(read_rb->Format) != GL_LUMINANCE) {
+ /* The glReadPixels() path will convert RGB to luminance by
+ * summing R+G+B. glCopyTexImage() is supposed to behave as
+ * glCopyPixels, which doesn't do that change, and instead
+ * leaves it up to glTexImage which converts RGB to luminance by
+ * just taking the R channel. To avoid glReadPixels() trashing
+ * our data, use RGBA for our temporary image.
+ */
+ 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