From 975871b4d5e25ddcd350f4e1600c00d37f65fea1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 16 Nov 2009 14:52:43 -0800 Subject: AL1616: Add texel fetch / store routines --- src/mesa/main/texfetch_tmp.h | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/mesa/main/texfetch_tmp.h') diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index 27434946ec..093e0abc49 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -834,6 +834,54 @@ static void store_texel_al88_rev(struct gl_texture_image *texImage, #endif +/* MESA_FORMAT_AL1616 ********************************************************/ + +/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */ +static void FETCH(f_al1616)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff ); + texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 ); +} + +#if DIM == 3 +static void store_texel_al1616(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLuint *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_AL1616_REV ****************************************************/ + +/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */ +static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 ); + texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff ); +} + +#if DIM == 3 +static void store_texel_al1616_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]); +} +#endif + + /* MESA_FORMAT_RGB332 ********************************************************/ /* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ -- cgit v1.2.3 From 2d0c2952566810ef1b277b49b064f4874a973112 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 17 Nov 2009 08:05:22 +0100 Subject: Add MESA_FORMAT_XRGB8888_REV. --- src/mesa/main/formats.c | 9 +++++++++ src/mesa/main/formats.h | 1 + src/mesa/main/texfetch.c | 7 +++++++ src/mesa/main/texfetch_tmp.h | 24 ++++++++++++++++++++++++ src/mesa/main/texstore.c | 11 ++++++++--- 5 files changed, 49 insertions(+), 3 deletions(-) (limited to 'src/mesa/main/texfetch_tmp.h') diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 7d64c462b1..329b795074 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -132,6 +132,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ 1, 1, 4 /* BlockWidth/Height,Bytes */ }, + { + MESA_FORMAT_XRGB8888_REV, /* Name */ + "MESA_FORMAT_XRGB8888_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, { MESA_FORMAT_RGB888, /* Name */ "MESA_FORMAT_RGB888", /* StrName */ diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index d3ac436b1b..eba28a69be 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -55,6 +55,7 @@ typedef enum MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index c431d3a1db..f4f2be48c3 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -375,6 +375,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] = fetch_texel_3d_f_xrgb8888, store_texel_xrgb8888 }, + { + MESA_FORMAT_XRGB8888_REV, + fetch_texel_1d_f_xrgb8888_rev, + fetch_texel_2d_f_xrgb8888_rev, + fetch_texel_3d_f_xrgb8888_rev, + store_texel_xrgb8888_rev, + }, { MESA_FORMAT_RGB888, fetch_texel_1d_f_rgb888, diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index 093e0abc49..6fac7ba1e1 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -559,6 +559,30 @@ static void store_texel_xrgb8888(struct gl_texture_image *texImage, #endif +/* MESA_FORMAT_XRGB8888_REV **************************************************/ + +/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */ +static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); + texel[ACOMP] = 1.0f; +} + +#if DIM == 3 +static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff); +} +#endif + + /* MESA_FORMAT_RGB888 ********************************************************/ /* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 7cf3287713..abb4ed2663 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1410,7 +1410,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || dstFormat == MESA_FORMAT_ARGB8888_REV || - dstFormat == MESA_FORMAT_XRGB8888); + dstFormat == MESA_FORMAT_XRGB8888 || + dstFormat == MESA_FORMAT_XRGB8888_REV ); ASSERT(texelBytes == 4); if (!ctx->_ImageTransferState && @@ -1431,7 +1432,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) } else if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB8888_REV && + (dstFormat == MESA_FORMAT_ARGB8888_REV || + dstFormat == MESA_FORMAT_XRGB8888_REV) && baseInternalFormat == GL_RGBA && srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || @@ -1524,7 +1526,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) */ if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) || - (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV)) { + (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) { dstmap[3] = 3; /* alpha */ dstmap[2] = 0; /* red */ dstmap[1] = 1; /* green */ @@ -1533,6 +1536,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) else { assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || + (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) || (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888)); dstmap[3] = 2; dstmap[2] = 1; @@ -3133,6 +3137,7 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 }, { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 }, { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 }, + { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 }, { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 }, { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 }, { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 }, -- cgit v1.2.3 From bc8fb028c6c9e7c9bd4f6aaf094a606c447e3711 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 17 Nov 2009 16:15:56 -0700 Subject: mesa: fix incorrect type in store_texel_al1616() --- src/mesa/main/texfetch_tmp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/main/texfetch_tmp.h') diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index 6fac7ba1e1..1f0d436236 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -876,7 +876,7 @@ static void store_texel_al1616(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel) { const GLushort *rgba = (const GLushort *) texel; - GLuint *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]); } #endif -- cgit v1.2.3 From b47f7316dab5eb81bc7e60dc93bb5dbe824c43d4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 2 Dec 2009 12:15:46 -0800 Subject: mesa: Fix copy'n'paste problem in al1616 texel fetch. --- src/mesa/main/texfetch_tmp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/main/texfetch_tmp.h') diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index 1f0d436236..e6772c89f3 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -864,7 +864,7 @@ static void store_texel_al88_rev(struct gl_texture_image *texImage, static void FETCH(f_al1616)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLuint s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff ); -- cgit v1.2.3