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>
This commit is contained in:
Mike Blumenkrantz 2021-03-22 10:33:34 -04:00 committed by Marge Bot
parent 6eaaaaa542
commit 4a736677af
2 changed files with 33 additions and 0 deletions

View File

@ -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)
{

View File

@ -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);