summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-03-22 10:33:34 -0400
committerMarge Bot <eric+marge@anholt.net>2021-03-30 15:12:58 +0000
commit4a736677afe568220bff07168d2bead728e03979 (patch)
tree6570cb9c5254d6d87304916a5a0fb74c40616fd1
parent6eaaaaa542e3b7d642b23df74d48b39347f8f116 (diff)
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@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9885>
-rw-r--r--src/gallium/drivers/zink/zink_context.c30
-rw-r--r--src/gallium/drivers/zink/zink_context.h3
2 files changed, 33 insertions, 0 deletions
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);