mesa: Fixed a texture memory leak
authorRobert Ellison <papillo@vmware.com>
Fri, 8 May 2009 17:13:57 +0000 (11:13 -0600)
committerRobert Ellison <papillo@vmware.com>
Fri, 8 May 2009 22:32:28 +0000 (16:32 -0600)
The current texture for any particular texture unit is given an additional
reference in update_texture_state(); but if the context is closed before
that texture can be released (which is quite frequent in normal use, unless
a program unbinds and deletes the texture and renders without it to force
a call to update_texture_state(), the memory is lost.

This affects general Mesa; but the i965 is particularly affected because
it allocates a considerable amount of additional memory for each allocated
texture.

src/mesa/main/texstate.c

index 5453331c67f32a2f4743290f6db46b0d6293c04b..6e0c0c688a19ac3171b7e1b86936ffbbab5f038c 100644 (file)
@@ -791,6 +791,9 @@ _mesa_free_texture_data(GLcontext *ctx)
 
    /* unreference current textures */
    for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
+      /* The _Current texture could account for another reference */
+      _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL);
+
       for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
          _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL);
       }