diff options
author | Marek Olšák <[email protected]> | 2010-12-21 23:46:32 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2010-12-23 16:54:58 +0100 |
commit | bae9d511f343c7bd5eb66d1d1d18d32b47e738e3 (patch) | |
tree | de35f27d177317ca075b6ad18445ddee0f30d9f6 /src/mesa/main/texstore.c | |
parent | 621e5254ef6714520f106bd3707fe6ddc279aa0c (diff) |
mesa: implement new texture format AL44
Radeon GPUs can do this. R600 can even do render-to-texture.
Packing and extracting aren't implemented, but we shouldn't hit them (I think).
Tested with swrast, softpipe, and r300g.
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r-- | src/mesa/main/texstore.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index b14ffe84b67..f9ab9469022 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2113,6 +2113,52 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) /** + * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm44(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL44); + ASSERT(texelBytes == 1); + + { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstUS = (GLubyte *) dstRow; + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_44( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats. */ static GLboolean @@ -3995,6 +4041,7 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 }, { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 }, { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 }, + { MESA_FORMAT_AL44, _mesa_texstore_unorm44 }, { MESA_FORMAT_AL88, _mesa_texstore_unorm88 }, { MESA_FORMAT_AL88_REV, _mesa_texstore_unorm88 }, { MESA_FORMAT_AL1616, _mesa_texstore_unorm1616 }, |