Mesa (gallium-mesa-7.4): mesa: fixes for srgb formats
Roland Scheidegger
sroland at kemper.freedesktop.org
Mon Feb 9 22:18:16 UTC 2009
Module: Mesa
Branch: gallium-mesa-7.4
Commit: c98040be3c76c977f1d5ac23f6b2212317db5c80
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c98040be3c76c977f1d5ac23f6b2212317db5c80
Author: Roland Scheidegger <sroland at tungstengraphics.com>
Date: Mon Feb 9 23:10:16 2009 +0100
mesa: fixes for srgb formats
swizzling in fetch/store srgba/sargb functions fixed (consistent with
equivalent non-srgb formats now).
---
src/mesa/main/texformat_tmp.h | 34 ++++++++++++++--------------------
1 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index 08b6d8f..275340c 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -1223,11 +1223,11 @@ static void store_texel_srgb8(struct gl_texture_image *texImage,
static void FETCH(srgba8)(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- texel[RCOMP] = nonlinear_to_linear(src[0]);
- texel[GCOMP] = nonlinear_to_linear(src[1]);
- texel[BCOMP] = nonlinear_to_linear(src[2]);
- texel[ACOMP] = UBYTE_TO_FLOAT(src[3]); /* linear! */
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
+ texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */
}
#if DIM == 3
@@ -1235,11 +1235,8 @@ static void store_texel_srgba8(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
}
#endif
@@ -1247,11 +1244,11 @@ static void store_texel_srgba8(struct gl_texture_image *texImage,
static void FETCH(sargb8)(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- texel[RCOMP] = nonlinear_to_linear(src[1]);
- texel[GCOMP] = nonlinear_to_linear(src[2]);
- texel[BCOMP] = nonlinear_to_linear(src[3]);
- texel[ACOMP] = UBYTE_TO_FLOAT(src[0]); /* linear! */
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
+ texel[BCOMP] = nonlinear_to_linear( (s ) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
}
#if DIM == 3
@@ -1259,11 +1256,8 @@ static void store_texel_sargb8(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- dst[0] = rgba[ACOMP];
- dst[1] = rgba[RCOMP];
- dst[2] = rgba[GCOMP];
- dst[3] = rgba[BCOMP];
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
}
#endif
More information about the mesa-commit
mailing list