virgl: simplify virgl_transfer_queue_extend
authorChia-I Wu <olvaffe@gmail.com>
Mon, 8 Jul 2019 23:31:46 +0000 (16:31 -0700)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 9 Jul 2019 21:26:55 +0000 (14:26 -0700)
We can reuse virgl_transfer_queue_find_pending.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
src/gallium/drivers/virgl/virgl_transfer_queue.c

index ea1e759bc69de5ebb9256343d6e6e9ec1945e225..10bb1c5d9a13369efe52d3d62f439d6576cd4cb5 100644 (file)
@@ -160,14 +160,6 @@ static bool transfers_intersect(struct virgl_transfer *queued,
          &current->base.box, true);
 }
 
-static void set_queued(UNUSED struct virgl_transfer_queue *queue,
-                       struct list_action_args *args)
-{
-   struct virgl_transfer *queued = args->queued;
-   struct virgl_transfer **val = args->data;
-   *val = queued;
-}
-
 static void remove_transfer(struct virgl_transfer_queue *queue,
                             struct list_action_args *args)
 {
@@ -234,26 +226,6 @@ static void compare_and_perform_action(struct virgl_transfer_queue *queue,
    }
 }
 
-static void intersect_and_set_queued_once(struct virgl_transfer_queue *queue,
-                                          struct list_iteration_args *iter)
-{
-   struct list_action_args args;
-   struct virgl_transfer *queued, *tmp;
-   enum virgl_transfer_queue_lists type = iter->type;
-
-   memset(&args, 0, sizeof(args));
-   args.current = iter->current;
-   args.data = iter->data;
-
-   LIST_FOR_EACH_ENTRY_SAFE(queued, tmp, &queue->lists[type], queue_link) {
-      if (transfers_intersect(queued, iter->current)) {
-         args.queued = queued;
-         set_queued(queue, &args);
-         return;
-      }
-   }
-}
-
 static void perform_action(struct virgl_transfer_queue *queue,
                            struct list_iteration_args *iter)
 {
@@ -405,17 +377,16 @@ virgl_transfer_queue_extend(struct virgl_transfer_queue *queue,
                             struct virgl_transfer *transfer)
 {
    struct virgl_transfer *queued = NULL;
-   struct list_iteration_args iter;
 
    /* We don't support extending from copy transfers. */
    assert(!transfer->copy_src_hw_res);
 
    if (transfer->base.resource->target == PIPE_BUFFER) {
-      memset(&iter, 0, sizeof(iter));
-      iter.current = transfer;
-      iter.data = &queued;
-      iter.type = PENDING_LIST;
-      intersect_and_set_queued_once(queue, &iter);
+      queued = virgl_transfer_queue_find_pending(queue,
+                                                 transfer->hw_res,
+                                                 transfer->base.level,
+                                                 &transfer->base.box,
+                                                 true);
    }
 
    if (queued) {