Mesa (master): zink: add function for checking whether a batch is done

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 30 15:21:23 UTC 2021


Module: Mesa
Branch: master
Commit: 4a736677afe568220bff07168d2bead728e03979
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a736677afe568220bff07168d2bead728e03979

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Mar 22 10:33:34 2021 -0400

zink: add function for checking whether a batch is done

this is like wait_on_batch, but without the waiting

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9885>

---

 src/gallium/drivers/zink/zink_context.c | 30 ++++++++++++++++++++++++++++++
 src/gallium/drivers/zink/zink_context.h |  3 +++
 2 files changed, 33 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index a353d52cc2c..bd359fc43c6 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1960,6 +1960,36 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id)
    simple_mtx_unlock(&ctx->batch_mtx);
 }
 
+bool
+zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id)
+{
+   assert(batch_id);
+   struct zink_batch_state *bs = ctx->batch.state;
+   assert(bs);
+   if (bs->fence.batch_id == batch_id)
+      /* not submitted yet */
+      return false;
+
+   struct zink_fence *fence;
+
+   simple_mtx_lock(&ctx->batch_mtx);
+
+   if (ctx->last_fence && batch_id == zink_batch_state(ctx->last_fence)->fence.batch_id)
+      fence = ctx->last_fence;
+   else {
+      struct hash_entry *he = _mesa_hash_table_search_pre_hashed(&ctx->batch_states, batch_id, (void*)(uintptr_t)batch_id);
+      /* if we can't find it, it must have finished already */
+      if (!he) {
+         simple_mtx_unlock(&ctx->batch_mtx);
+         return true;
+      }
+      fence = he->data;
+   }
+   simple_mtx_unlock(&ctx->batch_mtx);
+   assert(fence);
+   return ctx->base.screen->fence_finish(ctx->base.screen, &ctx->base, (struct pipe_fence_handle*)fence, 0);
+}
+
 static void
 zink_texture_barrier(struct pipe_context *pctx, unsigned flags)
 {
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index 74ffad05c39..829fd422596 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -248,6 +248,9 @@ zink_fence_wait(struct pipe_context *ctx);
 void
 zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id);
 
+bool
+zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id);
+
 void
 zink_flush_queue(struct zink_context *ctx);
 



More information about the mesa-commit mailing list