From: Brian Paul Date: Tue, 27 Apr 2004 13:39:20 +0000 (+0000) Subject: Removed the old teximage code. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f04c12e0ad876baa7eb9ed379e2b00150b376e0;p=mesa.git Removed the old teximage code. Moved all code related to specific texture compression modes into new texcompress_s3tc.c and texcompress_fxt1.c files (but not implemented). --- diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 8da537dd189..a51f6505f39 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -28,6 +28,7 @@ #include "buffers.h" #include "context.h" #include "program.h" +#include "texcompress.h" #include "texformat.h" #include "teximage.h" #include "texobj.h" @@ -90,8 +91,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; - driver->IsCompressedFormat = NULL; /* XXX?? */ - driver->CompressedTextureSize = NULL; /* XXX?? */ + driver->CompressedTextureSize = _mesa_compressed_texture_size; driver->BindTexture = NULL; driver->NewTextureObject = _mesa_new_texture_object; driver->DeleteTexture = _mesa_delete_texture_object; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2328b3726ec..e3cfd5c3f94 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -109,6 +109,7 @@ #include "simple_list.h" #include "state.h" #include "stencil.h" +#include "texcompress.h" #include "teximage.h" #include "texobj.h" #include "texstate.h" @@ -1130,6 +1131,9 @@ init_attrib_groups( GLcontext *ctx ) if (!_mesa_init_texture( ctx )) return GL_FALSE; + _mesa_init_texture_s3tc( ctx ); + _mesa_init_texture_fxt1( ctx ); + /* Miscellaneous */ ctx->NewState = _NEW_ALL; ctx->ErrorValue = (GLenum) GL_NO_ERROR; diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index b2b0bbd2377..c29c27efe6a 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -186,9 +186,8 @@ struct dd_function_table { * functions. The driver should examine \p internalFormat and return a * pointer to an appropriate gl_texture_format. */ - const struct gl_texture_format * - (*ChooseTextureFormat)( GLcontext *ctx, GLint internalFormat, - GLenum srcFormat, GLenum srcType ); + const struct gl_texture_format *(*ChooseTextureFormat)( GLcontext *ctx, + GLint internalFormat, GLenum srcFormat, GLenum srcType ); /** * Called by glTexImage1D(). @@ -454,16 +453,13 @@ struct dd_function_table { GLsizei imageSize, const GLvoid *data, struct gl_texture_object *texObj, struct gl_texture_image *texImage); + /** - * Called to validate a certain compressed format. - */ - GLboolean (*IsCompressedFormat)( GLcontext *ctx, GLenum internalFormat ); - /** - * Called to get bytes of storage needed for the given texture size and - * compressed format. + * Called to query number of bytes of storage needed to store the + * specified compressed texture. */ - GLuint (*CompressedTextureSize)( GLcontext *ctx, - GLsizei width, GLsizei height, GLsizei depth, + GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width, + GLsizei height, GLsizei depth, GLenum format ); /*@}*/ diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 4c6eaae4cf3..3d0326fccac 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -1,13 +1,8 @@ -/** - * \file texcompress.c - * Compressed textures functions. - */ - /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,17 +23,24 @@ */ +/** + * \file texcompress.c + * Helper functions for texture compression. + */ + + #include "glheader.h" #include "imports.h" +#include "colormac.h" #include "context.h" #include "image.h" #include "texcompress.h" #include "texformat.h" - +#include "texstore.h" /** * Get the list of supported internal compression formats. - * + * * \param ctx GL context. * \param formats the resulting format list (may be NULL). * @@ -89,16 +91,19 @@ _mesa_get_compressed_formats( GLcontext *ctx, GLint *formats ) } + /** - * Return bytes of storage needed for the given texture size and - * compressed format. - * + * Return number of bytes needed to store a texture of the given size + * using the specified compressed format. + * This is called via the ctx->Driver.CompressedTextureSize function, + * unless a device driver overrides it. + * * \param width texture width in texels. * \param height texture height in texels. * \param depth texture depth in texels. - * \param texFormat one of the compressed format enums - * - * \return size in bytes, or zero if bad \p texFormat. + * \param format - one of the specific compressed texture formats + * + * \return size in bytes, or zero if bad format */ GLuint _mesa_compressed_texture_size( GLcontext *ctx, @@ -107,10 +112,6 @@ _mesa_compressed_texture_size( GLcontext *ctx, { GLuint size; - if (ctx->Driver.CompressedTextureSize) { - return ctx->Driver.CompressedTextureSize(ctx, width, height, depth, format); - } - ASSERT(depth == 1); switch (format) { @@ -164,7 +165,7 @@ _mesa_compressed_texture_size( GLcontext *ctx, } -/** +/* * Compute the bytes per row in a compressed texture image. * We use this for computing the destination address for sub-texture updates. * \param format one of the specific texture compression formats @@ -201,18 +202,14 @@ _mesa_compressed_row_stride(GLenum format, GLsizei width) } -/** +/* * Return the address of the pixel at (col, row, img) in a * compressed texture image. - * - * \param col image position. - * \param row image position. - * \param img image position. - * \param format compressed image format. - * \param width image width. - * \param image the image address. - * - * \return address of pixel at (row, col). + * \param col, row, img - image position (3D) + * \param format - compressed image format + * \param width - image width + * \param image - the image address + * \return address of pixel at (row, col) */ GLubyte * _mesa_compressed_image_address(GLint col, GLint row, GLint img, @@ -254,21 +251,3 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img, return addr; } - - -/** - * \param srcRowStride source stride, in pixels - */ -void -_mesa_compress_teximage( GLcontext *ctx, GLsizei width, GLsizei height, - GLenum srcFormat, const GLchan *source, - GLint srcRowStride, - const struct gl_texture_format *dstFormat, - GLubyte *dest, GLint dstRowStride ) -{ - switch (dstFormat->MesaFormat) { - default: - _mesa_problem(ctx, "Bad dstFormat in _mesa_compress_teximage()"); - return; - } -} diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h index 457c1d7582d..50074145469 100644 --- a/src/mesa/main/texcompress.h +++ b/src/mesa/main/texcompress.h @@ -1,9 +1,8 @@ - /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 6.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -48,11 +47,13 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img, extern void -_mesa_compress_teximage( GLcontext *ctx, GLsizei width, GLsizei height, - GLenum srcFormat, const GLchan *source, - GLint srcRowStride, - const struct gl_texture_format *dstFormat, - GLubyte *dest, GLint dstRowStride ); +_mesa_init_texture_s3tc( GLcontext *ctx ); + +extern void +_mesa_init_texture_fxt1( GLcontext *ctx ); + + + #else #define _mesa_get_compressed_formats( c, f ) 0 #define _mesa_compressed_texture_size( c, w, h, d, f ) 0 diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c new file mode 100644 index 00000000000..f18f717fc64 --- /dev/null +++ b/src/mesa/main/texcompress_fxt1.c @@ -0,0 +1,155 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texcompress_fxt1.c + * GL_EXT_texture_compression_fxt1 support. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "context.h" +#include "convolve.h" +#include "image.h" +#include "texcompress.h" +#include "texformat.h" +#include "texstore.h" + + +void +_mesa_init_texture_fxt1( GLcontext *ctx ) +{ + /* called during context initialization */ +} + + +static GLboolean +texstore_rgb_fxt1(STORE_PARAMS) +{ + /* XXX to do */ + return GL_FALSE; +} + + +static GLboolean +texstore_rgba_fxt1(STORE_PARAMS) +{ + /* XXX to do */ + return GL_FALSE; +} + + + +static void +fetch_texel_2d_rgba_fxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + /* XXX to do */ +} + + +static void +fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_fxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + /* XXX to do */ +} + + +static void +fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgb_fxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + + +const struct gl_texture_format _mesa_texformat_rgb_fxt1 = { + MESA_FORMAT_RGB_FXT1, /* MesaFormat */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* TexelBytes */ + texstore_rgb_fxt1, /* StoreTexImageFunc */ + NULL, /*impossible*/ /* FetchTexel1D */ + fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */ + NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ +}; + +const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { + MESA_FORMAT_RGBA_FXT1, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 1, /*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* TexelBytes */ + texstore_rgba_fxt1, /* StoreTexImageFunc */ + NULL, /*impossible*/ /* FetchTexel1D */ + fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */ + NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ +}; + diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c new file mode 100644 index 00000000000..35f358a8f38 --- /dev/null +++ b/src/mesa/main/texcompress_s3tc.c @@ -0,0 +1,441 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texcompress_s3tc.c + * GL_EXT_texture_compression_s3tc support. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "context.h" +#include "convolve.h" +#include "image.h" +#include "texcompress.h" +#include "texformat.h" +#include "texstore.h" + + + +void +_mesa_init_texture_s3tc( GLcontext *ctx ) +{ + /* called during context initialization */ +} + + +/** + * Called via TexFormat->StoreImage to store an RGB_DXT1 texture. + */ +static GLboolean +texstore_rgb_dxt1(STORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride / 2; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + + if (srcFormat != GL_RGB || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGB/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + dstFormat->BaseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); + pixels = tempImage; + srcRowStride = 3 * srcWidth; + srcFormat = GL_RGB; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + texWidth, dstAddr); + +#if 0 + compress_dxt1(ctx, srcWidth, srcHeight, srcFormat, pixels, srcRowStride, + dst, dstRowStride); +#endif + + if (tempImage) + _mesa_free((void *) tempImage); + + return GL_TRUE; +} + + +/** + * Called via TexFormat->StoreImage to store an RGBA_DXT1 texture. + */ +static GLboolean +texstore_rgba_dxt1(STORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride / 2; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + dstFormat->BaseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); + pixels = tempImage; + srcRowStride = 4 * srcWidth; + srcFormat = GL_RGBA; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + texWidth, dstAddr); +#if 0 + compress_dxt1(ctx, srcWidth, srcHeight, srcFormat, pixels, srcRowStride, + dst, dstRowStride); +#endif + if (tempImage) + _mesa_free((void*) tempImage); + + return GL_TRUE; +} + + +/** + * Called via TexFormat->StoreImage to store an RGBA_DXT3 texture. + */ +static GLboolean +texstore_rgba_dxt3(STORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride / 4; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + dstFormat->BaseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); + pixels = tempImage; + srcRowStride = 4 * srcWidth; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + texWidth, dstAddr); +#if 0 + compress_rgba_dxt3(ctx, srcWidth, srcHeight, pixels, + srcRowStride, dst, dstRowStride); +#endif + if (tempImage) + _mesa_free((void *) tempImage); + + return GL_TRUE; +} + + +/** + * Called via TexFormat->StoreImage to store an RGBA_DXT5 texture. + */ +static GLboolean +texstore_rgba_dxt5(STORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride / 4; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + dstFormat->BaseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); + pixels = tempImage; + srcRowStride = 4 * srcWidth; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + texWidth, dstAddr); +#if 0 + compress_rgba_dxt5(ctx, srcWidth, srcHeight, pixels, + srcRowStride, dst, dstRowStride); +#endif + if (tempImage) + _mesa_free((void *) tempImage); + + return GL_TRUE; +} + + +static void +fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ +} + + +static void +fetch_texel_2d_f_rgb_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ +} + + +static void +fetch_texel_2d_f_rgba_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ +} + + +static void +fetch_texel_2d_f_rgba_dxt3( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ +} + + +static void +fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +const struct gl_texture_format _mesa_texformat_rgb_dxt1 = { + MESA_FORMAT_RGB_DXT1, /* MesaFormat */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* TexelBytes */ + texstore_rgb_dxt1, /* StoreTexImageFunc */ + NULL, /*impossible*/ /* FetchTexel1D */ + fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */ + NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ +}; + +const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { + MESA_FORMAT_RGBA_DXT1, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 1, /*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* TexelBytes */ + texstore_rgba_dxt1, /* StoreTexImageFunc */ + NULL, /*impossible*/ /* FetchTexel1D */ + fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */ + NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ +}; + +const struct gl_texture_format _mesa_texformat_rgba_dxt3 = { + MESA_FORMAT_RGBA_DXT3, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 4, /*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* TexelBytes */ + texstore_rgba_dxt3, /* StoreTexImageFunc */ + NULL, /*impossible*/ /* FetchTexel1D */ + fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */ + NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ +}; + +const struct gl_texture_format _mesa_texformat_rgba_dxt5 = { + MESA_FORMAT_RGBA_DXT5, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4,/*approx*/ /* RedBits */ + 4,/*approx*/ /* GreenBits */ + 4,/*approx*/ /* BlueBits */ + 4,/*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* TexelBytes */ + texstore_rgba_dxt5, /* StoreTexImageFunc */ + NULL, /*impossible*/ /* FetchTexel1D */ + fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */ + NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ +}; diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 9db53641792..c018e0c8c90 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -863,138 +863,6 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = { fetch_texel_3d_f_ycbcr_rev, /* FetchTexel3Df */ }; -const struct gl_texture_format _mesa_texformat_rgb_fxt1 = { - MESA_FORMAT_RGB_FXT1, /* MesaFormat */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4, /*approx*/ /* RedBits */ - 4, /*approx*/ /* GreenBits */ - 4, /*approx*/ /* BlueBits */ - 0, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* TexelBytes */ - _mesa_texstore_argb8888, /* StoreTexImageFunc */ - NULL, /*impossible*/ /* FetchTexel1D */ - fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */ - NULL, /*impossible*/ /* FetchTexel3D */ - NULL, /*impossible*/ /* FetchTexel1Df */ - fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */ - NULL, /*impossible*/ /* FetchTexel3Df */ -}; - -const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { - MESA_FORMAT_RGBA_FXT1, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4, /*approx*/ /* RedBits */ - 4, /*approx*/ /* GreenBits */ - 4, /*approx*/ /* BlueBits */ - 1, /*approx*/ /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* TexelBytes */ - _mesa_texstore_argb8888, /* StoreTexImageFunc */ - NULL, /*impossible*/ /* FetchTexel1D */ - fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */ - NULL, /*impossible*/ /* FetchTexel3D */ - NULL, /*impossible*/ /* FetchTexel1Df */ - fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */ - NULL, /*impossible*/ /* FetchTexel3Df */ -}; - -const struct gl_texture_format _mesa_texformat_rgb_dxt1 = { - MESA_FORMAT_RGB_DXT1, /* MesaFormat */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4, /*approx*/ /* RedBits */ - 4, /*approx*/ /* GreenBits */ - 4, /*approx*/ /* BlueBits */ - 0, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* TexelBytes */ - _mesa_texstore_argb8888, /* StoreTexImageFunc */ - NULL, /*impossible*/ /* FetchTexel1D */ - fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */ - NULL, /*impossible*/ /* FetchTexel3D */ - NULL, /*impossible*/ /* FetchTexel1Df */ - fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */ - NULL, /*impossible*/ /* FetchTexel3Df */ -}; - -const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { - MESA_FORMAT_RGBA_DXT1, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4, /*approx*/ /* RedBits */ - 4, /*approx*/ /* GreenBits */ - 4, /*approx*/ /* BlueBits */ - 1, /*approx*/ /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* TexelBytes */ - _mesa_texstore_argb8888, /* StoreTexImageFunc */ - NULL, /*impossible*/ /* FetchTexel1D */ - fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */ - NULL, /*impossible*/ /* FetchTexel3D */ - NULL, /*impossible*/ /* FetchTexel1Df */ - fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */ - NULL, /*impossible*/ /* FetchTexel3Df */ -}; - -const struct gl_texture_format _mesa_texformat_rgba_dxt3 = { - MESA_FORMAT_RGBA_DXT3, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4, /*approx*/ /* RedBits */ - 4, /*approx*/ /* GreenBits */ - 4, /*approx*/ /* BlueBits */ - 4, /*approx*/ /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* TexelBytes */ - _mesa_texstore_argb8888, /* StoreTexImageFunc */ - NULL, /*impossible*/ /* FetchTexel1D */ - fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */ - NULL, /*impossible*/ /* FetchTexel3D */ - NULL, /*impossible*/ /* FetchTexel1Df */ - fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */ - NULL, /*impossible*/ /* FetchTexel3Df */ -}; - -const struct gl_texture_format _mesa_texformat_rgba_dxt5 = { - MESA_FORMAT_RGBA_DXT5, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4,/*approx*/ /* RedBits */ - 4,/*approx*/ /* GreenBits */ - 4,/*approx*/ /* BlueBits */ - 4,/*approx*/ /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* TexelBytes */ - _mesa_texstore_argb8888, /* StoreTexImageFunc */ - NULL, /*impossible*/ /* FetchTexel1D */ - fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */ - NULL, /*impossible*/ /* FetchTexel3D */ - NULL, /*impossible*/ /* FetchTexel1Df */ - fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */ - NULL, /*impossible*/ /* FetchTexel3Df */ -}; - /* Big-endian */ #if 0 @@ -1198,27 +1066,6 @@ const struct gl_texture_format _mesa_null_texformat = { /*@}*/ -#if !NEWTEXSTORE -/** - * Determine whether a given texture format is a hardware texture - * format. - * - * \param format texture format. - * - * \return GL_TRUE if \p format is a hardware texture format, or GL_FALSE - * otherwise. - * - * \p format is a hardware texture format if gl_texture_format::MesaFormat is - * lower than _format::MESA_FORMAT_RGBA. - */ -GLboolean -_mesa_is_hardware_tex_format( const struct gl_texture_format *format ) -{ - return (format->MesaFormat < MESA_FORMAT_RGBA); -} -#endif - - /** * Choose an appropriate texture format given the format, type and * internalFormat parameters passed to glTexImage(). @@ -1448,33 +1295,3 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()"); return NULL; } - - -/** - * Return the base texture format for the given compressed format - * - * Called via dd_function_table::Driver.BaseCompressedTexFormat. - * This function is used by software rasterizers. Hardware drivers - * which support texture compression should not use this function but - * a specialized function instead. - */ -GLint -_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat) -{ - switch (intFormat) { - case GL_COMPRESSED_ALPHA_ARB: - return GL_ALPHA; - case GL_COMPRESSED_LUMINANCE_ARB: - return GL_LUMINANCE; - case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: - return GL_LUMINANCE_ALPHA; - case GL_COMPRESSED_INTENSITY_ARB: - return GL_INTENSITY; - case GL_COMPRESSED_RGB_ARB: - return GL_RGB; - case GL_COMPRESSED_RGBA_ARB: - return GL_RGBA; - default: - return -1; /* not a recognized compressed format */ - } -} diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h index cc26b7928a9..d6cd02a16cc 100644 --- a/src/mesa/main/texformat.h +++ b/src/mesa/main/texformat.h @@ -81,18 +81,6 @@ enum _format { MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ /*@}*/ - /** - * \name Compressed texture formats. - */ - /*@{*/ - MESA_FORMAT_RGB_FXT1, - MESA_FORMAT_RGBA_FXT1, - MESA_FORMAT_RGB_DXT1, - MESA_FORMAT_RGBA_DXT1, - MESA_FORMAT_RGBA_DXT3, - MESA_FORMAT_RGBA_DXT5, - /*@}*/ - #if 0 /** * \name Upcoming little-endian formats @@ -111,6 +99,18 @@ enum _format { /*@}*/ #endif + /** + * \name Compressed texture formats. + */ + /*@{*/ + MESA_FORMAT_RGB_FXT1, + MESA_FORMAT_RGBA_FXT1, + MESA_FORMAT_RGB_DXT1, + MESA_FORMAT_RGBA_DXT1, + MESA_FORMAT_RGBA_DXT3, + MESA_FORMAT_RGBA_DXT5, + /*@}*/ + /** * \name Generic GLchan-based formats. * @@ -159,7 +159,7 @@ enum _format { }; -/** The default formats, GLchan per component */ +/** GLchan-valued formats */ /*@{*/ extern const struct gl_texture_format _mesa_texformat_rgba; extern const struct gl_texture_format _mesa_texformat_rgb; @@ -192,7 +192,7 @@ extern const struct gl_texture_format _mesa_texformat_intensity_float32; extern const struct gl_texture_format _mesa_texformat_intensity_float16; /*@}*/ -/** \name The hardware-friendly formats */ +/** \name Assorted hardware-friendly formats */ /*@{*/ extern const struct gl_texture_format _mesa_texformat_rgba8888; extern const struct gl_texture_format _mesa_texformat_argb8888; @@ -206,8 +206,16 @@ extern const struct gl_texture_format _mesa_texformat_a8; extern const struct gl_texture_format _mesa_texformat_l8; extern const struct gl_texture_format _mesa_texformat_i8; extern const struct gl_texture_format _mesa_texformat_ci8; +/*@}*/ + +/** \name YCbCr formats */ +/*@{*/ extern const struct gl_texture_format _mesa_texformat_ycbcr; extern const struct gl_texture_format _mesa_texformat_ycbcr_rev; +/*@}*/ + +/** \name Compressed formats */ +/*@{*/ extern const struct gl_texture_format _mesa_texformat_rgb_fxt1; extern const struct gl_texture_format _mesa_texformat_rgba_fxt1; extern const struct gl_texture_format _mesa_texformat_rgb_dxt1; @@ -222,17 +230,8 @@ extern const struct gl_texture_format _mesa_null_texformat; /*@}*/ -#if !NEWTEXSTORE -extern GLboolean -_mesa_is_hardware_tex_format( const struct gl_texture_format *format ); -#endif - extern const struct gl_texture_format * _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type ); -extern GLint -_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat); - - #endif diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index ba52a8812a4..5c5bf6dc72b 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -1001,115 +1001,6 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, } -#if DIM == 2 /* Only 2D compressed textures possible */ - -static void FETCH(rgb_fxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -static void FETCH(f_rgb_fxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -static void FETCH(rgba_fxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -static void FETCH(f_rgba_fxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -#endif /* if DIM == 2 */ - - -#if DIM == 2 /* only 2D is valid */ - -static void FETCH(rgb_dxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -static void FETCH(f_rgb_dxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - - -static void FETCH(rgba_dxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -static void FETCH(f_rgba_dxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - - -static void FETCH(rgba_dxt3)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -static void FETCH(f_rgba_dxt3)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - - -static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -static void FETCH(f_rgba_dxt5)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* Extract the (i,j) pixel from texImage->Data and return it - * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. - */ -} - -#endif - - /* big-endian */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 978148a5221..1dbab88784f 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -255,8 +255,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) return GL_RGB; case GL_COMPRESSED_RGBA_FXT1_3DFX: return GL_RGBA; - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return GL_RGB; default: ; /* fallthrough */ } @@ -264,6 +262,8 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) if (ctx->Extensions.EXT_texture_compression_s3tc) { switch (internalFormat) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return GL_RGB; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: @@ -312,7 +312,7 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) case GL_LUMINANCE_ALPHA32F_ARB: return GL_LUMINANCE_ALPHA; default: - ; /* nothing */ + ; /* fallthrough */ } } @@ -474,9 +474,6 @@ is_compressed_format(GLcontext *ctx, GLenum internalFormat) case GL_RGBA4_S3TC: return GL_TRUE; default: - if (ctx->Driver.IsCompressedFormat) { - return ctx->Driver.IsCompressedFormat(ctx, internalFormat); - } return GL_FALSE; } } @@ -1000,8 +997,8 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target, img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); img->IsCompressed = is_compressed_format(ctx, internalFormat); if (img->IsCompressed) - img->CompressedSize = _mesa_compressed_texture_size(ctx, width, height, - depth, internalFormat); + img->CompressedSize = ctx->Driver.CompressedTextureSize(ctx, width, + height, depth, internalFormat); else img->CompressedSize = 0; @@ -2756,8 +2753,8 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions, if (level < 0 || level >= maxLevels) return GL_INVALID_VALUE; - expectedSize = _mesa_compressed_texture_size(ctx, width, height, depth, - internalFormat); + expectedSize = ctx->Driver.CompressedTextureSize(ctx, width, height, depth, + internalFormat); if (expectedSize != imageSize) return GL_INVALID_VALUE; @@ -2833,8 +2830,8 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, if ((height & 3) != 0 && height != 2 && height != 1) return GL_INVALID_VALUE; - expectedSize = _mesa_compressed_texture_size(ctx, width, height, depth, - format); + expectedSize = ctx->Driver.CompressedTextureSize(ctx, width, height, depth, + format); if (expectedSize != imageSize) return GL_INVALID_VALUE; diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index ef81dd654a9..d0529b13c3e 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -63,12 +63,8 @@ #include "texformat.h" #include "teximage.h" #include "texstore.h" -#include "texutil.h" - -/*** NEWTEXSTORE ***********************************************************/ - static const GLint ZERO = 1000, ONE = 1001; /** @@ -362,14 +358,14 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, * \param srcPacking source image pixel packing * \return resulting image with format = textureBaseFormat and type = GLchan. */ -static GLchan * -make_temp_chan_image(GLcontext *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) +GLchan * +_mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) { GLuint transferOps = ctx->_ImageTransferState; const GLint components = _mesa_components_in_format(logicalBaseFormat); @@ -640,7 +636,7 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims, } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -859,7 +855,7 @@ _mesa_texstore_rgb565(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -917,7 +913,7 @@ _mesa_texstore_rgba8888(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -977,7 +973,7 @@ _mesa_texstore_argb8888(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -1066,7 +1062,7 @@ _mesa_texstore_rgb888(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -1142,7 +1138,7 @@ _mesa_texstore_argb4444(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -1201,7 +1197,7 @@ _mesa_texstore_argb1555(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -1260,7 +1256,7 @@ _mesa_texstore_al88(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -1312,7 +1308,7 @@ _mesa_texstore_rgb332(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -1370,7 +1366,7 @@ _mesa_texstore_a8(STORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = make_temp_chan_image(ctx, dims, + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, dstFormat->BaseFormat, srcWidth, srcHeight, srcDepth, @@ -1635,688 +1631,6 @@ _mesa_texstore_rgba_float16(STORE_PARAMS) } -#if !NEWTEXSTORE /*****************************************************/ - - -/* - * Given an internal texture format enum or 1, 2, 3, 4 return the - * corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE, - * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. Return the - * number of components for the format. Return -1 if invalid enum. - */ -static GLint -components_in_intformat( GLint format ) -{ - switch (format) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return 1; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return 1; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return 2; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return 1; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return 3; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return 4; - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - return 1; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_SGIX: - case GL_DEPTH_COMPONENT24_SGIX: - case GL_DEPTH_COMPONENT32_SGIX: - return 1; - case GL_YCBCR_MESA: - return 2; /* Y + (Cb or Cr) */ - default: - return -1; /* error */ - } -} - - -/* - * This function is used to transfer the user's image data into a texture - * image buffer. We handle both full texture images and subtexture images. - * We also take care of all image transfer operations here, including - * convolution, scale/bias, colortables, etc. - * - * The destination texel type is always GLchan. - * The destination texel format is one of the 6 basic types. - * - * A hardware driver may use this as a helper routine to unpack and - * apply pixel transfer ops into a temporary image buffer. Then, - * convert the temporary image into the special hardware format. - * - * \param - * dimensions - 1, 2, or 3 - * texDestFormat - GL_LUMINANCE, GL_INTENSITY, GL_LUMINANCE_ALPHA, GL_ALPHA, - * GL_RGB or GL_RGBA (the destination format) - * texDestAddr - destination image address - * srcWidth, srcHeight, srcDepth - size (in pixels) of src and dest images - * dstXoffset, dstYoffset, dstZoffset - position to store the image within - * the destination 3D texture - * dstRowStride, dstImageStride - dest image strides in bytes - * srcFormat - source image format (GL_ALPHA, GL_RED, GL_RGB, etc) - * srcType - GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_FLOAT, etc - * srcPacking - describes packing of incoming image. - * transferOps - mask of pixel transfer operations - */ -static void -transfer_teximage(GLcontext *ctx, GLuint dimensions, - GLenum texDestFormat, GLvoid *texDestAddr, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, - GLint dstRowStride, GLint dstImageStride, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking, - GLuint transferOps) -{ - GLint texComponents; - - ASSERT(ctx); - ASSERT(dimensions >= 1 && dimensions <= 3); - ASSERT(texDestFormat == GL_LUMINANCE || - texDestFormat == GL_INTENSITY || - texDestFormat == GL_LUMINANCE_ALPHA || - texDestFormat == GL_ALPHA || - texDestFormat == GL_RGB || - texDestFormat == GL_RGBA || - texDestFormat == GL_COLOR_INDEX || - texDestFormat == GL_DEPTH_COMPONENT); - ASSERT(texDestAddr); - ASSERT(srcWidth >= 0); - ASSERT(srcHeight >= 0); - ASSERT(srcDepth >= 0); - ASSERT(dstXoffset >= 0); - ASSERT(dstYoffset >= 0); - ASSERT(dstZoffset >= 0); - ASSERT(dstRowStride >= 0); - ASSERT(dstImageStride >= 0); - ASSERT(srcAddr); - ASSERT(srcPacking); - - texComponents = components_in_intformat(texDestFormat); - - /* try common 2D texture cases first */ - if (!transferOps && dimensions == 2 && srcType == CHAN_TYPE) { - - if (srcFormat == texDestFormat) { - /* This will cover the common GL_RGB, GL_RGBA, GL_ALPHA, - * GL_LUMINANCE_ALPHA, etc. texture formats. Use memcpy(). - */ - const GLchan *src = (const GLchan *) _mesa_image_address( - srcPacking, srcAddr, srcWidth, srcHeight, - srcFormat, srcType, 0, 0, 0); - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); - const GLint widthInBytes = srcWidth * texComponents * sizeof(GLchan); - GLchan *dst = (GLchan *) texDestAddr - + dstYoffset * (dstRowStride / sizeof(GLchan)) - + dstXoffset * texComponents; - if (srcRowStride == widthInBytes && dstRowStride == widthInBytes) { - MEMCPY(dst, src, srcHeight * widthInBytes); - } - else { - GLint i; - for (i = 0; i < srcHeight; i++) { - MEMCPY(dst, src, widthInBytes); - src += (srcRowStride / sizeof(GLchan)); - dst += (dstRowStride / sizeof(GLchan)); - } - } - return; /* all done */ - } - else if (srcFormat == GL_RGBA && texDestFormat == GL_RGB) { - /* commonly used by Quake */ - const GLchan *src = (const GLchan *) _mesa_image_address( - srcPacking, srcAddr, srcWidth, srcHeight, - srcFormat, srcType, 0, 0, 0); - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); - GLchan *dst = (GLchan *) texDestAddr - + dstYoffset * (dstRowStride / sizeof(GLchan)) - + dstXoffset * texComponents; - GLint i, j; - for (i = 0; i < srcHeight; i++) { - const GLchan *s = src; - GLchan *d = dst; - for (j = 0; j < srcWidth; j++) { - *d++ = *s++; /*red*/ - *d++ = *s++; /*green*/ - *d++ = *s++; /*blue*/ - s++; /*alpha*/ - } - src += (srcRowStride / sizeof(GLchan)); - dst += (dstRowStride / sizeof(GLchan)); - } - return; /* all done */ - } - } - - /* - * General case solutions - */ - if (texDestFormat == GL_COLOR_INDEX) { - /* color index texture */ - const GLenum texType = CHAN_TYPE; - GLint img, row; - GLchan *dest = (GLchan *) texDestAddr - + dstZoffset * (dstImageStride / sizeof(GLchan)) - + dstYoffset * (dstRowStride / sizeof(GLchan)) - + dstXoffset * texComponents; - for (img = 0; img < srcDepth; img++) { - GLchan *destRow = dest; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_index_span(ctx, srcWidth, texType, destRow, - srcType, src, srcPacking, transferOps); - destRow += (dstRowStride / sizeof(GLchan)); - } - dest += dstImageStride; - } - } - else if (texDestFormat == GL_YCBCR_MESA) { - /* YCbCr texture */ - GLint img, row; - GLushort *dest = (GLushort *) texDestAddr - + dstZoffset * (dstImageStride / sizeof(GLushort)) - + dstYoffset * (dstRowStride / sizeof(GLushort)) - + dstXoffset * texComponents; - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - for (img = 0; img < srcDepth; img++) { - GLushort *destRow = dest; - for (row = 0; row < srcHeight; row++) { - const GLvoid *srcRow = _mesa_image_address(srcPacking, - srcAddr, srcWidth, srcHeight, - srcFormat, srcType, img, row, 0); - MEMCPY(destRow, srcRow, srcWidth * sizeof(GLushort)); - destRow += (dstRowStride / sizeof(GLushort)); - } - dest += dstImageStride / sizeof(GLushort); - } - } - else if (texDestFormat == GL_DEPTH_COMPONENT) { - /* Depth texture (shadow maps) */ - GLint img, row; - GLubyte *dest = (GLubyte *) texDestAddr - + dstZoffset * dstImageStride - + dstYoffset * (dstRowStride / sizeof(GLchan)) - + dstXoffset * texComponents; - for (img = 0; img < srcDepth; img++) { - GLubyte *destRow = dest; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) destRow, - srcType, src, srcPacking); - destRow += (dstRowStride / sizeof(GLchan)); - } - dest += dstImageStride; - } - } - else { - /* regular, color texture */ - if ((dimensions == 1 && ctx->Pixel.Convolution1DEnabled) || - (dimensions >= 2 && ctx->Pixel.Convolution2DEnabled) || - (dimensions >= 2 && ctx->Pixel.Separable2DEnabled)) { - /* - * Fill texture image with convolution - */ - GLint img, row; - GLint convWidth = srcWidth, convHeight = srcHeight; - GLfloat *tmpImage, *convImage; - tmpImage = (GLfloat *) MALLOC(srcWidth * srcHeight * 4 * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); - return; - } - convImage = (GLfloat *) MALLOC(srcWidth * srcHeight * 4 * sizeof(GLfloat)); - if (!convImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); - FREE(tmpImage); - return; - } - - for (img = 0; img < srcDepth; img++) { - const GLfloat *srcf; - GLfloat *dstf = tmpImage; - GLchan *dest; - - /* unpack and do transfer ops up to convolution */ - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(srcPacking, - srcAddr, srcWidth, srcHeight, - srcFormat, srcType, img, row, 0); - _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dstf, - srcFormat, srcType, src, srcPacking, - (transferOps & IMAGE_PRE_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT); - dstf += srcWidth * 4; - } - - /* convolve */ - if (dimensions == 1) { - ASSERT(ctx->Pixel.Convolution1DEnabled); - _mesa_convolve_1d_image(ctx, &convWidth, tmpImage, convImage); - } - else { - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &convWidth, &convHeight, - tmpImage, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &convWidth, &convHeight, - tmpImage, convImage); - } - } - - /* packing and transfer ops after convolution */ - srcf = convImage; - dest = (GLchan *) texDestAddr - + (dstZoffset + img) * (dstImageStride / sizeof(GLchan)) - + dstYoffset * (dstRowStride / sizeof(GLchan)); - for (row = 0; row < convHeight; row++) { - _mesa_pack_rgba_span_float(ctx, convWidth, - (const GLfloat (*)[4]) srcf, - texDestFormat, CHAN_TYPE, - dest, &ctx->DefaultPacking, - transferOps - & IMAGE_POST_CONVOLUTION_BITS); - srcf += convWidth * 4; - dest += (dstRowStride / sizeof(GLchan)); - } - } - - FREE(convImage); - FREE(tmpImage); - } - else { - /* - * no convolution - */ - GLint img, row; - GLchan *dest = (GLchan *) texDestAddr - + dstZoffset * (dstImageStride / sizeof(GLchan)) - + dstYoffset * (dstRowStride / sizeof(GLchan)) - + dstXoffset * texComponents; - for (img = 0; img < srcDepth; img++) { - GLchan *destRow = dest; - for (row = 0; row < srcHeight; row++) { - const GLvoid *srcRow = _mesa_image_address(srcPacking, - srcAddr, srcWidth, srcHeight, - srcFormat, srcType, img, row, 0); - _mesa_unpack_color_span_chan(ctx, srcWidth, texDestFormat, - destRow, srcFormat, srcType, srcRow, - srcPacking, transferOps); - destRow += (dstRowStride / sizeof(GLchan)); - } - dest += dstImageStride / sizeof(GLchan); - } - } - } -} - - - -/* - * Transfer a texture image from user space to applying all - * needed image transfer operations and storing the result in the format - * specified by . may be any format from texformat.h. - * \param - * dimensions - 1, 2 or 3 - * baseInternalFormat - base format of the internal texture format - * specified by the user. This is very important, see below. - * dstFormat - destination image format - * dstAddr - destination address - * srcWidth, srcHeight, srcDepth - size of source iamge - * dstX/Y/Zoffset - as specified by glTexSubImage - * dstRowStride - stride between dest rows in bytes - * dstImageStride - stride between dest images in bytes - * srcFormat, srcType - incoming image format and data type - * srcAddr - source image address - * srcPacking - packing params of source image - * - * XXX this function is a bit more complicated than it should be. If - * _mesa_convert_texsubimage[123]d could handle any dest/source formats - * or if transfer_teximage() could store in any MESA_FORMAT_* format, we - * could simplify things here. - */ -void -_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions, - GLenum baseInternalFormat, - const struct gl_texture_format *dstFormat, - GLvoid *dstAddr, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, - GLint dstRowStride, GLint dstImageStride, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - const GLint dstRowStridePixels = dstRowStride / dstFormat->TexelBytes; - const GLint dstImageStridePixels = dstImageStride / dstFormat->TexelBytes; - GLboolean makeTemp; - GLuint transferOps = ctx->_ImageTransferState; - GLboolean freeSourceData = GL_FALSE; - GLint postConvWidth = srcWidth, postConvHeight = srcHeight; - - assert(baseInternalFormat > 0); - ASSERT(baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_INTENSITY || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_YCBCR_MESA || - baseInternalFormat == GL_COLOR_INDEX || - baseInternalFormat == GL_DEPTH_COMPONENT); - - if (transferOps & IMAGE_CONVOLUTION_BIT) { - _mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth, - &postConvHeight); - } - - /* - * Consider this scenario: The user's source image is GL_RGB and the - * requested internal format is GL_LUMINANCE. Now suppose the device - * driver doesn't support GL_LUMINANCE and instead uses RGB16 as the - * texture format. In that case we still need to do an intermediate - * conversion to luminance format so that the incoming red channel gets - * replicated into the dest red, green and blue channels. The following - * code takes care of that. - */ - if (dstFormat->BaseFormat != baseInternalFormat) { - /* Allocate storage for temporary image in the baseInternalFormat */ - const GLint texelSize = _mesa_components_in_format(baseInternalFormat) - * sizeof(GLchan); - const GLint bytes = texelSize * postConvWidth * postConvHeight *srcDepth; - const GLint tmpRowStride = texelSize * postConvWidth; - const GLint tmpImgStride = texelSize * postConvWidth * postConvHeight; - GLvoid *tmpImage = MALLOC(bytes); - if (!tmpImage) - return; - transfer_teximage(ctx, dimensions, baseInternalFormat, tmpImage, - srcWidth, srcHeight, srcDepth, - 0, 0, 0, /* x/y/zoffset */ - tmpRowStride, tmpImgStride, - srcFormat, srcType, srcAddr, srcPacking, transferOps); - - /* this is our new source image */ - srcWidth = postConvWidth; - srcHeight = postConvHeight; - srcFormat = baseInternalFormat; - srcType = CHAN_TYPE; - srcAddr = tmpImage; - srcPacking = &ctx->DefaultPacking; - freeSourceData = GL_TRUE; - transferOps = 0; /* image transfer ops were completed */ - } - - /* Let the optimized tex conversion functions take a crack at the - * image conversion if the dest format is a h/w format. - */ - if (_mesa_is_hardware_tex_format(dstFormat)) { - if (transferOps) { - makeTemp = GL_TRUE; - } - else { - if (dimensions == 1) { - makeTemp = !_mesa_convert_texsubimage1d(dstFormat->MesaFormat, - dstXoffset, - srcWidth, - srcFormat, srcType, - srcPacking, srcAddr, - dstAddr); - } - else if (dimensions == 2) { - makeTemp = !_mesa_convert_texsubimage2d(dstFormat->MesaFormat, - dstXoffset, dstYoffset, - srcWidth, srcHeight, - dstRowStridePixels, - srcFormat, srcType, - srcPacking, srcAddr, - dstAddr); - } - else { - assert(dimensions == 3); - makeTemp = !_mesa_convert_texsubimage3d(dstFormat->MesaFormat, - dstXoffset, dstYoffset, dstZoffset, - srcWidth, srcHeight, srcDepth, - dstRowStridePixels, dstImageStridePixels, - srcFormat, srcType, - srcPacking, srcAddr, dstAddr); - } - if (!makeTemp) { - /* all done! */ - if (freeSourceData) - FREE((void *) srcAddr); - return; - } - } - } - else { - /* software texture format */ - makeTemp = GL_FALSE; - } - - if (makeTemp) { - GLint postConvWidth = srcWidth, postConvHeight = srcHeight; - GLenum tmpFormat; - GLuint tmpComps, tmpTexelSize; - GLint tmpRowStride, tmpImageStride; - GLubyte *tmpImage; - - if (transferOps & IMAGE_CONVOLUTION_BIT) { - _mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth, - &postConvHeight); - } - - tmpFormat = dstFormat->BaseFormat; - tmpComps = _mesa_components_in_format(tmpFormat); - tmpTexelSize = tmpComps * sizeof(GLchan); - tmpRowStride = postConvWidth * tmpTexelSize; - tmpImageStride = postConvWidth * postConvHeight * tmpTexelSize; - tmpImage = (GLubyte *) MALLOC(postConvWidth * postConvHeight * - srcDepth * tmpTexelSize); - if (!tmpImage) { - if (freeSourceData) - FREE((void *) srcAddr); - return; - } - - transfer_teximage(ctx, dimensions, tmpFormat, tmpImage, - srcWidth, srcHeight, srcDepth, - 0, 0, 0, /* x/y/zoffset */ - tmpRowStride, tmpImageStride, - srcFormat, srcType, srcAddr, srcPacking, transferOps); - - if (freeSourceData) - FREE((void *) srcAddr); - - /* the temp image is our new source image */ - srcWidth = postConvWidth; - srcHeight = postConvHeight; - srcFormat = tmpFormat; - srcType = CHAN_TYPE; - srcAddr = tmpImage; - srcPacking = &ctx->DefaultPacking; - freeSourceData = GL_TRUE; - } - - if (_mesa_is_hardware_tex_format(dstFormat)) { - assert(makeTemp); - if (dimensions == 1) { - GLboolean b; - b = _mesa_convert_texsubimage1d(dstFormat->MesaFormat, - dstXoffset, - srcWidth, - srcFormat, srcType, - srcPacking, srcAddr, - dstAddr); - assert(b); - (void) b; - } - else if (dimensions == 2) { - GLboolean b; - b = _mesa_convert_texsubimage2d(dstFormat->MesaFormat, - dstXoffset, dstYoffset, - srcWidth, srcHeight, - dstRowStridePixels, - srcFormat, srcType, - srcPacking, srcAddr, - dstAddr); - assert(b); - (void) b; - } - else { - GLboolean b; - b = _mesa_convert_texsubimage3d(dstFormat->MesaFormat, - dstXoffset, dstYoffset, dstZoffset, - srcWidth, srcHeight, srcDepth, - dstRowStridePixels, dstImageStridePixels, - srcFormat, srcType, - srcPacking, srcAddr, dstAddr); - assert(b); - (void) b; - } - } - else { - /* software format */ - assert(!makeTemp); - transfer_teximage(ctx, dimensions, dstFormat->BaseFormat, dstAddr, - srcWidth, srcHeight, srcDepth, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageStride, - srcFormat, srcType, srcAddr, srcPacking, transferOps); - } - - if (freeSourceData) - FREE((void *) srcAddr); /* the temp image */ -} - - - -/** - * Given a user's uncompressed texture image, this function takes care of - * pixel unpacking, pixel transfer, format conversion and compression. - */ -static void -transfer_compressed_teximage(GLcontext *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum srcFormat, GLenum srcType, - const struct gl_pixelstore_attrib *unpacking, - const GLvoid *source, - const struct gl_texture_format *dstFormat, - GLubyte *dest, - GLint dstRowStride) -{ - GLchan *tempImage = NULL; - GLint srcRowStride; - GLenum baseFormat; - - ASSERT(dimensions == 2); - /* TexelBytes is zero if and only if it's a compressed format */ - ASSERT(dstFormat->TexelBytes == 0); - - baseFormat = dstFormat->BaseFormat; - - if (srcFormat != baseFormat || srcType != CHAN_TYPE || - ctx->_ImageTransferState != 0 || unpacking->SwapBytes) { - /* need to convert user's image to texImage->Format, GLchan */ - GLint comps = components_in_intformat(baseFormat); - GLint postConvWidth = width, postConvHeight = height; - - /* XXX convolution untested */ - if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { - _mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth, - &postConvHeight); - } - - tempImage = (GLchan*) MALLOC(width * height * comps * sizeof(GLchan)); - if (!tempImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - transfer_teximage(ctx, dimensions, - baseFormat, /* dest format */ - tempImage, /* dst address */ - width, height, depth, /* src size */ - 0, 0, 0, /* x/y/zoffset */ - comps * width, /* dst row stride */ - comps * width * height, /* dst image stride */ - srcFormat, srcType, /* src format, type */ - source, unpacking, /* src and src packing */ - ctx->_ImageTransferState); - source = tempImage; - width = postConvWidth; - height = postConvHeight; - srcRowStride = width; - } - else { - if (unpacking->RowLength) - srcRowStride = unpacking->RowLength; - else - srcRowStride = width; - } - - _mesa_compress_teximage(ctx, width, height, baseFormat, - (const GLchan *) source, srcRowStride, - dstFormat, dest, dstRowStride); - if (tempImage) { - FREE(tempImage); - } -} - - -#endif /************************************************************/ - - - /** * Validate acces to a PBO for texture data. @@ -2414,7 +1728,6 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, if (!pixels) return; -#if NEWTEXSTORE { const GLint dstRowStride = 0, dstImageStride = 0; GLboolean success; @@ -2431,27 +1744,6 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, return; } } -#else - /* unpack image, apply transfer ops and store in texImage->Data */ - if (texImage->IsCompressed) { - GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - width); - transfer_compressed_teximage(ctx, 1, width, 1, 1, - format, type, packing, - pixels, texImage->TexFormat, - (GLubyte *) texImage->Data, dstRowStride); - } - else { - _mesa_transfer_teximage(ctx, 1, - texImage->Format, /* base format */ - texImage->TexFormat, texImage->Data, - width, 1, 1, /* src size */ - 0, 0, 0, /* dstX/Y/Zoffset */ - 0, /* dstRowStride */ - 0, /* dstImageStride */ - format, type, pixels, packing); - } -#endif /* GL_SGIS_generate_mipmap */ if (level == texObj->BaseLevel && texObj->GenerateMipmap) { @@ -2513,7 +1805,6 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, if (!pixels) return; -#if NEWTEXSTORE { GLint dstRowStride, dstImageStride = 0; GLboolean success; @@ -2536,27 +1827,6 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, return; } } -#else - /* unpack image, apply transfer ops and store in texImage->Data */ - if (texImage->IsCompressed) { - GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - width); - transfer_compressed_teximage(ctx, 2, width, height, 1, - format, type, packing, - pixels, texImage->TexFormat, - (GLubyte *) texImage->Data, dstRowStride); - } - else { - _mesa_transfer_teximage(ctx, 2, - texImage->Format, - texImage->TexFormat, texImage->Data, - width, height, 1, /* src size */ - 0, 0, 0, /* dstX/Y/Zoffset */ - texImage->Width * texelBytes, /* dstRowStride */ - 0, /* dstImageStride */ - format, type, pixels, packing); - } -#endif /* GL_SGIS_generate_mipmap */ if (level == texObj->BaseLevel && texObj->GenerateMipmap) { @@ -2610,7 +1880,6 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, return; /* unpack image, apply transfer ops and store in texImage->Data */ -#if NEWTEXSTORE { GLint dstRowStride, dstImageStride; GLboolean success; @@ -2635,26 +1904,6 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, return; } } -#else - if (texImage->IsCompressed) { - GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - width); - transfer_compressed_teximage(ctx, 3, width, height, depth, - format, type, packing, - pixels, texImage->TexFormat, - (GLubyte *) texImage->Data, dstRowStride); - } - else { - _mesa_transfer_teximage(ctx, 3, - texImage->Format, - texImage->TexFormat, texImage->Data, - width, height, depth, /* src size */ - 0, 0, 0, /* dstX/Y/Zoffset */ - texImage->Width * texelBytes, /* dstRowStride */ - texImage->Width * texImage->Height * texelBytes, - format, type, pixels, packing); - } -#endif /* GL_SGIS_generate_mipmap */ if (level == texObj->BaseLevel && texObj->GenerateMipmap) { @@ -2684,7 +1933,6 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, if (!pixels) return; -#if NEWTEXSTORE { const GLint dstRowStride = 0, dstImageStride = 0; GLboolean success; @@ -2701,33 +1949,6 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, return; } } -#else - if (texImage->IsCompressed) { - GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - texImage->Width); - GLubyte *dest = _mesa_compressed_image_address(xoffset, 0, 0, - texImage->IntFormat, - texImage->Width, - (GLubyte*) texImage->Data); - transfer_compressed_teximage(ctx, 1, /* dimensions */ - width, 1, 1, /* size to replace */ - format, type, /* source format/type */ - packing, /* source packing */ - pixels, /* source data */ - texImage->TexFormat,/* dest format */ - dest, dstRowStride); - } - else { - _mesa_transfer_teximage(ctx, 1, - texImage->Format, - texImage->TexFormat, texImage->Data, - width, 1, 1, /* src size */ - xoffset, 0, 0, /* dest offsets */ - 0, /* dstRowStride */ - 0, /* dstImageStride */ - format, type, pixels, packing); - } -#endif /* GL_SGIS_generate_mipmap */ if (level == texObj->BaseLevel && texObj->GenerateMipmap) { @@ -2757,7 +1978,6 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level, if (!pixels) return; -#if NEWTEXSTORE { GLint dstRowStride = 0, dstImageStride = 0; GLboolean success; @@ -2781,35 +2001,6 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level, return; } } -#else - - if (texImage->IsCompressed) { - GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - texImage->Width); - GLubyte *dest = _mesa_compressed_image_address(xoffset, yoffset, 0, - texImage->IntFormat, - texImage->Width, - (GLubyte*) texImage->Data); - transfer_compressed_teximage(ctx, 2, /* dimensions */ - width, height, 1, /* size to replace */ - format, type, /* source format/type */ - packing, /* source packing */ - pixels, /* source data */ - texImage->TexFormat,/* dest format */ - dest, dstRowStride); - } - else { - /* old path */ - _mesa_transfer_teximage(ctx, 2, - texImage->Format, - texImage->TexFormat, texImage->Data, - width, height, 1, /* src size */ - xoffset, yoffset, 0, /* dest offsets */ - texImage->Width *texImage->TexFormat->TexelBytes, - 0, /* dstImageStride */ - format, type, pixels, packing); - } -#endif /* GL_SGIS_generate_mipmap */ if (level == texObj->BaseLevel && texObj->GenerateMipmap) { @@ -2838,7 +2029,6 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level, if (!pixels) return; -#if NEWTEXSTORE { GLint dstRowStride, dstImageStride; GLboolean success; @@ -2864,34 +2054,7 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level, return; } } -#else - if (texImage->IsCompressed) { - GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - texImage->Width); - GLubyte *dest = _mesa_compressed_image_address(xoffset, yoffset, zoffset, - texImage->IntFormat, - texImage->Width, - (GLubyte*) texImage->Data); - transfer_compressed_teximage(ctx, 3, /* dimensions */ - width, height, depth,/* size to replace */ - format, type, /* source format/type */ - packing, /* source packing */ - pixels, /* source data */ - texImage->TexFormat,/* dest format */ - dest, dstRowStride); - } - else { - const GLint texelBytes = texImage->TexFormat->TexelBytes; - _mesa_transfer_teximage(ctx, 3, - texImage->Format, - texImage->TexFormat, texImage->Data, - width, height, depth, /* src size */ - xoffset, yoffset, zoffset, /* dest offsets */ - texImage->Width * texelBytes, /* dst row stride */ - texImage->Width * texImage->Height * texelBytes, - format, type, pixels, packing); - } -#endif + /* GL_SGIS_generate_mipmap */ if (level == texObj->BaseLevel && texObj->GenerateMipmap) { _mesa_generate_mipmap(ctx, target, @@ -2960,6 +2123,13 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level, /* copy the data */ ASSERT(texImage->CompressedSize == (GLuint) imageSize); MEMCPY(texImage->Data, data, imageSize); + + /* GL_SGIS_generate_mipmap */ + if (level == texObj->BaseLevel && texObj->GenerateMipmap) { + _mesa_generate_mipmap(ctx, target, + &ctx->Texture.Unit[ctx->Texture.CurrentUnit], + texObj); + } } @@ -3043,6 +2213,13 @@ _mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target, dest += destRowStride; src += srcRowStride; } + + /* GL_SGIS_generate_mipmap */ + if (level == texObj->BaseLevel && texObj->GenerateMipmap) { + _mesa_generate_mipmap(ctx, target, + &ctx->Texture.Unit[ctx->Texture.CurrentUnit], + texObj); + } } @@ -4015,15 +3192,15 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, GLint dstRowStride = _mesa_compressed_row_stride(srcImage->IntFormat, dstWidth); ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA); - _mesa_compress_teximage(ctx, - dstWidth, dstHeight, /* size */ - srcFormat, /* source format */ - (const GLchan *) dstData, /* source buffer */ - dstWidth, /* source row stride */ - dstImage->TexFormat, /* dest format */ - (GLubyte*) dstImage->Data, /* dest buffer */ - dstRowStride ); /* dest row stride */ - + dstImage->TexFormat->StoreImage(ctx, 2, dstImage->Format, + dstImage->TexFormat, + dstImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, 0, /* strides */ + dstWidth, dstHeight, 1, /* size */ + srcFormat, CHAN_TYPE, + dstData, /* src data, actually */ + &ctx->DefaultPacking); /* swap src and dest pointers */ temp = (GLubyte *) srcData; srcData = dstData; diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index 8ba8101c481..47775a1bb81 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -70,6 +70,23 @@ extern GLboolean _mesa_texstore_ci8(STORE_PARAMS); extern GLboolean _mesa_texstore_ycbcr(STORE_PARAMS); extern GLboolean _mesa_texstore_rgba_float32(STORE_PARAMS); extern GLboolean _mesa_texstore_rgba_float16(STORE_PARAMS); +extern GLboolean _mesa_texstore_rgb_fxt1(STORE_PARAMS); +extern GLboolean _mesa_texstore_rgba_fxt1(STORE_PARAMS); +extern GLboolean _mesa_texstore_rgb_dxt1(STORE_PARAMS); +extern GLboolean _mesa_texstore_rgba_dxt1(STORE_PARAMS); +extern GLboolean _mesa_texstore_rgba_dxt3(STORE_PARAMS); +extern GLboolean _mesa_texstore_rgba_dxt5(STORE_PARAMS); + + +extern GLchan * +_mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking); + #if !NEWTEXSTORE diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c deleted file mode 100644 index 0871c9ec243..00000000000 --- a/src/mesa/main/texutil.c +++ /dev/null @@ -1,1040 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -/* - * Description: - * Functions for texture image conversion. This takes care of converting - * typical GL_RGBA/GLubyte textures into hardware-specific formats. - * We can handle non-standard row strides and pixel unpacking parameters. - */ - - -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "enums.h" -#include "image.h" -#include "imports.h" -#include "macros.h" -#include "mtypes.h" -#include "texformat.h" -#include "texutil.h" - - -#if !NEWTEXSTORE - - -#define DEBUG_TEXUTIL 0 - - -#ifdef MESA_BIG_ENDIAN -#define APPEND16( a, b ) ( (a) << 16 | (b) ) -#else -#define APPEND16( a, b ) ( (a) | (b) << 16 ) -#endif - - -struct convert_info { - GLint xoffset, yoffset, zoffset; /* Subimage offset */ - GLint width, height, depth; /* Subimage region */ - - GLint dstImageWidth, dstImageHeight; /* Dest image size */ - /* Needed for subimage replacement */ - GLenum format, type; /* Source (user) format and type */ - - const struct gl_pixelstore_attrib *unpacking; - - const GLvoid *srcImage; - GLvoid *dstImage; - - GLint index; -}; - -typedef GLboolean (*convert_func)( const struct convert_info *convert ); - -/* bitvalues for convert->index */ -#define CONVERT_STRIDE_BIT 0x1 -#define CONVERT_UNPACKING_BIT 0x2 - - - -/* ============================================================= - * Convert to RGBA8888 textures: - */ - -#define DST_TYPE GLuint -#define DST_TEXELS_PER_DWORD 1 - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_8888_LE( src[3], src[2], src[1], src[0] ) - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_rgba8888_direct -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_8888_LE( src[0], src[1], src[2], src[3] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src ) - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_abgr8888_to_rgba8888 -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_8888_LE( src[0], src[1], src[2], 0xff ) - -#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src ) - -#define SRC_TEXEL_BYTES 3 - -#define TAG(x) x##_bgr888_to_rgba8888 -#include "texutil_tmp.h" - - -#define CONVERT_RGBA8888( name ) \ -static GLboolean \ -convert_##name##_rgba8888( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if ( convert->format == GL_ABGR_EXT && \ - convert->type == GL_UNSIGNED_INT_8_8_8_8_REV ) \ - { \ - tab = name##_tab_rgba8888_direct; \ - } \ - else if ( convert->format == GL_RGBA && \ - ( convert->type == GL_UNSIGNED_BYTE || \ - convert->type == GL_UNSIGNED_INT_8_8_8_8 ) ) \ - { \ - tab = name##_tab_abgr8888_to_rgba8888; \ - } \ - else if ( convert->format == GL_RGB && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_bgr888_to_rgba8888; \ - } \ - else \ - { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - \ - return tab[index]( convert ); \ -} - -CONVERT_RGBA8888( texsubimage2d ) -CONVERT_RGBA8888( texsubimage3d ) - - - -/* ============================================================= - * Convert to ARGB8888 textures: - */ - -#define DST_TYPE GLuint -#define DST_TEXELS_PER_DWORD 1 - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_8888_LE( src[3], src[2], src[1], src[0] ) - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_argb8888_direct -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_8888_LE( src[3], src[0], src[1], src[2] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src ) - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_abgr8888_to_argb8888 -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_8888_LE( 0xff, src[0], src[1], src[2] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src ) - -#define SRC_TEXEL_BYTES 3 - -#define TAG(x) x##_bgr888_to_argb8888 -#include "texutil_tmp.h" - - -#define CONVERT_ARGB8888( name ) \ -static GLboolean \ -convert_##name##_argb8888( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if ( convert->format == GL_BGRA && \ - convert->type == GL_UNSIGNED_INT_8_8_8_8_REV ) \ - { \ - tab = name##_tab_argb8888_direct; \ - } \ - else if ( convert->format == GL_RGBA && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_abgr8888_to_argb8888; \ - } \ - else if ( convert->format == GL_RGB && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_bgr888_to_argb8888; \ - } \ - else \ - { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - \ - return tab[index]( convert ); \ -} - -CONVERT_ARGB8888( texsubimage2d ) -CONVERT_ARGB8888( texsubimage3d ) - - - -/* ============================================================= - * Convert to RGB888 textures: - */ - -static GLboolean -convert_texsubimage2d_rgb888( const struct convert_info *convert ) -{ - /* This is a placeholder for now... - */ - return GL_FALSE; -} - -static GLboolean -convert_texsubimage3d_rgb888( const struct convert_info *convert ) -{ - /* This is a placeholder for now... - */ - return GL_FALSE; -} - - - -/* ============================================================= - * Convert to RGB565 textures: - */ - -#define DST_TYPE GLushort -#define DST_TEXELS_PER_DWORD 2 - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_565_LE( src[0], src[1], src[2] ) - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 2 - -#define TAG(x) x##_rgb565_direct -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_565_LE( src[0], src[1], src[2] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - dst = APPEND16( PACK_COLOR_565_LE( src[0], src[1], src[2] ), \ - PACK_COLOR_565_LE( src[3], src[4], src[5] ) ) - -#define SRC_TEXEL_BYTES 3 - -#define TAG(x) x##_bgr888_to_rgb565 -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_565_LE( src[0], src[1], src[2] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - dst = APPEND16( PACK_COLOR_565_LE( src[0], src[1], src[2] ), \ - PACK_COLOR_565_LE( src[4], src[5], src[6] ) ) - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_abgr8888_to_rgb565 -#include "texutil_tmp.h" - - -#define CONVERT_RGB565( name ) \ -static GLboolean \ -convert_##name##_rgb565( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if ( convert->format == GL_RGB && \ - convert->type == GL_UNSIGNED_SHORT_5_6_5 ) \ - { \ - tab = name##_tab_rgb565_direct; \ - } \ - else if ( convert->format == GL_RGB && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_bgr888_to_rgb565; \ - } \ - else if ( convert->format == GL_RGBA && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_abgr8888_to_rgb565; \ - } \ - else \ - { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - \ - return tab[index]( convert ); \ -} - -CONVERT_RGB565( texsubimage2d ) -CONVERT_RGB565( texsubimage3d ) - - - -/* ============================================================= - * Convert to ARGB4444 textures: - */ - -#define DST_TYPE GLushort -#define DST_TEXELS_PER_DWORD 2 - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_4444_LE( src[3], src[0], src[1], src[2] ) - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 2 - -#define TAG(x) x##_argb4444_direct -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_4444_LE( src[3], src[0], src[1], src[2] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - dst = APPEND16( PACK_COLOR_4444_LE( src[3], src[0], src[1], src[2] ), \ - PACK_COLOR_4444_LE( src[7], src[4], src[5], src[6] ) ) - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_abgr8888_to_argb4444 -#include "texutil_tmp.h" - - -#define CONVERT_ARGB4444( name ) \ -static GLboolean \ -convert_##name##_argb4444( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if ( convert->format == GL_BGRA && \ - convert->type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) \ - { \ - tab = name##_tab_argb4444_direct; \ - } \ - else if ( convert->format == GL_RGBA && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_abgr8888_to_argb4444; \ - } \ - else \ - { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - \ - return tab[index]( convert ); \ -} - -CONVERT_ARGB4444( texsubimage2d ) -CONVERT_ARGB4444( texsubimage3d ) - - - -/* ============================================================= - * Convert to ARGB1555 textures: - */ - -#define DST_TYPE GLushort -#define DST_TEXELS_PER_DWORD 2 - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_1555_LE( src[3], src[0], src[1], src[2] ) - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 2 - -#define TAG(x) x##_argb1555_direct -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#ifdef MESA_BIG_ENDIAN - -#define CONVERT_TEXEL( dst, src ) \ - { const GLushort s = *(GLushort *)src; \ - dst = (s >> 9) | ((s & 0x1ff) << 7); } - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - { const GLuint s = ((fi_type *)src)->i; \ - dst = (((s & 0xfe00fe00) >> 9) | \ - ((s & 0x01ff01ff) << 7)); } - -#else - -#define CONVERT_TEXEL( dst, src ) \ - { const GLushort s = *(GLushort *)src; \ - dst = (s >> 1) | ((s & 1) << 15); } - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - { const GLuint s = ((fi_type *)src)->i; \ - dst = (((s & 0xfffefffe) >> 1) | \ - ((s & 0x00010001) << 15)); } - -#endif - -#define SRC_TEXEL_BYTES 2 - -#define TAG(x) x##_rgba5551_to_argb1555 -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_1555_LE( src[3], src[0], src[1], src[2] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - dst = APPEND16( PACK_COLOR_1555_LE( src[3], src[0], src[1], src[2] ), \ - PACK_COLOR_1555_LE( src[7], src[4], src[5], src[6] ) ) - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_abgr8888_to_argb1555 -#include "texutil_tmp.h" - - -#define CONVERT_ARGB1555( name ) \ -static GLboolean \ -convert_##name##_argb1555( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if ( convert->format == GL_BGRA && \ - convert->type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) \ - { \ - tab = name##_tab_argb1555_direct; \ - } \ - else if ( convert->format == GL_RGBA && \ - convert->type == GL_UNSIGNED_SHORT_5_5_5_1 ) \ - { \ - tab = name##_tab_rgba5551_to_argb1555; \ - } \ - else if ( convert->format == GL_RGBA && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_abgr8888_to_argb1555; \ - } \ - else \ - { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - \ - return tab[index]( convert ); \ -} - -CONVERT_ARGB1555( texsubimage2d ) -CONVERT_ARGB1555( texsubimage3d ) - - - -/* ============================================================= - * AL88 textures: - */ - -#define DST_TYPE GLushort -#define DST_TEXELS_PER_DWORD 2 - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_88_LE( src[0], src[1] ) - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 2 - -#define TAG(x) x##_al88_direct -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_88_LE( src[0], 0x00 ) - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - dst = APPEND16( PACK_COLOR_88_LE( src[0], 0x00 ), \ - PACK_COLOR_88_LE( src[1], 0x00 ) ) - -#define SRC_TEXEL_BYTES 1 - -#define TAG(x) x##_a8_to_al88 -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_88_LE( 0xff, src[0] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - dst = APPEND16( PACK_COLOR_88_LE( 0xff, src[0] ), \ - PACK_COLOR_88_LE( 0xff, src[1] ) ) - -#define SRC_TEXEL_BYTES 1 - -#define TAG(x) x##_l8_to_al88 -#define PRESERVE_DST_TYPE -#include "texutil_tmp.h" - - -#define CONVERT_TEXEL( dst, src ) \ - dst = PACK_COLOR_88_LE( src[3], src[0] ) - -#define CONVERT_TEXEL_DWORD( dst, src ) \ - dst = APPEND16( PACK_COLOR_88_LE( src[3], src[0] ), \ - PACK_COLOR_88_LE( src[7], src[4] ) ) - -#define SRC_TEXEL_BYTES 4 - -#define TAG(x) x##_abgr8888_to_al88 -#include "texutil_tmp.h" - - -#define CONVERT_AL88( name ) \ -static GLboolean \ -convert_##name##_al88( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if ( convert->format == GL_LUMINANCE_ALPHA && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_al88_direct; \ - } \ - else if ( convert->format == GL_ALPHA && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_a8_to_al88; \ - } \ - else if ( convert->format == GL_LUMINANCE && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_l8_to_al88; \ - } \ - else if ( convert->format == GL_RGBA && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_abgr8888_to_al88; \ - } \ - else \ - { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - \ - return tab[index]( convert ); \ -} - -CONVERT_AL88( texsubimage2d ) -CONVERT_AL88( texsubimage3d ) - - - -/* ============================================================= - * Convert to RGB332 textures: - */ - -static GLboolean -convert_texsubimage2d_rgb332( const struct convert_info *convert ) -{ - /* This is a placeholder for now... - */ - return GL_FALSE; -} - -static GLboolean -convert_texsubimage3d_rgb332( const struct convert_info *convert ) -{ - /* This is a placeholder for now... - */ - return GL_FALSE; -} - - - -/* ============================================================= - * CI8 (and all other single-byte texel) textures: - */ - -#define DST_TYPE GLubyte -#define DST_TEXELS_PER_DWORD 4 - -#define CONVERT_TEXEL( dst, src ) dst = src[0] - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 1 - -#define TAG(x) x##_ci8_direct -#include "texutil_tmp.h" - - -#define CONVERT_CI8( name ) \ -static GLboolean \ -convert_##name##_ci8( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if ( ( convert->format == GL_ALPHA || \ - convert->format == GL_LUMINANCE || \ - convert->format == GL_INTENSITY || \ - convert->format == GL_COLOR_INDEX ) && \ - convert->type == GL_UNSIGNED_BYTE ) \ - { \ - tab = name##_tab_ci8_direct; \ - } \ - else \ - { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - \ - return tab[index]( convert ); \ -} - -CONVERT_CI8( texsubimage2d ) -CONVERT_CI8( texsubimage3d ) - - -/* ============================================================= - * convert to YCBCR textures: - */ - -#define DST_TYPE GLushort -#define DST_TEXELS_PER_DWORD 2 - -#define CONVERT_TEXEL( dst, src ) \ - dst = (src[0] << 8) | src[1]; - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 2 - -#define TAG(x) x##_ycbcr_direct -#include "texutil_tmp.h" - - -#define CONVERT_YCBCR( name ) \ -static GLboolean \ -convert_##name##_ycbcr( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if (convert->format != GL_YCBCR_MESA) { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - tab = name##_tab_ycbcr_direct; \ - \ - return tab[index]( convert ); \ -} - -CONVERT_YCBCR( texsubimage2d ) -CONVERT_YCBCR( texsubimage3d ) - - -/* ============================================================= - * convert to YCBCR_REV textures: - */ - -#define DST_TYPE GLushort -#define DST_TEXELS_PER_DWORD 2 - -#define CONVERT_TEXEL( dst, src ) \ - dst = (src[1] << 8) | src[0]; - -#define CONVERT_DIRECT - -#define SRC_TEXEL_BYTES 2 - -#define TAG(x) x##_ycbcr_rev_direct -#include "texutil_tmp.h" - - -#define CONVERT_YCBCR_REV( name ) \ -static GLboolean \ -convert_##name##_ycbcr_rev( const struct convert_info *convert ) \ -{ \ - convert_func *tab; \ - GLint index = convert->index; \ - \ - if (convert->format != GL_YCBCR_MESA) { \ - /* Can't handle this source format/type combination */ \ - return GL_FALSE; \ - } \ - tab = name##_tab_ycbcr_rev_direct; \ - \ - return tab[index]( convert ); \ -} - -CONVERT_YCBCR_REV( texsubimage2d ) -CONVERT_YCBCR_REV( texsubimage3d ) - - - -/* ============================================================= - * Global entry points - */ - -static convert_func convert_texsubimage2d_tab[] = { - convert_texsubimage2d_rgba8888, - convert_texsubimage2d_argb8888, - convert_texsubimage2d_rgb888, - convert_texsubimage2d_rgb565, - convert_texsubimage2d_argb4444, - convert_texsubimage2d_argb1555, - convert_texsubimage2d_al88, - convert_texsubimage2d_rgb332, - convert_texsubimage2d_ci8, /* These are all the same... */ - convert_texsubimage2d_ci8, - convert_texsubimage2d_ci8, - convert_texsubimage2d_ci8, - convert_texsubimage2d_ycbcr, - convert_texsubimage2d_ycbcr_rev, -}; - -static convert_func convert_texsubimage3d_tab[] = { - convert_texsubimage3d_rgba8888, - convert_texsubimage3d_argb8888, - convert_texsubimage3d_rgb888, - convert_texsubimage3d_rgb565, - convert_texsubimage3d_argb4444, - convert_texsubimage3d_argb1555, - convert_texsubimage3d_al88, - convert_texsubimage3d_rgb332, - convert_texsubimage3d_ci8, /* These are all the same... */ - convert_texsubimage3d_ci8, - convert_texsubimage3d_ci8, - convert_texsubimage3d_ci8, - convert_texsubimage3d_ycbcr, - convert_texsubimage3d_ycbcr_rev, -}; - - -/* See if we need to care about the pixel store attributes when we're - * converting the texture image. This should be stored as - * unpacking->_SomeBoolean and updated when the values change, to avoid - * testing every time... - */ -static INLINE GLboolean -convert_needs_unpacking( const struct gl_pixelstore_attrib *unpacking, - GLenum format, GLenum type ) -{ - if ( ( unpacking->Alignment == 1 || - ( unpacking->Alignment == 4 && /* Pick up the common Q3A case... */ - format == GL_RGBA && type == GL_UNSIGNED_BYTE ) ) && - unpacking->RowLength == 0 && - unpacking->SkipPixels == 0 && - unpacking->SkipRows == 0 && - unpacking->ImageHeight == 0 && - unpacking->SkipImages == 0 && - unpacking->SwapBytes == GL_FALSE && - unpacking->LsbFirst == GL_FALSE ) { - return GL_FALSE; - } else { - return GL_TRUE; - } -} - - -GLboolean -_mesa_convert_texsubimage1d( GLint mesaFormat, - GLint xoffset, - GLint width, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpacking, - const GLvoid *srcImage, GLvoid *dstImage ) -{ - struct convert_info convert; - - ASSERT( unpacking ); - ASSERT( srcImage ); - ASSERT( dstImage ); - - ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 ); - ASSERT( mesaFormat <= MESA_FORMAT_YCBCR_REV ); - - /* Make it easier to pass all the parameters around. - */ - convert.xoffset = xoffset; - convert.yoffset = 0; - convert.width = width; - convert.height = 1; - convert.format = format; - convert.type = type; - convert.unpacking = unpacking; - convert.srcImage = srcImage; - convert.dstImage = dstImage; - - convert.index = 0; - - if ( convert_needs_unpacking( unpacking, format, type ) ) - convert.index |= CONVERT_UNPACKING_BIT; - - ASSERT(convert.index < 4); - - return convert_texsubimage2d_tab[mesaFormat]( &convert ); -} - - -/* Convert a user's 2D image into a texture image. This basically - * repacks pixel data into the special texture formats used by core Mesa - * and the DRI drivers. This function can do full images or subimages. - * - * We return a boolean because this function may not accept some kinds - * of source image formats and/or types. For example, if the incoming - * format/type = GL_BGR, GL_UNSIGNED_INT this function probably won't - * be able to do the conversion. - * - * In that case, the incoming image should first be simplified to one of - * the "canonical" formats (GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, - * GL_INTENSITY, GL_RGB, GL_RGBA) and types (GL_CHAN). We can do that - * with the _mesa_transfer_teximage() function. That function will also - * do image transfer operations such as scale/bias and convolution. - * - * \param - * mesaFormat - one of the MESA_FORMAT_* values from texformat.h - * xoffset, yoffset - position in dest image to put data - * width, height - incoming image size, also size of dest region. - * dstImageWidth - width (row stride) of dest image in pixels - * format, type - incoming image format and type - * unpacking - describes incoming image unpacking - * srcImage - pointer to source image - * destImage - pointer to dest image - */ -GLboolean -_mesa_convert_texsubimage2d( GLint mesaFormat, /* dest */ - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLint destImageWidth, - GLenum format, GLenum type, /* source */ - const struct gl_pixelstore_attrib *unpacking, - const GLvoid *srcImage, GLvoid *dstImage ) -{ - struct convert_info convert; - - ASSERT( unpacking ); - ASSERT( srcImage ); - ASSERT( dstImage ); - - ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 ); - ASSERT( mesaFormat <= MESA_FORMAT_YCBCR_REV ); - - /* Make it easier to pass all the parameters around. - */ - convert.xoffset = xoffset; - convert.yoffset = yoffset; - convert.width = width; - convert.height = height; - convert.dstImageWidth = destImageWidth; - convert.format = format; - convert.type = type; - convert.unpacking = unpacking; - convert.srcImage = srcImage; - convert.dstImage = dstImage; - - convert.index = 0; - - if ( convert_needs_unpacking( unpacking, format, type ) ) - convert.index |= CONVERT_UNPACKING_BIT; - - if ( width != destImageWidth ) - convert.index |= CONVERT_STRIDE_BIT; - - return convert_texsubimage2d_tab[mesaFormat]( &convert ); -} - -GLboolean -_mesa_convert_texsubimage3d( GLint mesaFormat, /* dest */ - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLint dstImageWidth, GLint dstImageHeight, - GLenum format, GLenum type, /* source */ - const struct gl_pixelstore_attrib *unpacking, - const GLvoid *srcImage, GLvoid *dstImage ) -{ - struct convert_info convert; - - ASSERT( unpacking ); - ASSERT( srcImage ); - ASSERT( dstImage ); - - ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 ); - ASSERT( mesaFormat <= MESA_FORMAT_YCBCR_REV ); - - /* Make it easier to pass all the parameters around. - */ - convert.xoffset = xoffset; - convert.yoffset = yoffset; - convert.zoffset = zoffset; - convert.width = width; - convert.height = height; - convert.depth = depth; - convert.dstImageWidth = dstImageWidth; - convert.dstImageHeight = dstImageHeight; - convert.format = format; - convert.type = type; - convert.unpacking = unpacking; - convert.srcImage = srcImage; - convert.dstImage = dstImage; - - convert.index = 0; - - if ( convert_needs_unpacking( unpacking, format, type ) ) - convert.index |= CONVERT_UNPACKING_BIT; - - if ( width != dstImageWidth || height != dstImageHeight ) - convert.index |= CONVERT_STRIDE_BIT; - - return convert_texsubimage3d_tab[mesaFormat]( &convert ); -} - -#endif - - - -/* Nearest filtering only (for broken hardware that can't support - * all aspect ratios). This can be made a lot faster, but I don't - * really care enough... - */ -void _mesa_rescale_teximage2d( GLuint bytesPerPixel, GLuint dstRowStride, - GLint srcWidth, GLint srcHeight, - GLint dstWidth, GLint dstHeight, - const GLvoid *srcImage, GLvoid *dstImage ) -{ - GLint row, col; - -#define INNER_LOOP( TYPE, HOP, WOP ) \ - for ( row = 0 ; row < dstHeight ; row++ ) { \ - GLint srcRow = row HOP hScale; \ - for ( col = 0 ; col < dstWidth ; col++ ) { \ - GLint srcCol = col WOP wScale; \ - dst[col] = src[srcRow * srcWidth + srcCol]; \ - } \ - dst = (TYPE *) ((GLubyte *) dst + dstRowStride); \ - } \ - -#define RESCALE_IMAGE( TYPE ) \ -do { \ - const TYPE *src = (const TYPE *)srcImage; \ - TYPE *dst = (TYPE *)dstImage; \ - \ - if ( srcHeight < dstHeight ) { \ - const GLint hScale = dstHeight / srcHeight; \ - if ( srcWidth < dstWidth ) { \ - const GLint wScale = dstWidth / srcWidth; \ - INNER_LOOP( TYPE, /, / ); \ - } \ - else { \ - const GLint wScale = srcWidth / dstWidth; \ - INNER_LOOP( TYPE, /, * ); \ - } \ - } \ - else { \ - const GLint hScale = srcHeight / dstHeight; \ - if ( srcWidth < dstWidth ) { \ - const GLint wScale = dstWidth / srcWidth; \ - INNER_LOOP( TYPE, *, / ); \ - } \ - else { \ - const GLint wScale = srcWidth / dstWidth; \ - INNER_LOOP( TYPE, *, * ); \ - } \ - } \ -} while (0) - - switch ( bytesPerPixel ) { - case 4: - RESCALE_IMAGE( GLuint ); - break; - - case 2: - RESCALE_IMAGE( GLushort ); - break; - - case 1: - RESCALE_IMAGE( GLubyte ); - break; - default: - _mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d"); - } -} diff --git a/src/mesa/main/texutil.h b/src/mesa/main/texutil.h deleted file mode 100644 index 97e629cfb48..00000000000 --- a/src/mesa/main/texutil.h +++ /dev/null @@ -1,72 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - - -#ifndef TEXUTIL_H -#define TEXUTIL_H - -#include "mtypes.h" -#include "texformat.h" - -extern GLboolean -_mesa_convert_texsubimage1d( GLint mesaFormat, - GLint xoffset, - GLint width, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - const GLvoid *srcImage, GLvoid *dstImage ); - -extern GLboolean -_mesa_convert_texsubimage2d( GLint mesaFormat, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLint imageWidth, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - const GLvoid *srcImage, GLvoid *dstImage ); - -extern GLboolean -_mesa_convert_texsubimage3d( GLint mesaFormat, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLint imageWidth, GLint imageHeight, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - const GLvoid *srcImage, GLvoid *dstImage ); - -/* Nearest filtering only (for broken hardware that can't support - * all aspect ratios). FIXME: Make this a subimage update as well... - */ -extern void -_mesa_rescale_teximage2d( GLuint bytesPerPixel, GLuint dstRowStride, - GLint srcWidth, GLint srcHeight, - GLint dstWidth, GLint dstHeight, - const GLvoid *srcImage, GLvoid *dstImage ); - - -#endif diff --git a/src/mesa/main/texutil_tmp.h b/src/mesa/main/texutil_tmp.h deleted file mode 100644 index 0be341c87c3..00000000000 --- a/src/mesa/main/texutil_tmp.h +++ /dev/null @@ -1,526 +0,0 @@ -/** - * \file texutil_tmp.h - * Texture conversion templates. - * - * \author Gareth Hughes - * - * For 2D and 3D texture images, we generate functions for - * - conversion without pixel unpacking and standard stride - * - conversion without pixel unpacking and non-standard stride - * - conversion with pixel unpacking and standard stride - * - conversion with pixel unpacking and non-standard stride - * - * Macros which need to be defined before including this file: - * - \c TAG(x) - the function name wrapper - * - \c DST_TYPE - the destination texel data type (GLuint, GLushort, etc) - * - \c DST_TEXELS_PER_DWORD - number of destination texels that'll fit in 4 bytes - * - \c CONVERT_TEXEL - code to convert from source to destination texel - * - \c CONVER_TEXEL_DWORD - if multiple texels fit in 4 bytes, this macros - * will convert/store multiple texels at once - * - \c CONVERT_DIRECT - if defined, just memcpy texels from source to destination - * - \c SRC_TEXEL_BYTES - bytes per source texel - * - \c PRESERVE_DST_TYPE - if defined, don't undefined these macros at end - * - * \sa convert_func. - */ - -/* - * Mesa 3-D graphics library - * Version: 4.0.2 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#define DST_TEXEL_BYTES (4 / DST_TEXELS_PER_DWORD) -#define DST_ROW_BYTES (convert->width * DST_TEXEL_BYTES) -#define DST_ROW_STRIDE (convert->dstImageWidth * DST_TEXEL_BYTES) -#define DST_IMG_STRIDE (convert->dstImageWidth * \ - convert->dstImageHeight * DST_TEXEL_BYTES) - - -/***************************************************************/ -/** \name Doesn't require pixelstore attributes or stride - * - * \code width == dstImageWidth \endcode - * and - * \code height == dstImageHeight \endcode - * if applicable. - */ -/*@{*/ - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage2d)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *)convert->srcImage; - GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + - (convert->yoffset * convert->dstImageWidth + - convert->xoffset) * DST_TEXEL_BYTES); - -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ "\n" ); -#endif - -#ifdef CONVERT_DIRECT - MEMCPY( dst, src, convert->height * DST_ROW_BYTES ); -#else - { - const GLint texels = convert->width * convert->height; - const GLint dwords = texels / DST_TEXELS_PER_DWORD; - const GLint leftover = texels - dwords * DST_TEXELS_PER_DWORD; - GLint i; - for ( i = 0 ; i < dwords ; i++ ) { - CONVERT_TEXEL_DWORD( *dst++, src ); - src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; - } - for ( i = 0; i < leftover; i++ ) { - CONVERT_TEXEL( *dst++, src ); - src += SRC_TEXEL_BYTES; - } - } -#endif - - return GL_TRUE; -} - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage3d)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *)convert->srcImage; - GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + - ((convert->zoffset * convert->height + - convert->yoffset) * convert->width + - convert->xoffset) * DST_TEXEL_BYTES); -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ "\n" ); -#endif - -#ifdef CONVERT_DIRECT - MEMCPY( dst, src, convert->depth * convert->height * DST_ROW_BYTES ); -#else - { - const GLint texels = convert->width * convert->height * convert->depth; - const GLint dwords = texels / DST_TEXELS_PER_DWORD; - const GLint leftover = texels - dwords * DST_TEXELS_PER_DWORD; - GLint i; - for ( i = 0 ; i < dwords ; i++ ) { - CONVERT_TEXEL_DWORD( *dst++, src ); - src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; - } - for ( i = 0; i < leftover; i++ ) { - CONVERT_TEXEL( *dst++, src ); - src += SRC_TEXEL_BYTES; - } - } -#endif - - return GL_TRUE; -} - -/*@}*/ - - -/***************************************************************/ -/** \name Requires stride but no pixelstore attributes - * - * \code width != dstImageWidth \endcode - * or - * \code height != dstImageHeight \endcode - * if applicable. - */ -/*@{*/ - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage2d_stride)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *)convert->srcImage; - DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + - (convert->yoffset * convert->dstImageWidth + - convert->xoffset) * DST_TEXEL_BYTES); - GLint adjust; - GLint row, col; - - adjust = convert->dstImageWidth - convert->width; - -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ ":\n" ); - _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n", - convert->xoffset, convert->yoffset, convert->width, - convert->height, convert->dstImageWidth ); - _mesa_debug( NULL, " adjust=%d\n", adjust ); -#endif - - for ( row = 0 ; row < convert->height ; row++ ) { - for ( col = 0 ; col < convert->width ; col++ ) { - CONVERT_TEXEL( *dst++, src ); - src += SRC_TEXEL_BYTES; - } - dst += adjust; - } - - return GL_TRUE; -} - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage3d_stride)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *)convert->srcImage; - DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + - ((convert->zoffset * convert->dstImageHeight + - convert->yoffset) * convert->dstImageWidth + - convert->xoffset) * DST_TEXEL_BYTES); - GLint adjust; - GLint row, col, img; - - adjust = convert->dstImageWidth - convert->width; - -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ ":\n" ); - _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n", - convert->xoffset, convert->yoffset, convert->width, - convert->height, convert->dstImageWidth ); - _mesa_debug( NULL, " adjust=%d\n", adjust ); -#endif - - for ( img = 0 ; img < convert->depth ; img++ ) { - for ( row = 0 ; row < convert->height ; row++ ) { - for ( col = 0 ; col < convert->width ; col++ ) { - CONVERT_TEXEL( *dst++, src ); - src += SRC_TEXEL_BYTES; - } - dst += adjust; - } - /* FIXME: ... */ - } - - return GL_TRUE; -} - -/*@}*/ - - -/***************************************************************/ -/** \name Requires pixelstore attributes but no stride. - * - * \code width == dstImageWidth \endcode - * and - * \code height == dstImageHeight \endcode - * if applicable. - */ -/*@{*/ - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage2d_unpack)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *) - _mesa_image_address( convert->unpacking, convert->srcImage, - convert->width, convert->height, - convert->format, convert->type, 0, 0, 0 ); - const GLint srcRowStride = - _mesa_image_row_stride( convert->unpacking, convert->width, - convert->format, convert->type ); - GLint row, col; - -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ "\n" ); -#endif - - if (convert->width & (DST_TEXELS_PER_DWORD - 1)) { - /* Can't use dword conversion (i.e. when width = 1 and texels/dword = 2 - * or width = 2 and texels/dword = 4). - */ - DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + - (convert->yoffset * convert->width + - convert->xoffset) * DST_TEXEL_BYTES); - for ( row = 0 ; row < convert->height ; row++ ) { - const GLubyte *srcRow = src; - for ( col = 0; col < convert->width; col++ ) { - CONVERT_TEXEL(*dst, src); - src += SRC_TEXEL_BYTES; - } - src = srcRow + srcRowStride; - } - } - else { - /* the common case */ - GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + - (convert->yoffset * convert->width + - convert->xoffset) * DST_TEXEL_BYTES); - for ( row = 0 ; row < convert->height ; row++ ) { -#ifdef CONVERT_DIRECT - MEMCPY( dst, src, DST_ROW_STRIDE ); - src += srcRowStride; - dst = (GLuint *)((GLubyte *)dst + DST_ROW_STRIDE); -#else - const GLubyte *srcRow = src; - for ( col = convert->width / DST_TEXELS_PER_DWORD ; col ; col-- ) { - CONVERT_TEXEL_DWORD( *dst++, src ); - src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; - } - src = srcRow + srcRowStride; -#endif - } - } - - return GL_TRUE; -} - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage3d_unpack)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *) - _mesa_image_address( convert->unpacking, convert->srcImage, - convert->width, convert->height, - convert->format, convert->type, 0, 0, 0 ); - const GLint srcImgStride = (const GLubyte *) - _mesa_image_address( convert->unpacking, convert->srcImage, - convert->width, convert->height, - convert->format, convert->type, 1, 0, 0 ) - src; - const GLint srcRowStride = - _mesa_image_row_stride( convert->unpacking, convert->width, - convert->format, convert->type ); - GLint row, col, img; - -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ "\n" ); -#endif - - if (convert->width & (DST_TEXELS_PER_DWORD - 1)) { - /* Can't use dword conversion (i.e. when width = 1 and texels/dword = 2 - * or width = 2 and texels/dword = 4). - */ - DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + - ((convert->zoffset * convert->height + - convert->yoffset) * convert->width + - convert->xoffset) * DST_TEXEL_BYTES); - for ( img = 0 ; img < convert->depth ; img++ ) { - const GLubyte *srcImage = src; - for ( row = 0 ; row < convert->height ; row++ ) { - const GLubyte *srcRow = src; - for ( col = 0; col < convert->width; col++ ) { - CONVERT_TEXEL(*dst, src); - src += SRC_TEXEL_BYTES; - } - src = srcRow + srcRowStride; - } - src = srcImage + srcImgStride; - } - } - else { - /* the common case */ - GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + - ((convert->zoffset * convert->height + - convert->yoffset) * convert->width + - convert->xoffset) * DST_TEXEL_BYTES); - for ( img = 0 ; img < convert->depth ; img++ ) { - const GLubyte *srcImage = src; - for ( row = 0 ; row < convert->height ; row++ ) { -#ifdef CONVERT_DIRECT - MEMCPY( dst, src, DST_ROW_STRIDE ); - src += srcRowStride; - dst = (GLuint *)((GLubyte *)dst + DST_ROW_STRIDE); -#else - const GLubyte *srcRow = src; - for ( col = convert->width / DST_TEXELS_PER_DWORD ; col ; col-- ) { - CONVERT_TEXEL_DWORD( *dst++, src ); - src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; - } - src = srcRow + srcRowStride; -#endif - } - src = srcImage + srcImgStride; - } - } - - return GL_TRUE; -} - -/*@}*/ - - -/***************************************************************/ -/** \name Requires pixelstore attributes and stride. - * - * \code width != dstImageWidth \endcode - * or - * \code height != dstImageHeight \endcode - * if applicable. - */ -/*@{*/ - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *) - _mesa_image_address( convert->unpacking, convert->srcImage, - convert->width, convert->height, - convert->format, convert->type, 0, 0, 0 ); - const GLint srcRowStride = - _mesa_image_row_stride( convert->unpacking, convert->width, - convert->format, convert->type ); - DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + - (convert->yoffset * convert->dstImageWidth + - convert->xoffset) * DST_TEXEL_BYTES); - GLint row; -#ifndef CONVERT_DIRECT - GLint adjust = convert->dstImageWidth - convert->width; -#endif - -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ ":\n" ); - _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n", - convert->xoffset, convert->yoffset, convert->width, - convert->height, convert->dstImageWidth ); -#endif - - for ( row = 0 ; row < convert->height ; row++ ) { -#ifdef CONVERT_DIRECT - MEMCPY( dst, src, DST_ROW_BYTES ); - src += srcRowStride; - dst += convert->dstImageWidth; -#else - const GLubyte *srcRow = src; - GLint col; - for ( col = 0 ; col < convert->width ; col++ ) { - CONVERT_TEXEL( *dst++, src ); - src += SRC_TEXEL_BYTES; - } - src = srcRow + srcRowStride; - dst += adjust; -#endif - } - - return GL_TRUE; -} - -/** \sa convert_func */ -static GLboolean -TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert ) -{ - const GLubyte *src = (const GLubyte *) - _mesa_image_address( convert->unpacking, convert->srcImage, - convert->width, convert->height, - convert->format, convert->type, 0, 0, 0 ); - const GLint srcImgStride = (const GLubyte *) - _mesa_image_address( convert->unpacking, convert->srcImage, - convert->width, convert->height, - convert->format, convert->type, 1, 0, 0 ) - src; - const GLint srcRowStride = - _mesa_image_row_stride( convert->unpacking, convert->width, - convert->format, convert->type ); - DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + - ((convert->zoffset * convert->dstImageHeight + - convert->yoffset) * convert->dstImageWidth + - convert->xoffset) * DST_TEXEL_BYTES); - GLint row, img; -#ifndef CONVERT_DIRECT - GLint adjust = convert->dstImageWidth - convert->width; -#endif - -#if DEBUG_TEXUTIL - _mesa_debug( NULL, __FUNCTION__ ":\n" ); - _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n", - convert->xoffset, convert->yoffset, convert->width, - convert->height, convert->dstImageWidth ); -#endif - - for ( img = 0 ; img < convert->depth ; img++ ) { - const GLubyte *srcImage = src; - for ( row = 0 ; row < convert->height ; row++ ) { -#ifdef CONVERT_DIRECT - MEMCPY( dst, src, DST_ROW_BYTES ); - src += srcRowStride; - dst += convert->dstImageWidth; -#else - const GLubyte *srcRow = src; - GLint col; - for ( col = 0 ; col < convert->width ; col++ ) { - CONVERT_TEXEL( *dst++, src ); - src += SRC_TEXEL_BYTES; - } - src = srcRow + srcRowStride; - dst += adjust; -#endif - } - src = srcImage + srcImgStride; - } - - return GL_TRUE; -} - -/*@}*/ - - -/***********************************************************************/ -/** \name Conversion function tables - */ -/*@{*/ - -/** - * 2D texture conversion functions table. - * - * \sa convert_func. - */ -static convert_func TAG(texsubimage2d_tab)[] = { - TAG(texsubimage2d), - TAG(texsubimage2d_stride), - TAG(texsubimage2d_unpack), - TAG(texsubimage2d_stride_unpack), -}; - -/** - * 3D texture conversion functions table. - * - * \sa convert_func. - */ -static convert_func TAG(texsubimage3d_tab)[] = { - TAG(texsubimage3d), - TAG(texsubimage3d_stride), - TAG(texsubimage3d_unpack), - TAG(texsubimage3d_stride_unpack), -}; - -/*@}*/ - - -#ifndef PRESERVE_DST_TYPE -#undef DST_TYPE -#undef DST_TEXELS_PER_DWORD -#endif - -#undef SRC_TEXEL_BYTES -#undef DST_TEXEL_BYTES -#undef DST_ROW_BYTES -#undef DST_ROW_STRIDE - -#undef CONVERT_TEXEL -#undef CONVERT_TEXEL_DWORD -#undef CONVERT_DIRECT - -#undef TAG - -#undef PRESERVE_DST_TYPE diff --git a/src/mesa/sources b/src/mesa/sources index 14c4205bbd9..cfe97df75fd 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -42,12 +42,13 @@ MAIN_SOURCES = \ main/state.c \ main/stencil.c \ main/texcompress.c \ + main/texcompress_s3tc.c \ + main/texcompress_fxt1.c \ main/texformat.c \ main/teximage.c \ main/texobj.c \ main/texstate.c \ main/texstore.c \ - main/texutil.c \ main/varray.c \ main/vtxfmt.c