zink: handle checking batch completion from other contexts without timelines

if a batch state can't be found, it may exist on a different context, so the screen
value needs to be checked

if the screen value indicates that the batch hasn't completed and we're waiting,
force a flush so there's a fence that can be waited upon

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Tested-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10115>
This commit is contained in:
Mike Blumenkrantz 2021-04-08 10:08:00 -04:00 committed by Marge Bot
parent fa36a16c68
commit b7a0265c27
1 changed files with 9 additions and 3 deletions

View File

@ -2067,9 +2067,14 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t 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);
/* if we can't find it, it either must have finished already or is on a different context */
if (!zink_screen_check_last_finished(zink_screen(ctx->base.screen), batch_id)) {
/* if it hasn't finished, it's on another context, so force a flush so there's something to wait on */
ctx->batch.has_work = true;
zink_fence_wait(&ctx->base);
}
return;
}
fence = he->data;
@ -2103,10 +2108,11 @@ zink_check_batch_completion(struct zink_context *ctx, uint32_t 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 we can't find it, it either must have finished already or is on a different context */
if (!he) {
simple_mtx_unlock(&ctx->batch_mtx);
return true;
/* return compare against last_finished, since this has info from all contexts */
return zink_screen_check_last_finished(zink_screen(ctx->base.screen), batch_id);
}
fence = he->data;
}