fix up radeon span functions using latest r200 code from Brian,
[mesa.git] / src / mesa / drivers / dri / r200 / r200_tex.c
index f64bc2f089dff11d6ef9097b3c140d9ff75bbb80..3d259c2ca668bed10eb172106a4d7457b3f9e906 100644 (file)
@@ -41,7 +41,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "simple_list.h"
 #include "texformat.h"
 #include "texstore.h"
-#include "texutil.h"
 #include "texmem.h"
 #include "teximage.h"
 #include "texobj.h"
@@ -89,13 +88,17 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
    case GL_MIRRORED_REPEAT:
       t->pp_txfilter |= R200_CLAMP_S_MIRROR;
       break;
-   case GL_MIRROR_CLAMP_ATI:
+   case GL_MIRROR_CLAMP_EXT:
       t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_GL;
       is_clamp = GL_TRUE;
       break;
-   case GL_MIRROR_CLAMP_TO_EDGE_ATI:
+   case GL_MIRROR_CLAMP_TO_EDGE_EXT:
       t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_LAST;
       break;
+   case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+      t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_GL;
+      is_clamp_to_border = GL_TRUE;
+      break;
    default:
       _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
    }
@@ -118,13 +121,17 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
    case GL_MIRRORED_REPEAT:
       t->pp_txfilter |= R200_CLAMP_T_MIRROR;
       break;
-   case GL_MIRROR_CLAMP_ATI:
+   case GL_MIRROR_CLAMP_EXT:
       t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_GL;
       is_clamp = GL_TRUE;
       break;
-   case GL_MIRROR_CLAMP_TO_EDGE_ATI:
+   case GL_MIRROR_CLAMP_TO_EDGE_EXT:
       t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_LAST;
       break;
+   case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+      t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_GL;
+      is_clamp_to_border = GL_TRUE;
+      break;
    default:
       _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
    }
@@ -149,13 +156,17 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
    case GL_MIRRORED_REPEAT:
       t->pp_txformat_x |= R200_CLAMP_Q_MIRROR;
       break;
-   case GL_MIRROR_CLAMP_ATI:
+   case GL_MIRROR_CLAMP_EXT:
       t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
       is_clamp = GL_TRUE;
       break;
-   case GL_MIRROR_CLAMP_TO_EDGE_ATI:
+   case GL_MIRROR_CLAMP_TO_EDGE_EXT:
       t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_LAST;
       break;
+   case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+      t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
+      is_clamp_to_border = GL_TRUE;
+      break;
    default:
       _mesa_problem(NULL, "bad R wrap mode in %s", __FUNCTION__);
    }
@@ -313,15 +324,15 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_INT_10_10_10_2:
       case GL_UNSIGNED_INT_2_10_10_10_REV:
-        return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+        return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_argb1555;
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return _dri_texformat_argb4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return _dri_texformat_argb1555;
       default:
-         return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
+         return do32bpt ? _dri_texformat_rgba8888 : _dri_texformat_argb4444;
       }
 
    case 3:
@@ -330,15 +341,15 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       switch ( type ) {
       case GL_UNSIGNED_SHORT_4_4_4_4:
       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return &_mesa_texformat_argb4444;
+        return _dri_texformat_argb4444;
       case GL_UNSIGNED_SHORT_5_5_5_1:
       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return &_mesa_texformat_argb1555;
+        return _dri_texformat_argb1555;
       case GL_UNSIGNED_SHORT_5_6_5:
       case GL_UNSIGNED_SHORT_5_6_5_REV:
-        return &_mesa_texformat_rgb565;
+        return _dri_texformat_rgb565;
       default:
-         return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
+         return do32bpt ? _dri_texformat_rgba8888 : _dri_texformat_rgb565;
       }
 
    case GL_RGBA8:
@@ -346,25 +357,25 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGBA12:
    case GL_RGBA16:
       return !force16bpt ?
-         &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
+         _dri_texformat_rgba8888 : _dri_texformat_argb4444;
 
    case GL_RGBA4:
    case GL_RGBA2:
-      return &_mesa_texformat_argb4444;
+      return _dri_texformat_argb4444;
 
    case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
+      return _dri_texformat_argb1555;
 
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return !force16bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
+      return !force16bpt ? _dri_texformat_rgba8888 : _dri_texformat_rgb565;
 
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-      return &_mesa_texformat_rgb565;
+      return _dri_texformat_rgb565;
 
    case GL_ALPHA:
    case GL_ALPHA4:
@@ -372,7 +383,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_ALPHA12:
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
-      return &_mesa_texformat_al88;
+      return _dri_texformat_a8;
 
    case 1:
    case GL_LUMINANCE:
