mesa: remove gl_texture_format
[mesa.git] / src / mesa / main / texcompress_fxt1.c
index b6991f45ed85c416128b2640cd97c059f4767b8d..7a30806b609e86f7bd75a5dcc06d54482c2080a3 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  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"),
@@ -37,6 +37,7 @@
 #include "image.h"
 #include "mipmap.h"
 #include "texcompress.h"
+#include "texcompress_fxt1.h"
 #include "texformat.h"
 #include "texstore.h"
 
@@ -62,10 +63,10 @@ _mesa_init_texture_fxt1( GLcontext *ctx )
 
 
 /**
- * Called via TexFormat->StoreImage to store an RGB_FXT1 texture.
+ * Store user's image in rgb_fxt1 format.
  */
-static GLboolean
-texstore_rgb_fxt1(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -73,7 +74,7 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgb_fxt1);
+   ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1);
    ASSERT(dstXoffset % 8 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset     == 0);
@@ -87,7 +88,7 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
       /* convert image to RGB/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                             _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -105,7 +106,7 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
 
    fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
@@ -119,10 +120,10 @@ texstore_rgb_fxt1(TEXSTORE_PARAMS)
 
 
 /**
- * Called via TexFormat->StoreImage to store an RGBA_FXT1 texture.
+ * Store user's image in rgba_fxt1 format.
  */
-static GLboolean
-texstore_rgba_fxt1(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
 {
    const GLchan *pixels;
    GLint srcRowStride;
@@ -130,7 +131,7 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
    GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == &_mesa_texformat_rgba_fxt1);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1);
    ASSERT(dstXoffset % 8 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset     == 0);
@@ -144,7 +145,7 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
       /* convert image to RGBA/GLchan */
       tempImage = _mesa_make_temp_chan_image(ctx, dims,
                                              baseInternalFormat,
-                                             dstFormat->BaseFormat,
+                                             _mesa_get_format_base_format(dstFormat),
                                              srcWidth, srcHeight, srcDepth,
                                              srcFormat, srcType, srcAddr,
                                              srcPacking);
@@ -162,7 +163,7 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
    }
 
    dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
-                                        dstFormat->MesaFormat,
+                                        dstFormat,
                                         texWidth, (GLubyte *) dstAddr);
 
    fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
@@ -175,18 +176,18 @@ texstore_rgba_fxt1(TEXSTORE_PARAMS)
 }
 
 
-static void
-fetch_texel_2d_rgba_fxt1( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLchan *texel )
+void
+_mesa_fetch_texel_2d_rgba_fxt1( const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLchan *texel )
 {
    (void) k;
    fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
 }
 
 
-static void
-fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_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];
@@ -199,9 +200,9 @@ fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
 }
 
 
-static void
-fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLchan *texel )
+void
+_mesa_fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLchan *texel )
 {
    (void) k;
    fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
@@ -209,9 +210,9 @@ fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage,
 }
 
 
-static void
-fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
-                           GLint i, GLint j, GLint k, GLfloat *texel )
+void
+_mesa_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];
@@ -225,55 +226,6 @@ fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
 
 
 
-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,                                  /* StencilBits */
-   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 */
-   NULL                                        /* StoreTexel */
-};
-
-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,                                  /* StencilBits */
-   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 */
-   NULL                                        /* StoreTexel */
-};
-
-
 /***************************************************************************\
  * FXT1 encoder
  *
@@ -298,22 +250,17 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
 /*
  * Define a 64-bit unsigned integer type and macros
  */
-#if defined(__GNUC__) && !defined(__cplusplus)
+#if 1
 
 #define FX64_NATIVE 1
 
-#ifdef __MINGW32__
-typedef unsigned long Fx64;
-#else
-typedef unsigned long long Fx64;
-#endif
-
+typedef uint64_t Fx64;
 
 #define FX64_MOV32(a, b) a = b
 #define FX64_OR32(a, b)  a |= b
 #define FX64_SHL(a, c)   a <<= c
 
-#else  /* !__GNUC__ */
+#else
 
 #define FX64_NATIVE 0
 
@@ -335,7 +282,7 @@ typedef struct {
        }                                               \
    } while (0)
 
-#endif /* !__GNUC__ */
+#endif
 
 
 #define F(i) (GLfloat)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */