Make the drivers using the common texmem code work with NewTextureObject
authorFelix Kuehling <fxkuehl@gmx.de>
Mon, 26 Jan 2004 23:38:12 +0000 (23:38 +0000)
committerFelix Kuehling <fxkuehl@gmx.de>
Mon, 26 Jan 2004 23:38:12 +0000 (23:38 +0000)
in Mesa. This is analogous to changes idr made to the r200 driver. Patch
submitted by Andreas Stenglein.

src/mesa/drivers/dri/i810/i810context.c
src/mesa/drivers/dri/i810/i810tex.c
src/mesa/drivers/dri/i830/i830_context.c
src/mesa/drivers/dri/i830/i830_tex.c
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/mga/mgatex.c
src/mesa/drivers/dri/r128/r128_context.c
src/mesa/drivers/dri/r128/r128_tex.c
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_tex.c

index 78698e8..f443ce0 100644 (file)
@@ -292,8 +292,6 @@ i810CreateContext( const __GLcontextModes *mesaVis,
    i810InitVB( ctx );
    i810InitState( ctx );
 
-   driInitTextureObjects( ctx, &imesa->swapped, DRI_TEXMGR_DO_TEXTURE_2D);
-
 #if DO_DEBUG
    I810_DEBUG  = driParseDebugString( getenv( "I810_DEBUG" ),
                                      debug_control );
index cd9ef15..220d901 100644 (file)
@@ -412,9 +412,7 @@ static void i810TexSubImage2D( GLcontext *ctx,
 static void i810BindTexture( GLcontext *ctx, GLenum target,
                             struct gl_texture_object *tObj )
 {
-   if (!tObj->DriverData) {
-      i810AllocTexObj( ctx, tObj );
-   }
+   assert( (target != GL_TEXTURE_2D) || (tObj->DriverData != NULL) );
 }
 
 
@@ -532,6 +530,7 @@ i810NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
    struct gl_texture_object *obj;
    obj = _mesa_new_texture_object(ctx, name, target);
+   i810AllocTexObj( ctx, obj );
    return obj;
 }
 
index 74a7d77..0d6b2b7 100644 (file)
@@ -370,10 +370,6 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
    i830DDInitSpanFuncs( ctx );
    i830DDInitState (ctx);
 
-   driInitTextureObjects( ctx, & imesa->swapped,
-                         DRI_TEXMGR_DO_TEXTURE_2D
-                         | DRI_TEXMGR_DO_TEXTURE_RECT );
-
 #if DO_DEBUG
    I830_DEBUG  = driParseDebugString( getenv( "I830_DEBUG" ),
                                      debug_control );
index 3399859..00b869a 100644 (file)
@@ -420,9 +420,8 @@ static void i830TexSubImage2D( GLcontext *ctx,
 static void i830BindTexture( GLcontext *ctx, GLenum target,
                             struct gl_texture_object *tObj )
 {
-   if (!tObj->DriverData) {
-      i830AllocTexObj( tObj );
-   }
+   assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) ||
+           (tObj->DriverData != NULL) );
 }
 
 
@@ -565,6 +564,7 @@ i830NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
    struct gl_texture_object *obj;
    obj = _mesa_new_texture_object(ctx, name, target);
+   i830AllocTexObj( obj );
    return obj;
 }
 
index a3eb758..169615d 100644 (file)
@@ -527,10 +527,6 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
    mgaDDInitPixelFuncs( ctx );
    mgaDDInitTriFuncs( ctx );
 
-   driInitTextureObjects( ctx, & mmesa->swapped,
-                          (DRI_TEXMGR_DO_TEXTURE_2D |
-                           DRI_TEXMGR_DO_TEXTURE_RECT) );
-
    mgaInitVB( ctx );
    mgaInitState( mmesa );
 
index 2fef5b8..1b45c0f 100644 (file)
@@ -484,12 +484,8 @@ static void
 mgaBindTexture( GLcontext *ctx, GLenum target,
                  struct gl_texture_object *tObj )
 {
-   if ( target == GL_TEXTURE_2D ||
-        target == GL_TEXTURE_RECTANGLE_NV ) {
-      if ( tObj->DriverData == NULL ) {
-        mgaAllocTexObj( tObj );
-      }
-   }
+   assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) ||
+           (tObj->DriverData != NULL) );
 }
 
 
@@ -523,6 +519,7 @@ mgaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
    struct gl_texture_object *obj;
    obj = _mesa_new_texture_object(ctx, name, target);
+   mgaAllocTexObj( obj );
    return obj;
 }
 
index 7bb3244..ea1c276 100644 (file)
@@ -245,10 +245,6 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
    r128DDInitSpanFuncs( ctx );
    r128DDInitState( rmesa );
 
-   driInitTextureObjects( ctx, & rmesa->swapped,
-                         DRI_TEXMGR_DO_TEXTURE_1D
-                         | DRI_TEXMGR_DO_TEXTURE_2D );
-
    rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
        ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
 
index 373ff5c..d459b62 100644 (file)
@@ -561,11 +561,8 @@ static void r128BindTexture( GLcontext *ctx, GLenum target,
               ctx->Texture.CurrentUnit );
    }
 
-   if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
-      if ( tObj->DriverData == NULL ) {
-        r128AllocTexObj( tObj );
-      }
-   }
+   assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_1D) ||
+           (tObj->DriverData != NULL) );
 }
 
 
@@ -598,6 +595,7 @@ r128NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
    struct gl_texture_object *obj;
    obj = _mesa_new_texture_object(ctx, name, target);
+   r128AllocTexObj( obj );
    return obj;
 }
 
index 6e9cc5f..de197aa 100644 (file)
@@ -354,11 +354,6 @@ radeonCreateContext( const __GLcontextModes *glVisual,
 
    rmesa->boxes = 0;
 
-   /* formerly in radeon_tex.c */
-   driInitTextureObjects( ctx, & rmesa->swapped,
-                         DRI_TEXMGR_DO_TEXTURE_1D
-                         | DRI_TEXMGR_DO_TEXTURE_2D );
-
    /* Initialize the software rasterizer and helper modules.
     */
    _swrast_CreateContext( ctx );
index 99aa4a4..78220c6 100644 (file)
@@ -674,11 +674,9 @@ static void radeonBindTexture( GLcontext *ctx, GLenum target,
               ctx->Texture.CurrentUnit );
    }
 
-   if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
-      if ( texObj->DriverData == NULL ) {
-        radeonAllocTexObj( texObj );
-      }
-   }
+   assert( (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D &&
+            target != GL_TEXTURE_RECTANGLE_NV) ||
+           (texObj->DriverData != NULL) );
 }
 
 
@@ -741,6 +739,7 @@ radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
    if (!obj)
       return NULL;
    obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
+   radeonAllocTexObj( obj );
    return obj;
 }