@@ -381,7 +392,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
-      return &_mesa_texformat_al88;
+      return _dri_texformat_l8;
 
    case 2:
    case GL_LUMINANCE_ALPHA:
@@ -392,7 +403,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return &_mesa_texformat_al88;
+      return _dri_texformat_al88;
 
    case GL_INTENSITY:
    case GL_INTENSITY4:
@@ -400,21 +411,35 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      /* At the moment, glean & conform both fail using the i8 internal
-       * format.
-       */
-      return &_mesa_texformat_al88;
-/*       return &_mesa_texformat_i8; */
+       return _dri_texformat_i8;
 
    case GL_YCBCR_MESA:
       if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
-         type == GL_UNSIGNED_BYTE)
+          type == GL_UNSIGNED_BYTE)
          return &_mesa_texformat_ycbcr;
       else
          return &_mesa_texformat_ycbcr_rev;
 
+   case GL_RGB_S3TC:
+   case GL_RGB4_S3TC:
+   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+      return &_mesa_texformat_rgb_dxt1;
+
+   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+      return &_mesa_texformat_rgba_dxt1;
+
+   case GL_RGBA_S3TC:
+   case GL_RGBA4_S3TC:
+   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+      return &_mesa_texformat_rgba_dxt3;
+
+   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+      return &_mesa_texformat_rgba_dxt5;
+
    default:
-      _mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__);
+      _mesa_problem(ctx,
+         "unexpected internalFormat 0x%x in r200ChooseTextureFormat",
+         (int) internalFormat);
       return NULL;
    }
 
@@ -433,7 +458,6 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
 
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   int texelBytes;
 
    if (0)
       fprintf(stderr, "intformat %s format %s type %s\n",
@@ -455,8 +479,7 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
    switch ( internalFormat ) {
    case GL_RGBA:
       if ( format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
-        texImage->TexFormat = &_mesa_texformat_argb8888;
-        texelBytes = 4;
+        texImage->TexFormat = _dri_texformat_argb8888;
       }
       else
         return 0;
@@ -464,8 +487,7 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
 
    case GL_RGB:
       if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
-        texImage->TexFormat = &_mesa_texformat_rgb565;
-        texelBytes = 2;
+        texImage->TexFormat = _dri_texformat_rgb565;
       }
       else
         return 0;
@@ -475,19 +497,16 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
       if ( format == GL_YCBCR_MESA && 
           type == GL_UNSIGNED_SHORT_8_8_REV_APPLE ) {
         texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
-        texelBytes = 2;
       }
       else if ( format == GL_YCBCR_MESA && 
                (type == GL_UNSIGNED_SHORT_8_8_APPLE || 
                 type == GL_UNSIGNED_BYTE)) {
         texImage->TexFormat = &_mesa_texformat_ycbcr;
-        texelBytes = 2;
       }
       else
         return 0;
       break;
-      
-        
+
    default:
       return 0;
    }
@@ -526,7 +545,8 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
        */
       texImage->Data = (void *)pixels;
       texImage->IsClientData = GL_TRUE;
-      texImage->RowStride = srcRowStride / texelBytes;
+      texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
+
       return 1;
    }
 }
@@ -671,7 +691,6 @@ static void r200TexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
    driTextureObject * t = (driTextureObject *) texObj->DriverData;
    GLuint face;
 
-
    /* which cube face or ordinary 2D image */
    switch (target) {
    case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
@@ -707,6 +726,116 @@ static void r200TexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
 }
 
 
