i965: Fix all non-snb regression in the snb attribute interpolation commit.
[mesa.git] / src / mesa / drivers / dri / tdfx / tdfx_tex.c
index 5e9421aa2ac8058eed1762bef86a75f529776101..1c51452c104b04a221784550a73c419ae6764cfd 100644 (file)
@@ -42,7 +42,6 @@
 #include "main/image.h"
 #include "main/mipmap.h"
 #include "main/texcompress.h"
-#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texstore.h"
 #include "main/texobj.h"
@@ -1397,11 +1396,6 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
     }
 #endif
 
-    /* choose the texture format */
-    assert(ctx->Driver.ChooseTextureFormat);
-    texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                     internalFormat, format, type);
-    assert(texImage->TexFormat);
     mesaFormat = texImage->TexFormat;
     mml->glideFormat = fxGlideFormat(mesaFormat);
     ti->info.format = mml->glideFormat;
@@ -1409,12 +1403,9 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
     texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
     if (_mesa_is_format_compressed(texImage->TexFormat)) {
-       GLuint compressedSize = ctx->Driver.CompressedTextureSize(ctx,
-                                                                 mml->width,
-                                                                 mml->height,
-                                                                 1,
-                                                                 mesaFormat);
-       dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat, mml->width);
+       GLuint compressedSize = _mesa_format_image_size(mesaFormat, mml->width,
+                                                       mml->height, 1);
+       dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
        texImage->Data = _mesa_alloc_texmemory(compressedSize);
     } else {
        dstRowStride = mml->width * texelBytes;
@@ -1492,7 +1483,7 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
 
     texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
     if (_mesa_is_format_compressed(texImage->TexFormat)) {
-       dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat, mml->width);
+       dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
     } else {
        dstRowStride = mml->width * texelBytes;
     }
@@ -1581,7 +1572,7 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
     tdfxTexInfo *ti;
     tdfxMipMapLevel *mml;
     gl_format mesaFormat;
-    GLuint compressedSize;
+    GLuint compressedSize = 0;
 
     if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
         fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x  %dx%d\n",
@@ -1622,12 +1613,6 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
     mml->height = height * mml->hScale;
 
 
-    /* choose the texture format */
-    assert(ctx->Driver.ChooseTextureFormat);
-    texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
-                                           internalFormat, -1/*format*/, -1/*type*/);
-    assert(texImage->TexFormat);
-
     /* Determine the appropriate Glide texel format,
      * given the user's internal texture format hint.
      */
@@ -1638,11 +1623,8 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
 
     /* allocate new storage for texture image, if needed */
     if (!texImage->Data) {
-       compressedSize = ctx->Driver.CompressedTextureSize(ctx,
-                                                          mml->width,
-                                                          mml->height,
-                                                          1,
-                                                          mesaFormat);
+       compressedSize = _mesa_format_image_size(mesaFormat, mml->width,
+                                                mml->height, 1);
        texImage->Data = _mesa_alloc_texmemory(compressedSize);
        if (!texImage->Data) {
           _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
@@ -1667,9 +1649,9 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
         * For now, we take 2) + 3) but texelfetchers will be wrong!
         */
        const GLuint mesaFormat = texImage->TexFormat;
-       GLuint srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
+       GLuint srcRowStride = _mesa_format_row_stride(mesaFormat, width);
  
-       GLuint destRowStride = _mesa_compressed_row_stride(mesaFormat,
+       GLuint destRowStride = _mesa_format_row_stride(mesaFormat,
                                                    mml->width);
  
        _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4,
@@ -1678,7 +1660,7 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
                                 texImage->Data);
        ti->padded = GL_TRUE;
     } else {
-       MEMCPY(texImage->Data, data, compressedSize);
+       memcpy(texImage->Data, data, compressedSize);
     }
 
     RevalidateTexture(ctx, texObj);
@@ -1714,9 +1696,9 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
     mml = TDFX_TEXIMAGE_DATA(texImage);
     assert(mml);
 
-    srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
+    srcRowStride = _mesa_format_row_stride(mesaFormat, width);
 
-    destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
+    destRowStride = _mesa_format_row_stride(mesaFormat, mml->width);
     dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
                                           mesaFormat,
                                           mml->width,
@@ -1725,7 +1707,7 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
     rows = height / 4; /* [dBorca] hardcoded 4, but works for FXT1/DXTC */
 
     for (i = 0; i < rows; i++) {
-       MEMCPY(dest, data, srcRowStride);
+       memcpy(dest, data, srcRowStride);
        dest += destRowStride;
        data = (GLvoid *)((intptr_t)data + (intptr_t)srcRowStride);
     }
@@ -1734,9 +1716,9 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
      * see fxDDCompressedTexImage2D for caveats
      */
     if (mml->wScale != 1 || mml->hScale != 1) {
-       srcRowStride = _mesa_compressed_row_stride(mesaFormat, texImage->Width);
+       srcRowStride = _mesa_format_row_stride(mesaFormat, texImage->Width);
  
-       destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
+       destRowStride = _mesa_format_row_stride(mesaFormat, mml->width);
        _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4,
                                 destRowStride, mml->height / 4,
                                 1, texImage->Data, destRowStride,