fix GL_LINE_LOOP with drivers using own render pipeline stage (#12410, #13527)
[mesa.git] / src / mesa / drivers / dri / mga / mgatex.c
index b64335f30344ca96fe6ab3e2b562c11255b5020a..a7d74317a5b7a9bd277d4287767df2ea7c414f90 100644 (file)
@@ -366,7 +366,6 @@ static void mgaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
 {
    driTextureObject * t = (driTextureObject *) texObj->DriverData;
 
-   assert(t);
    if ( t != NULL ) {
       driSwapOutTextureObject( t );
    } 
@@ -437,7 +436,6 @@ mgaTexParameter( GLcontext *ctx, GLenum target,
     * created with current state before it is used, so we don't have
     * to do anything now 
     */
-   assert(t);
    if ( (t == NULL) ||
         (target != GL_TEXTURE_2D &&
          target != GL_TEXTURE_RECTANGLE_NV) ) {
@@ -482,20 +480,13 @@ mgaTexParameter( GLcontext *ctx, GLenum target,
 }
 
 
-#if 0
-/* no longer needed */
 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) );
 }
-#endif
 
 
 static void
@@ -504,7 +495,6 @@ mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
    driTextureObject * t = (driTextureObject *) tObj->DriverData;
 
-   assert(t);
    if ( t ) {
       if ( mmesa ) {
         FLUSH_BATCH( mmesa );
@@ -512,6 +502,9 @@ mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
 
       driDestroyTextureObject( t );
    }
+
+   /* Free mipmap images and the texture object itself */
+   _mesa_delete_texture_object(ctx, tObj);
 }
 
 
@@ -520,22 +513,15 @@ mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
  * Called via ctx->Driver.NewTextureObject.
  * Note: this function will be called during context creation to
  * allocate the default texture objects.
- * Fixup MaxAnisotropy according to user preference.
+ * 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.
  */
 static struct gl_texture_object *
 mgaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
-   mgaContextPtr rmesa = MGA_CONTEXT(ctx);
    struct gl_texture_object *obj;
-   driTextureObject *t;
    obj = _mesa_new_texture_object(ctx, name, target);
-   if (!obj)
-      return NULL;
-   t = (driTextureObject *) mgaAllocTexObj( obj );
-   if (!t) {
-      _mesa_delete_texture_object(ctx, obj);
-      return NULL;
-   }
+   mgaAllocTexObj( obj );
    return obj;
 }
 
@@ -546,10 +532,10 @@ mgaInitTextureFuncs( struct dd_function_table *functions )
    functions->ChooseTextureFormat      = mgaChooseTextureFormat;
    functions->TexImage2D               = mgaTexImage2D;
    functions->TexSubImage2D            = mgaTexSubImage2D;
-   /*ctx->Driver.BindTexture           = mgaBindTexture;*/
+   functions->BindTexture              = mgaBindTexture;
    functions->NewTextureObject         = mgaNewTextureObject;
    functions->DeleteTexture            = mgaDeleteTexture;
-   functions->IsTextureResident        = driIsTextureResident;
+   functions->IsTextureResident                = driIsTextureResident;
    functions->TexEnv                   = mgaTexEnv;
    functions->TexParameter             = mgaTexParameter;
 }