virgl: also destroy all read-transfers
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Tue, 2 Apr 2019 08:48:30 +0000 (10:48 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Wed, 3 Apr 2019 16:59:23 +0000 (18:59 +0200)
For texture write-transfers, we either free them on the transfer-queue
or right away. But for read-transfers, we currently only destroy them in
case they used a temp-resource. This leads to occasional resource-leaks.

Let's add a call to virgl_resource_destroy_transfer in the missing case.

Do the same thing for buffers as well, but the logic is a bit easier to
follow there.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Fixes: f0e71b10888 ("virgl: use transfer queue")
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_texture.c

index 3baccc010be878b92852c7e734c7659adf3f32da..784cc02a54586578ed8287aed93e2bcd78baeb67 100644 (file)
@@ -90,7 +90,8 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
 
       vctx->num_transfers++;
       virgl_transfer_queue_unmap(&vctx->queue, trans);
-   }
+   } else
+      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
 }
 
 static void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
index 231319899e03d345e3c1ee5582bee124d189be5a..1832309aa49dfeab9b9f6bca2ab573517e26dc06 100644 (file)
@@ -181,7 +181,8 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
    if (trans->resolve_tmp) {
       pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL);
       virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
-   }
+   } else if (!(trans->base.usage & PIPE_TRANSFER_WRITE))
+      virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
 }
 
 static const struct u_resource_vtbl virgl_texture_vtbl =