+static void r200CompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+                              GLint internalFormat,
+                              GLint width, GLint height, GLint border,
+                              GLsizei imageSize, const GLvoid *data,
+                              struct gl_texture_object *texObj,
+                              struct gl_texture_image *texImage )
+{
+   driTextureObject * t = (driTextureObject *) texObj->DriverData;
+   GLuint face;
+
+   /* which cube face or ordinary 2D image */
+   switch (target) {
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+      ASSERT(face < 6);
+      break;
+   default:
+      face = 0;
+   }
+
+   if ( t != NULL ) {
+      driSwapOutTextureObject( t );
+   }
+   else {
+      t = (driTextureObject *) r200AllocTexObj( texObj );
+      if (!t) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+         return;
+      }
+   }
+
+   texImage->IsClientData = GL_FALSE;
+/* can't call this, different parameters. Would never evaluate to true anyway currently
+   if (r200ValidateClientStorage( ctx, target, 
+                                 internalFormat,
+                                 width, height,
+                                 format, type, pixels,
+                                 packing, texObj, texImage)) {
+      if (R200_DEBUG & DEBUG_TEXTURE)
+        fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
+   }
+   else */{
+      if (R200_DEBUG & DEBUG_TEXTURE)
+        fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
+
+      /* Normal path: copy (to cached memory) and eventually upload
+       * via another copy to GART memory and then a blit...  Could
+       * eliminate one copy by going straight to (permanent) GART.
+       *
+       * Note, this will call r200ChooseTextureFormat.
+       */
+      _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
+                                 height, border, imageSize, data, texObj, texImage);
+
+      t->dirty_images[face] |= (1 << level);
+   }
+}
+
+
+static void r200CompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
+                                 GLint xoffset, GLint yoffset,
+                                 GLsizei width, GLsizei height,
+                                 GLenum format,
+                                 GLsizei imageSize, const GLvoid *data,
+                                 struct gl_texture_object *texObj,
+                                 struct gl_texture_image *texImage )
+{
+   driTextureObject * t = (driTextureObject *) texObj->DriverData;
+   GLuint face;
+
+
+   /* which cube face or ordinary 2D image */
+   switch (target) {
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+      ASSERT(face < 6);
+      break;
+   default:
+      face = 0;
+   }
+
+   assert( t ); /* this _should_ be true */
+   if ( t ) {
+      driSwapOutTextureObject( t );
+   }
+   else {
+      t = (driTextureObject *) r200AllocTexObj( texObj );
+      if (!t) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
+         return;
+      }
+   }
+
+   _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+                            height, format, imageSize, data, texObj, texImage);
+
+   t->dirty_images[face] |= (1 << level);
+}
+
+
 #if ENABLE_HW_3D_TEXTURE
 static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
                             GLint internalFormat,
@@ -723,7 +852,7 @@ static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
       driSwapOutTextureObject( t );
    }
    else {
-      t = r200AllocTexObj( texObj );
+      t = (driTextureObject *) r200AllocTexObj( texObj );
       if (!t) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
          return;
@@ -784,7 +913,7 @@ r200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
       driSwapOutTextureObject( t );
    }
    else {
-      t = r200AllocTexObj(texObj);
+      t = (driTextureObject *) r200AllocTexObj( texObj );
       if (!t) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
          return;
@@ -877,10 +1006,6 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
               _mesa_lookup_enum_by_nr( pname ) );
    }
 
-   if ( ( target != GL_TEXTURE_2D ) &&
-       ( target != GL_TEXTURE_1D ) )
-      return;
-
    switch ( pname ) {
    case GL_TEXTURE_MIN_FILTER:
    case GL_TEXTURE_MAG_FILTER:
@@ -930,13 +1055,18 @@ static void r200BindTexture( GLcontext *ctx, GLenum target,
               ctx->Texture.CurrentUnit );
    }
 
-   if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
-      if ( texObj->DriverData == NULL ) {
-        r200AllocTexObj( texObj );
-      }
+   if ( (target == GL_TEXTURE_1D)
+       || (target == GL_TEXTURE_2D) 
+#if ENABLE_HW_3D_TEXTURE
+       || (target == GL_TEXTURE_3D)
+#endif
+       || (target == GL_TEXTURE_CUBE_MAP)
+       || (target == GL_TEXTURE_RECTANGLE_NV) ) {
+      assert( texObj->DriverData != NULL );
    }
 }
 
+
 static void r200DeleteTexture( GLcontext *ctx,
                                 struct gl_texture_object *texObj )
 {
@@ -955,6 +1085,8 @@ static void r200DeleteTexture( GLcontext *ctx,
 
       driDestroyTextureObject( t );
    }
+   /* Free mipmap images and the texture object itself */
+   _mesa_delete_texture_object(ctx, texObj);
 }
 
 /* Need:  
@@ -977,59 +1109,67 @@ static void r200TexGen( GLcontext *ctx,
    rmesa->recheck_texgen[unit] = GL_TRUE;
 }
 
-/* Fixup MaxAnisotropy according to user preference.
- */
-static struct gl_texture_object *r200NewTextureObject ( GLcontext *ctx,
-                                                       GLuint name,
-                                                       GLenum target ) {
-    struct gl_texture_object *obj;
-    obj = _mesa_new_texture_object (ctx, name, target);
-    obj->MaxAnisotropy = driQueryOptionf (&R200_CONTEXT(ctx)->optionCache,
-                                         "def_max_anisotropy");
-    return obj;
-}
-
 
