diff options
author | Brian Paul <[email protected]> | 2011-09-30 08:15:30 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-09-30 08:16:34 -0600 |
commit | a8ca786ba69f6af0120a24f473b2ae7e6a41495d (patch) | |
tree | 2909eca9a45a420af02ecd0a4c1b63adf216f949 /src/mesa/drivers/common/meta.c | |
parent | 57169c469406f1880107a6b9f052708ce078942d (diff) |
meta: fix GetTexImage() for luminance, l/a, intensity formats
The GL spec says that luminance values are returned as (l, 0, 0, 1),
L/A values as (l, 0, 0, a) and intensity values as (i, 0, 0, 1).
Use the pixel transfer scale controls to implement that.
This fixes a few failures in the new piglit getteximage-formats
test when getting a compressed L or L/A image.
Diffstat (limited to 'src/mesa/drivers/common/meta.c')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 02913685e66..4d645e20083 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -49,6 +49,7 @@ #include "main/macros.h" #include "main/matrix.h" #include "main/mipmap.h" +#include "main/pixel.h" #include "main/pbo.h" #include "main/polygon.h" #include "main/readpix.h" @@ -3235,8 +3236,27 @@ decompress_texture_image(struct gl_context *ctx, } /* read pixels from renderbuffer */ - ctx->Pack.RowLength = destRowLength; - _mesa_ReadPixels(0, 0, width, height, destFormat, destType, dest); + { + GLenum baseTexFormat = texImage->_BaseFormat; + + /* The pixel transfer state will be set to default values at this point + * (see MESA_META_PIXEL_TRANSFER) so pixel transfer ops are effectively + * turned off (as required by glGetTexImage) but we need to handle some + * special cases. In particular, single-channel texture values are + * returned as red and two-channel texture values are returned as + * red/alpha. + */ + if (baseTexFormat == GL_LUMINANCE || + baseTexFormat == GL_LUMINANCE_ALPHA || + baseTexFormat == GL_INTENSITY) { + /* Green and blue must be zero */ + _mesa_PixelTransferf(GL_GREEN_SCALE, 0.0f); + _mesa_PixelTransferf(GL_BLUE_SCALE, 0.0f); + } + + ctx->Pack.RowLength = destRowLength; + _mesa_ReadPixels(0, 0, width, height, destFormat, destType, dest); + } /* disable texture unit */ _mesa_set_enable(ctx, target, GL_FALSE); |