zink: pass batch instead of context for queries
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 21 May 2020 10:25:26 +0000 (12:25 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 25 May 2020 20:20:49 +0000 (20:20 +0000)
This makes things a bit more consistent IMO.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5141>

src/gallium/drivers/zink/zink_query.c

index b5b37cff259a60bfb44f67e2f4f8c224897e84c3..1d0050306d1edf11d869ae88d99ba1cb9eb3f586 100644 (file)
@@ -106,13 +106,12 @@ zink_destroy_query(struct pipe_context *pctx,
 }
 
 static void
-begin_query(struct zink_context *ctx, struct zink_query *q)
+begin_query(struct zink_batch *batch, struct zink_query *q)
 {
    VkQueryControlFlags flags = 0;
    if (q->precise)
       flags |= VK_QUERY_CONTROL_PRECISE_BIT;
 
-   struct zink_batch *batch = zink_curr_batch(ctx);
    vkCmdBeginQuery(batch->cmdbuf, q->query_pool, q->curr_query, flags);
 }
 
@@ -135,16 +134,15 @@ zink_begin_query(struct pipe_context *pctx,
    vkCmdResetQueryPool(batch->cmdbuf, query->query_pool, 0, MIN2(query->curr_query + 1, query->num_queries));
    query->curr_query = 0;
 
-   begin_query(ctx, query);
+   begin_query(batch, query);
    list_addtail(&query->active_list, &ctx->active_queries);
 
    return true;
 }
 
 static void
-end_query(struct zink_context *ctx, struct zink_query *q)
+end_query(struct zink_batch *batch, struct zink_query *q)
 {
-   struct zink_batch *batch = zink_curr_batch(ctx);
    assert(q->type != PIPE_QUERY_TIMESTAMP);
    vkCmdEndQuery(batch->cmdbuf, q->query_pool, q->curr_query);
    if (++q->curr_query == q->num_queries) {
@@ -158,15 +156,15 @@ zink_end_query(struct pipe_context *pctx,
                struct pipe_query *q)
 {
    struct zink_context *ctx = zink_context(pctx);
+   struct zink_batch *batch = zink_curr_batch(ctx);
    struct zink_query *query = (struct zink_query *)q;
 
    if (query->type == PIPE_QUERY_TIMESTAMP) {
       assert(query->curr_query == 0);
-      struct zink_batch *batch = zink_curr_batch(ctx);
       vkCmdWriteTimestamp(batch->cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
                           query->query_pool, 0);
    } else {
-      end_query(ctx, query);
+      end_query(batch, query);
       list_delinit(&query->active_list);
    }
 
@@ -235,7 +233,7 @@ zink_suspend_queries(struct zink_context *ctx, struct zink_batch *batch)
 {
    struct zink_query *query;
    LIST_FOR_EACH_ENTRY(query, &ctx->active_queries, active_list) {
-      end_query(ctx, query);
+      end_query(batch, query);
    }
 }
 
@@ -245,7 +243,7 @@ zink_resume_queries(struct zink_context *ctx, struct zink_batch *batch)
    struct zink_query *query;
    LIST_FOR_EACH_ENTRY(query, &ctx->active_queries, active_list) {
       vkCmdResetQueryPool(batch->cmdbuf, query->query_pool, query->curr_query, 1);
-      begin_query(ctx, query);
+      begin_query(batch, query);
    }
 }