diff options
author | Marek Olšák <[email protected]> | 2010-12-22 01:11:13 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2010-12-23 16:54:58 +0100 |
commit | bb5ace68ce9e8bd171a39162ed6bd93632bd6619 (patch) | |
tree | b9e09caf1c2a26ce0b770602143dc69b1f5565d1 /src | |
parent | eb31837a0d4fa4fe115bb288ddb37cbedea954ae (diff) |
mesa: implement new texture format L16
Diffstat (limited to 'src')
-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 | 6 |
7 files changed, 55 insertions, 4 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index efbd4a2c25d..81d907f7a0e 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -303,6 +303,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 1, 1, 1 /* BlockWidth/Height,Bytes */ }, { + MESA_FORMAT_L16, /* Name */ + "MESA_FORMAT_L16", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { MESA_FORMAT_I8, /* Name */ "MESA_FORMAT_I8", /* StrName */ GL_INTENSITY, /* BaseFormat */ @@ -1307,6 +1316,7 @@ _mesa_format_to_type_and_comps(gl_format format, case MESA_FORMAT_R16: case MESA_FORMAT_A16: + case MESA_FORMAT_L16: *datatype = GL_UNSIGNED_SHORT; *comps = 1; return; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 033d2e1e941..afc91e3da46 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -74,6 +74,7 @@ typedef enum MESA_FORMAT_A8, /* AAAA AAAA */ MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ MESA_FORMAT_L8, /* LLLL LLLL */ + MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ MESA_FORMAT_I8, /* IIII IIII */ MESA_FORMAT_CI8, /* CCCC CCCC */ MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index 6a650d1d143..4791e367598 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -300,6 +300,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] = store_texel_l8 }, { + MESA_FORMAT_L16, + fetch_texel_1d_f_l16, + fetch_texel_2d_f_l16, + fetch_texel_3d_f_l16, + store_texel_l16 + }, + { MESA_FORMAT_I8, fetch_texel_1d_f_i8, fetch_texel_2d_f_i8, diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index 3a75cdcefe9..0951f86b7ba 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -1196,6 +1196,30 @@ static void store_texel_l8(struct gl_texture_image *texImage, #endif +/* MESA_FORMAT_L16 ***********************************************************/ + +/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */ +static void FETCH(f_l16)( 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] = USHORT_TO_FLOAT( src[0] ); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_l16(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[RCOMP]; +} +#endif + + /* MESA_FORMAT_I8 ************************************************************/ /* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index e10d2e535e2..c7011431310 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -113,11 +113,13 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, case 1: case GL_LUMINANCE: case GL_LUMINANCE4: - case GL_LUMINANCE12: - case GL_LUMINANCE16: case GL_LUMINANCE8: return MESA_FORMAT_L8; + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return MESA_FORMAT_L16; + /* Luminance/Alpha formats */ case GL_LUMINANCE4_ALPHA4: return MESA_FORMAT_AL44; diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 428e41009ad..71b8ce43f80 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -432,6 +432,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_L16 && + format == GL_LUMINANCE && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } else if (texImage->TexFormat == MESA_FORMAT_A8 && format == GL_ALPHA && type == GL_UNSIGNED_BYTE) { diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 107fbf1951b..e43636eafcb 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2357,7 +2357,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS) } -/* Texstore for R16, A16. */ +/* Texstore for R16, A16, L16. */ static GLboolean _mesa_texstore_unorm16(TEXSTORE_PARAMS) { @@ -2366,7 +2366,8 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS) const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_R16 || - dstFormat == MESA_FORMAT_A16); + dstFormat == MESA_FORMAT_A16 || + dstFormat == MESA_FORMAT_L16); ASSERT(texelBytes == 2); if (!ctx->_ImageTransferState && @@ -4050,6 +4051,7 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_A8, _mesa_texstore_a8 }, { MESA_FORMAT_A16, _mesa_texstore_unorm16 }, { MESA_FORMAT_L8, _mesa_texstore_a8 }, + { MESA_FORMAT_L16, _mesa_texstore_unorm16 }, { MESA_FORMAT_I8, _mesa_texstore_a8 }, { MESA_FORMAT_CI8, _mesa_texstore_ci8 }, { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr }, |