virgl: make unmap queuing a bit more straight-forward
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 4 Apr 2019 14:52:21 +0000 (16:52 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Wed, 17 Apr 2019 07:27:08 +0000 (07:27 +0000)
It's hard to read the code that decides if we want to queue up an unmap
or destroy the transfer right away. So let's make it a bit simpler, by
setting a bool in case we want to queue it.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_texture.c

index a17c094..cae7921 100644 (file)
@@ -173,6 +173,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
    struct virgl_context *vctx = virgl_context(ctx);
    struct virgl_transfer *trans = virgl_transfer(transfer);
    struct virgl_resource *vtex = virgl_resource(transfer->resource);
+   bool queue_unmap = false;
 
    if (transfer->usage & PIPE_TRANSFER_WRITE &&
        (transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT) == 0) {
@@ -182,13 +183,14 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
                            trans->base.stride, trans->l_stride,
                            trans->offset, transfer->level);
       } else
-         virgl_transfer_queue_unmap(&vctx->queue, trans);
+         queue_unmap = true;
    }
 
-   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))
+   pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL);
+
+   if (queue_unmap)
+      virgl_transfer_queue_unmap(&vctx->queue, trans);
+   else
       virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
 }