drivers: don't include texformat.h
[mesa.git] / src / mesa / drivers / dri / r200 / r200_tex.c
index 7c433cc6b71efa63271d8ab0a5ec18b24ee84ad6..5a21a8b9c5a8213423e9b58b985c924f17186cd3 100644 (file)
@@ -38,13 +38,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/enums.h"
 #include "main/image.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
 
-#include "texmem.h"
-
 #include "radeon_mipmap_tree.h"
 #include "r200_context.h"
 #include "r200_state.h"
@@ -211,6 +208,9 @@ static void r200SetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
 {
    GLuint anisotropy = (t->pp_txfilter & R200_MAX_ANISO_MASK);
 
+   /* Force revalidation to account for switches from/to mipmapping. */
+   t->validated = GL_FALSE;
+
    t->pp_txfilter &= ~(R200_MIN_FILTER_MASK | R200_MAG_FILTER_MASK);
    t->pp_txformat_x &= ~R200_VOLUME_FILTER_MASK;
 
@@ -269,15 +269,16 @@ static void r200SetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
    }
 }
 
-static void r200SetTexBorderColor( radeonTexObjPtr t, GLubyte c[4] )
+static void r200SetTexBorderColor( radeonTexObjPtr t, const GLfloat color[4] )
 {
+   GLubyte c[4];
+   CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+   CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+   CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+   CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
    t->pp_border_color = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
 }
 
-
-
-
-
 static void r200TexEnv( GLcontext *ctx, GLenum target,
                          GLenum pname, const GLfloat *param )
 {
@@ -285,7 +286,7 @@ static void r200TexEnv( GLcontext *ctx, GLenum target,
    GLuint unit = ctx->Texture.CurrentUnit;
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
 
-   if ( R200_DEBUG & DEBUG_STATE ) {
+   if ( R200_DEBUG & RADEON_STATE ) {
       fprintf( stderr, "%s( %s )\n",
               __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
    }
@@ -357,7 +358,7 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
 {
    radeonTexObj* t = radeon_tex_obj(texObj);
 
-   if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
+   if ( R200_DEBUG & (RADEON_STATE|RADEON_TEXTURE) ) {
       fprintf( stderr, "%s( %s )\n", __FUNCTION__,
               _mesa_lookup_enum_by_nr( pname ) );
    }
@@ -377,7 +378,7 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
       break;
 
    case GL_TEXTURE_BORDER_COLOR:
-      r200SetTexBorderColor( t, texObj->_BorderChan );
+      r200SetTexBorderColor( t, texObj->BorderColor );
       break;
 
    case GL_TEXTURE_BASE_LEVEL:
@@ -389,16 +390,16 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
        * we just have to rely on loading the right subset of mipmap levels
        * to simulate a clamped LOD.
        */
-      driSwapOutTextureObject( (driTextureObject *) t );
+      if (t->mt) {
+         radeon_miptree_unreference(t->mt);
+        t->mt = 0;
+        t->validated = GL_FALSE;
+      }
       break;
 
    default:
       return;
    }
-
-   /* Mark this texobj as dirty (one bit per tex unit)
-    */
-   t->dirty_state = R200_TEX_ALL;
 }
 
 
@@ -407,7 +408,7 @@ static void r200DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    radeonTexObj* t = radeon_tex_obj(texObj);
 
-   if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+   if (RADEON_DEBUG & (RADEON_STATE | RADEON_TEXTURE)) {
       fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
              (void *)texObj,
              _mesa_lookup_enum_by_nr(texObj->Target));
@@ -415,7 +416,7 @@ static void r200DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
    
    if (rmesa) {
       int i;
-      R200_FIREVERTICES(rmesa);
+      radeon_firevertices(&rmesa->radeon);
       for ( i = 0 ; i < rmesa->radeon.glCtx->Const.MaxTextureUnits ; i++ ) {
         if ( t == rmesa->state.texture.unit[i].texobj ) {
            rmesa->state.texture.unit[i].texobj = NULL;
@@ -468,7 +469,7 @@ static struct gl_texture_object *r200NewTextureObject(GLcontext * ctx,
    radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj);
 
 
-   if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+   if (RADEON_DEBUG & (RADEON_STATE | RADEON_TEXTURE)) {
      fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
             t, _mesa_lookup_enum_by_nr(target));
    }
@@ -480,7 +481,7 @@ static struct gl_texture_object *r200NewTextureObject(GLcontext * ctx,
    r200SetTexWrap( t, t->base.WrapS, t->base.WrapT, t->base.WrapR );
    r200SetTexMaxAnisotropy( t, t->base.MaxAnisotropy );
    r200SetTexFilter(t, t->base.MinFilter, t->base.MagFilter);
-   r200SetTexBorderColor(t, t->base._BorderChan);
+   r200SetTexBorderColor(t, t->base.BorderColor);
 
    return &t->base;
 }
@@ -492,7 +493,7 @@ 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      = radeonChooseTextureFormat;
+   functions->ChooseTextureFormat      = radeonChooseTextureFormat_mesa;
    functions->TexImage1D               = radeonTexImage1D;
    functions->TexImage2D               = radeonTexImage2D;
 #if ENABLE_HW_3D_TEXTURE
@@ -507,6 +508,8 @@ void r200InitTextureFuncs( struct dd_function_table *functions )
 #else
    functions->TexSubImage3D            = _mesa_store_texsubimage3d;
 #endif
+   functions->GetTexImage               = radeonGetTexImage;
+   functions->GetCompressedTexImage     = radeonGetCompressedTexImage;
    functions->NewTextureObject         = r200NewTextureObject;
    //   functions->BindTexture         = r200BindTexture;
    functions->DeleteTexture            = r200DeleteTexture;
@@ -519,7 +522,7 @@ void r200InitTextureFuncs( struct dd_function_table *functions )
    functions->CompressedTexImage2D     = radeonCompressedTexImage2D;
    functions->CompressedTexSubImage2D  = radeonCompressedTexSubImage2D;
 
-   functions->GenerateMipmap = radeon_generate_mipmap;
+   functions->GenerateMipmap = radeonGenerateMipmap;
 
    functions->NewTextureImage = radeonNewTextureImage;
    functions->FreeTexImageData = radeonFreeTexImageData;