glsl: Add ir_unop_sin_reduced and ir_unop_cos_reduced
[mesa.git] / src / mesa / main / texcompress_fxt1.c
index ef42fb92b773807115d748c965b3adc783804c41..33f46d4c8bbeb46af5f4d4a03c85963fbed4f746 100644 (file)
 
 /**
  * \file texcompress_fxt1.c
- * GL_EXT_texture_compression_fxt1 support.
+ * GL_3DFX_texture_compression_FXT1 support.
  */
 
 
 #include "glheader.h"
 #include "imports.h"
 #include "colormac.h"
-#include "context.h"
-#include "convolve.h"
 #include "image.h"
+#include "macros.h"
 #include "mipmap.h"
 #include "texcompress.h"
 #include "texcompress_fxt1.h"
 #include "texstore.h"
 
 
+#if FEATURE_texture_fxt1
+
+
 static void
 fxt1_encode (GLuint width, GLuint height, GLint comps,
              const void *source, GLint srcRowStride,
@@ -51,16 +53,6 @@ fxt1_decode_1 (const void *texture, GLint stride,
                GLint i, GLint j, GLchan *rgba);
 
 
-/**
- * Called during context initialization.
- */
-void
-_mesa_init_texture_fxt1( GLcontext *ctx )
-{
-   (void) ctx;
-}
-
-
 /**
  * Store user's image in rgb_fxt1 format.
  */
@@ -93,7 +85,6 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
                                              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;
@@ -112,7 +103,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
                dst, dstRowStride);
 
    if (tempImage)
-      _mesa_free((void*) tempImage);
+      free((void*) tempImage);
 
    return GL_TRUE;
 }
@@ -150,7 +141,6 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
                                              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;
@@ -169,21 +159,12 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
                dst, dstRowStride);
 
    if (tempImage)
-      _mesa_free((void*) tempImage);
+      free((void*) tempImage);
 
    return GL_TRUE;
 }
 
 
-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);
-}
-
-
 void
 _mesa_fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
                                   GLint i, GLint j, GLint k, GLfloat *texel )
@@ -199,16 +180,6 @@ _mesa_fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
 }
 
 
-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);
-   texel[ACOMP] = 255;
-}
-
-
 void
 _mesa_fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
                                  GLint i, GLint j, GLint k, GLfloat *texel )
@@ -432,7 +403,7 @@ fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv,
    } hist[N_TEXELS];
    GLint lenh = 0;
 
-   _mesa_memset(hist, 0, sizeof(hist));
+   memset(hist, 0, sizeof(hist));
 
    for (k = 0; k < n; k++) {
       GLint l;
@@ -502,7 +473,7 @@ fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv,
     *     for each sample color
     *         sort to nearest vector.
     *
-    *     replace each vector with the centroid of it's matching colors.
+    *     replace each vector with the centroid of its matching colors.
     *
     *     repeat until RMS doesn't improve.
     *
@@ -554,6 +525,7 @@ fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv,
 #else
          GLint best = fxt1_bestcol(vec, nv, input[k], nc, &err);
 #endif
+         assert(best >= 0);
          /* add in closest color */
          for (i = 0; i < nc; i++) {
             sum[best][i] += input[k][i];
@@ -1237,7 +1209,7 @@ fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps)
 
    if (comps == 3) {
       /* make the whole block opaque */
-      _mesa_memset(input, -1, sizeof(input));
+      memset(input, -1, sizeof(input));
    }
 
    /* 8 texels each line */
@@ -1331,7 +1303,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
    if ((width & 7) | (height & 3)) {
       GLint newWidth = (width + 7) & ~7;
       GLint newHeight = (height + 3) & ~3;
-      newSource = _mesa_malloc(comps * newWidth * newHeight * sizeof(GLchan));
+      newSource = malloc(comps * newWidth * newHeight * sizeof(GLchan));
       if (!newSource) {
          GET_CURRENT_CONTEXT(ctx);
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression");
@@ -1350,7 +1322,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
    if (CHAN_TYPE != GL_UNSIGNED_BYTE) {
       const GLuint n = width * height * comps;
       const GLchan *src = (const GLchan *) source;
-      GLubyte *dest = (GLubyte *) _mesa_malloc(n * sizeof(GLubyte));
+      GLubyte *dest = (GLubyte *) malloc(n * sizeof(GLubyte));
       GLuint i;
       if (!dest) {
          GET_CURRENT_CONTEXT(ctx);
@@ -1361,7 +1333,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
          dest[i] = CHAN_TO_UBYTE(src[i]);
       }
       if (newSource != NULL) {
-         _mesa_free(newSource);
+         free(newSource);
       }
       newSource = dest;  /* we'll free this buffer before returning */
       source = dest;  /* the new, GLubyte incoming image */
@@ -1387,7 +1359,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
 
  cleanUp:
    if (newSource != NULL) {
-      _mesa_free(newSource);
+      free(newSource);
    }
 }
 
@@ -1673,3 +1645,6 @@ fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
 
    decode_1[mode](code, t, rgba);
 }
+
+
+#endif /* FEATURE_texture_fxt1 */