svga: Fix resource leak; undo temporary workaround.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 3 Feb 2011 16:14:02 +0000 (16:14 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 3 Feb 2011 16:14:02 +0000 (16:14 +0000)
Leak was introduced when fixing strict aliasing violation in this code:
the reference counting was preserved, but the destructor call on zero
reference count was not.

src/gallium/drivers/svga/svga_draw.c
src/gallium/drivers/svga/svga_resource_buffer_upload.c

index 051ac1c..2c873a0 100644 (file)
@@ -224,13 +224,6 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
       hwtnl->cmd.prim_count = 0;
    }
 
-   /*
-    * FIXME:  Somehow we are accumulating too many buffer uploads without
-    * flushing, so temporarily disable buffer upload coalescing to prevent OOM
-    * crashes (at expense of less performance).
-    */
-   svga_context_flush_buffers(svga);
-
    return PIPE_OK;
 }
 
index 3de5216..765d2f3 100644 (file)
@@ -248,6 +248,7 @@ svga_buffer_upload_flush(struct svga_context *svga,
 {
    SVGA3dCopyBox *boxes;
    unsigned i;
+   struct pipe_resource *dummy;
 
    assert(sbuf->handle); 
    assert(sbuf->hwbuf);
@@ -289,9 +290,9 @@ svga_buffer_upload_flush(struct svga_context *svga,
    sbuf->dma.svga = NULL;
    sbuf->dma.boxes = NULL;
 
-   /* Decrement reference count */
-   pipe_reference(&(sbuf->b.b.reference), NULL);
-   sbuf = NULL;
+   /* Decrement reference count (and potentially destroy) */
+   dummy = &sbuf->b.b;
+   pipe_resource_reference(&dummy, NULL);
 }