glsl: Add ir_unop_sin_reduced and ir_unop_cos_reduced
[mesa.git] / src / mesa / main / texcompress_s3tc.c
index 9fc73fec5110f5c33241fe7a2dd4870d9e40b696..0e893a59fa3780619f02d6bac958652422aea821 100644 (file)
 #include "glheader.h"
 #include "imports.h"
 #include "colormac.h"
-#include "context.h"
-#include "convolve.h"
 #include "dlopen.h"
 #include "image.h"
+#include "macros.h"
 #include "texcompress.h"
 #include "texcompress_s3tc.h"
 #include "texstore.h"
 
-#ifdef __MINGW32__
+
+#if FEATURE_texture_s3tc
+
+
+#if defined(_WIN32) || defined(WIN32)
 #define DXTN_LIBNAME "dxtn.dll"
 #define RTLD_LAZY 0
 #define RTLD_GLOBAL 0
@@ -74,7 +77,7 @@ nonlinear_to_linear(GLubyte cs8)
             table[i] = cs / 12.92f;
          }
          else {
-            table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
+            table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
          }
       }
       tableReady = GL_TRUE;
@@ -101,7 +104,7 @@ static void *dxtlibhandle = NULL;
 
 
 void
-_mesa_init_texture_s3tc( GLcontext *ctx )
+_mesa_init_texture_s3tc( struct gl_context *ctx )
 {
    /* called during context initialization */
    ctx->Mesa_DXTn = GL_FALSE;
@@ -145,7 +148,6 @@ _mesa_init_texture_s3tc( GLcontext *ctx )
    }
    if (dxtlibhandle) {
       ctx->Mesa_DXTn = GL_TRUE;
-      _mesa_warning(ctx, "software DXTn compression/decompression available");
    }
 #else
    (void) ctx;
@@ -164,7 +166,8 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1);
+   ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 ||
+          dstFormat == MESA_FORMAT_SRGB_DXT1);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -184,7 +187,6 @@ _mesa_texstore_rgb_dxt1(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;
@@ -209,7 +211,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
    }
 
    if (tempImage)
-      _mesa_free((void *) tempImage);
+      free((void *) tempImage);
 
    return GL_TRUE;
 }
@@ -227,7 +229,8 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
+          dstFormat == MESA_FORMAT_SRGBA_DXT1);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -247,7 +250,6 @@ _mesa_texstore_rgba_dxt1(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;
@@ -271,7 +273,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
    }
 
    if (tempImage)
-      _mesa_free((void*) tempImage);
+      free((void*) tempImage);
 
    return GL_TRUE;
 }
@@ -289,7 +291,8 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
+          dstFormat == MESA_FORMAT_SRGBA_DXT3);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -309,7 +312,6 @@ _mesa_texstore_rgba_dxt3(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;
    }
@@ -332,7 +334,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
    }
 
    if (tempImage)
-      _mesa_free((void *) tempImage);
+      free((void *) tempImage);
 
    return GL_TRUE;
 }
@@ -350,7 +352,8 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
    const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
    const GLchan *tempImage = NULL;
 
-   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5);
+   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
+          dstFormat == MESA_FORMAT_SRGBA_DXT5);
    ASSERT(dstXoffset % 4 == 0);
    ASSERT(dstYoffset % 4 == 0);
    ASSERT(dstZoffset % 4 == 0);
@@ -370,7 +373,6 @@ _mesa_texstore_rgba_dxt5(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;
    }
@@ -393,7 +395,7 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
    }
 
    if (tempImage)
-      _mesa_free((void *) tempImage);
+      free((void *) tempImage);
 
    return GL_TRUE;
 }
@@ -564,5 +566,7 @@ _mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage,
    texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
    texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 }
-#endif
+#endif /* FEATURE_EXT_texture_sRGB */
+
 
+#endif /* FEATURE_texture_s3tc */