-void r200InitTextureFuncs( GLcontext *ctx )
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object.  Not done at this time.
+ * Fixup MaxAnisotropy according to user preference.
+ */
+static struct gl_texture_object *
+r200NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
+   struct gl_texture_object *obj;
+   obj = _mesa_new_texture_object(ctx, name, target);
+   if (!obj)
+      return NULL;
+   obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
+   r200AllocTexObj( obj );
+   return obj;
+}
 
 
-   ctx->Driver.ChooseTextureFormat     = r200ChooseTextureFormat;
-   ctx->Driver.TexImage1D              = r200TexImage1D;
-   ctx->Driver.TexImage2D              = r200TexImage2D;
+void r200InitTextureFuncs( struct dd_function_table *functions )
+{
+   /* Note: we only plug in the functions we implement in the driver
+    * since _mesa_init_driver_functions() was already called.
+    */
+   functions->ChooseTextureFormat      = r200ChooseTextureFormat;
+   functions->TexImage1D               = r200TexImage1D;
+   functions->TexImage2D               = r200TexImage2D;
 #if ENABLE_HW_3D_TEXTURE
-   ctx->Driver.TexImage3D              = r200TexImage3D;
+   functions->TexImage3D               = r200TexImage3D;
 #else
-   ctx->Driver.TexImage3D              = _mesa_store_teximage3d;
+   functions->TexImage3D               = _mesa_store_teximage3d;
 #endif
-   ctx->Driver.TexSubImage1D           = r200TexSubImage1D;
-   ctx->Driver.TexSubImage2D           = r200TexSubImage2D;
+   functions->TexSubImage1D            = r200TexSubImage1D;
+   functions->TexSubImage2D            = r200TexSubImage2D;
 #if ENABLE_HW_3D_TEXTURE
-   ctx->Driver.TexSubImage3D           = r200TexSubImage3D;
+   functions->TexSubImage3D            = r200TexSubImage3D;
 #else
-   ctx->Driver.TexSubImage3D           = _mesa_store_texsubimage3d;
+   functions->TexSubImage3D            = _mesa_store_texsubimage3d;
 #endif
-   ctx->Driver.CopyTexImage1D          = _swrast_copy_teximage1d;
-   ctx->Driver.CopyTexImage2D          = _swrast_copy_teximage2d;
-   ctx->Driver.CopyTexSubImage1D       = _swrast_copy_texsubimage1d;
-   ctx->Driver.CopyTexSubImage2D       = _swrast_copy_texsubimage2d;
-   ctx->Driver.CopyTexSubImage3D       = _swrast_copy_texsubimage3d;
-   ctx->Driver.TestProxyTexImage       = _mesa_test_proxy_teximage;
-
-   ctx->Driver.NewTextureObject         = r200NewTextureObject;
-   ctx->Driver.BindTexture             = r200BindTexture;
-   ctx->Driver.CreateTexture           = NULL; /* FIXME: Is this used??? */
-   ctx->Driver.DeleteTexture           = r200DeleteTexture;
-   ctx->Driver.IsTextureResident       = driIsTextureResident;
-   ctx->Driver.PrioritizeTexture       = NULL;
-   ctx->Driver.ActiveTexture           = NULL;
-   ctx->Driver.UpdateTexturePalette    = NULL;
-
-   ctx->Driver.TexEnv                  = r200TexEnv;
-   ctx->Driver.TexParameter            = r200TexParameter;
-   ctx->Driver.TexGen                   = r200TexGen;
+   functions->NewTextureObject         = r200NewTextureObject;
+   functions->BindTexture              = r200BindTexture;
+   functions->DeleteTexture            = r200DeleteTexture;
+   functions->IsTextureResident                = driIsTextureResident;
+
+   functions->TexEnv                   = r200TexEnv;
+   functions->TexParameter             = r200TexParameter;
+   functions->TexGen                   = r200TexGen;
 
+   functions->CompressedTexImage2D     = r200CompressedTexImage2D;
+   functions->CompressedTexSubImage2D  = r200CompressedTexSubImage2D;
+
+   driInitTextureFormats();
+
+#if 000
+   /* moved or obsolete code */
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);
    driInitTextureObjects( ctx, & rmesa->swapped,
                          DRI_TEXMGR_DO_TEXTURE_1D
                          | DRI_TEXMGR_DO_TEXTURE_2D );
@@ -1039,4 +1179,5 @@ void r200InitTextureFuncs( GLcontext *ctx )
     * default 2D texture now. */
    ctx->Shared->Default2D->MaxAnisotropy = driQueryOptionf (&rmesa->optionCache,
                                                            "def_max_anisotropy");
+#endif
 }