diff options
author | Marek Olšák <maraeo@gmail.com> | 2010-12-22 00:32:33 +0100 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2010-12-23 16:54:58 +0100 |
commit | eb31837a0d4fa4fe115bb288ddb37cbedea954ae (patch) | |
tree | de384dba7f46628e6a9d24900ce3c030b7067989 | |
parent | bae9d511f343c7bd5eb66d1d1d18d32b47e738e3 (diff) |
mesa: implement new texture format A16
-rw-r--r-- | src/mesa/main/formats.c | 10 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 1 | ||||
-rw-r--r-- | src/mesa/main/texfetch.c | 7 | ||||
-rw-r--r-- | src/mesa/main/texfetch_tmp.h | 24 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 6 | ||||
-rw-r--r-- | src/mesa/main/texgetimage.c | 5 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 13 |
7 files changed, 58 insertions, 8 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 90296f434c..efbd4a2c25 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -285,6 +285,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 1, 1, 1 /* BlockWidth/Height,Bytes */ }, { + MESA_FORMAT_A16, /* Name */ + "MESA_FORMAT_A16", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { MESA_FORMAT_L8, /* Name */ "MESA_FORMAT_L8", /* StrName */ GL_LUMINANCE, /* BaseFormat */ @@ -1297,6 +1306,7 @@ _mesa_format_to_type_and_comps(gl_format format, return; case MESA_FORMAT_R16: + case MESA_FORMAT_A16: *datatype = GL_UNSIGNED_SHORT; *comps = 1; return; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index db63fde3f2..033d2e1e94 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -72,6 +72,7 @@ typedef enum MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ MESA_FORMAT_RGB332, /* RRRG GGBB */ MESA_FORMAT_A8, /* AAAA AAAA */ + MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ MESA_FORMAT_L8, /* LLLL LLLL */ MESA_FORMAT_I8, /* IIII IIII */ MESA_FORMAT_CI8, /* CCCC CCCC */ diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index 5c7e728c13..6a650d1d14 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -286,6 +286,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] = store_texel_a8 }, { + MESA_FORMAT_A16, + fetch_texel_1d_f_a16, + fetch_texel_2d_f_a16, + fetch_texel_3d_f_a16, + store_texel_a16 + }, + { MESA_FORMAT_L8, fetch_texel_1d_f_l8, fetch_texel_2d_f_l8, diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index b6ffdd09f9..3a75cdcefe 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -1148,6 +1148,30 @@ static void store_texel_a8(struct gl_texture_image *texImage, #endif +/* MESA_FORMAT_A16 ************************************************************/ + +/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ +static void FETCH(f_a16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0F; + texel[ACOMP] = USHORT_TO_FLOAT( src[0] ); +} + +#if DIM == 3 +static void store_texel_a16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = rgba[ACOMP]; +} +#endif + + /* MESA_FORMAT_L8 ************************************************************/ /* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index fb738fc635..e10d2e535e 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -102,11 +102,13 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, /* Alpha formats */ case GL_ALPHA: case GL_ALPHA4: - case GL_ALPHA12: - case GL_ALPHA16: case GL_ALPHA8: return MESA_FORMAT_A8; + case GL_ALPHA12: + case GL_ALPHA16: + return MESA_FORMAT_A16; + /* Luminance formats */ case 1: case GL_LUMINANCE: diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index c94f88e16e..428e41009a 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -437,6 +437,11 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixel type == GL_UNSIGNED_BYTE) { memCopy = GL_TRUE; } + else if (texImage->TexFormat == MESA_FORMAT_A16 && + format == GL_ALPHA && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } } if (memCopy) { diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index f9ab946902..107fbf1951 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2357,21 +2357,21 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS) } +/* Texstore for R16, A16. */ static GLboolean -_mesa_texstore_r16(TEXSTORE_PARAMS) +_mesa_texstore_unorm16(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - ASSERT(dstFormat == MESA_FORMAT_R16); + ASSERT(dstFormat == MESA_FORMAT_R16 || + dstFormat == MESA_FORMAT_A16); ASSERT(texelBytes == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_R16 && - baseInternalFormat == GL_RED && - srcFormat == GL_RED && + baseInternalFormat == srcFormat && srcType == GL_UNSIGNED_SHORT && littleEndian) { /* simple memcpy path */ @@ -4048,6 +4048,7 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_AL1616_REV, _mesa_texstore_unorm1616 }, { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 }, { MESA_FORMAT_A8, _mesa_texstore_a8 }, + { MESA_FORMAT_A16, _mesa_texstore_unorm16 }, { MESA_FORMAT_L8, _mesa_texstore_a8 }, { MESA_FORMAT_I8, _mesa_texstore_a8 }, { MESA_FORMAT_CI8, _mesa_texstore_ci8 }, @@ -4056,7 +4057,7 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_R8, _mesa_texstore_a8 }, { MESA_FORMAT_RG88, _mesa_texstore_unorm88 }, { MESA_FORMAT_RG88_REV, _mesa_texstore_unorm88 }, - { MESA_FORMAT_R16, _mesa_texstore_r16 }, + { MESA_FORMAT_R16, _mesa_texstore_unorm16 }, { MESA_FORMAT_RG1616, _mesa_texstore_unorm1616 }, { MESA_FORMAT_RG1616_REV, _mesa_texstore_unorm1616 }, { MESA_FORMAT_ARGB2101010, _mesa_texstore_argb2101010 }, |