init secondary color to (0,0,0,1). remove some redundant initializations.
[mesa.git] / src / mesa / main / texutil_tmp.h
index 3a225aaac54767e0ccc532febf4d314b8d060e0c..0be341c87c37d7c82f1b296104339bcdac9d7b30 100644 (file)
@@ -1,4 +1,28 @@
-/* $Id: texutil_tmp.h,v 1.11 2002/09/21 16:51:25 brianp Exp $ */
+/**
+ * \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
  * 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.
- *
- * Author:
- *    Gareth Hughes <gareth@valinux.com>
- */
-
-
-/*
- * 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:
- *  TAG(x)  - the function name wrapper
- *  DST_TYPE - the destination texel datatype (GLuint, GLushort, etc)
- *  DST_TEXELS_PER_DWORD - number of dest texels that'll fit in 4 bytes
- *  CONVERT_TEXEL - code to convert from source to dest texel
- *  CONVER_TEXEL_DWORD - if multiple texels fit in 4 bytes, this macros
- *                       will convert/store multiple texels at once
- *  CONVERT_DIRECT - if defined, just memcpy texels from src to dest
- *  SRC_TEXEL_BYTES - bytes per source texel
- *  PRESERVE_DST_TYPE - if defined, don't undefined these macros at end
  */
 
 
                                 convert->dstImageHeight * DST_TEXEL_BYTES)
 
 
-/* =============================================================
- * PRE: No pixelstore attribs, width == dstImageWidth.
+/***************************************************************/
+/** \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 )
 {
@@ -93,8 +101,7 @@ TAG(texsubimage2d)( const struct convert_info *convert )
    return GL_TRUE;
 }
 
-/* PRE: As above, height == dstImageHeight also.
- */
+/** \sa convert_func */
 static GLboolean
 TAG(texsubimage3d)( const struct convert_info *convert )
 {
@@ -129,11 +136,20 @@ TAG(texsubimage3d)( const struct convert_info *convert )
    return GL_TRUE;
 }
 
+/*@}*/
 
 
-/* =============================================================
- * PRE: No pixelstore attribs, width != dstImageWidth.
+/***************************************************************/
+/** \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 )
 {
@@ -165,8 +181,7 @@ TAG(texsubimage2d_stride)( const struct convert_info *convert )
    return GL_TRUE;
 }
 
-/* PRE: As above, or height != dstImageHeight also.
- */
+/** \sa convert_func */
 static GLboolean
 TAG(texsubimage3d_stride)( const struct convert_info *convert )
 {
@@ -202,11 +217,20 @@ TAG(texsubimage3d_stride)( const struct convert_info *convert )
    return GL_TRUE;
 }
 
+/*@}*/
 
 
-/* =============================================================
- * PRE: Require pixelstore attribs, width == dstImageWidth.
+/***************************************************************/
+/** \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 )
 {
@@ -263,8 +287,7 @@ TAG(texsubimage2d_unpack)( const struct convert_info *convert )
    return GL_TRUE;
 }
 
-/* PRE: as above, height == dstImageHeight also.
- */
+/** \sa convert_func */
 static GLboolean
 TAG(texsubimage3d_unpack)( const struct convert_info *convert )
 {
@@ -335,11 +358,20 @@ TAG(texsubimage3d_unpack)( const struct convert_info *convert )
    return GL_TRUE;
 }
 
+/*@}*/
 
 
-/* =============================================================
- * PRE: Require pixelstore attribs, width != dstImageWidth.
+/***************************************************************/
+/** \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 )
 {
@@ -353,18 +385,16 @@ TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert )
    DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
                                (convert->yoffset * convert->dstImageWidth +
                                 convert->xoffset) * DST_TEXEL_BYTES);
-   GLint adjust;
-   GLint row, col;
-   (void) col;
-
-   adjust = convert->dstImageWidth - convert->width;
+   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 );
-   _mesa_debug( NULL, "   adjust=%d\n", adjust );
 #endif
 
    for ( row = 0 ; row < convert->height ; row++ ) {
@@ -374,6 +404,7 @@ TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert )
       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;
@@ -386,8 +417,7 @@ TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert )
    return GL_TRUE;
 }
 
-/* PRE: As above, or height != dstImageHeight also.
- */
+/** \sa convert_func */
 static GLboolean
 TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert )
 {
@@ -406,18 +436,16 @@ TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert )
                                ((convert->zoffset * convert->dstImageHeight +
                                  convert->yoffset) * convert->dstImageWidth +
                                 convert->xoffset) * DST_TEXEL_BYTES);
-   GLint adjust;
-   GLint row, col, img;
-   (void) col;
-
-   adjust = convert->dstImageWidth - convert->width;
+   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 );
-   _mesa_debug( NULL, "   adjust=%d\n", adjust );
 #endif
 
    for ( img = 0 ; img < convert->depth ; img++ ) {
@@ -429,6 +457,7 @@ TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert )
         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;
@@ -443,8 +472,19 @@ TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert )
    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),
@@ -452,6 +492,11 @@ static convert_func TAG(texsubimage2d_tab)[] = {
    TAG(texsubimage2d_stride_unpack),
 };
 
+/**
+ * 3D texture conversion functions table.
+ *
+ * \sa convert_func.
+ */
 static convert_func TAG(texsubimage3d_tab)[] = {
    TAG(texsubimage3d),
    TAG(texsubimage3d_stride),
@@ -459,6 +504,8 @@ static convert_func TAG(texsubimage3d_tab)[] = {
    TAG(texsubimage3d_stride_unpack),
 };
 
+/*@}*/
+
 
 #ifndef PRESERVE_DST_TYPE
 #undef DST_TYPE