diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2021-01-23 18:09:11 -0500 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-04-01 13:25:51 +0000 |
commit | 357b54c9bb67fa931a1655f961ac5897630579e3 (patch) | |
tree | 0a260f8fe1b99643304329c7bddd47e816c05468 /src | |
parent | 4dbeb92c7e7df232f6bcfcf62a406256f933b1ad (diff) |
zink: optimize batch states for timeline use
finishing a timeline wait guarantees that a given fence has completed,
meaning the accompanying batch static is implicitly available for use
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9963>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/zink/zink_batch.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index a6191df3004..e4779a8e68a 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -206,7 +206,7 @@ fail: return NULL; } -static bool +static inline bool find_unused_state(struct hash_entry *entry) { struct zink_fence *fence = entry->data; @@ -225,10 +225,13 @@ get_batch_state(struct zink_context *ctx, struct zink_batch *batch) if (util_dynarray_num_elements(&ctx->free_batch_states, struct zink_batch_state*)) bs = util_dynarray_pop(&ctx->free_batch_states, struct zink_batch_state*); if (!bs) { - struct hash_entry *he = _mesa_hash_table_random_entry(&ctx->batch_states, find_unused_state); - if (he) { //there may not be any entries available - bs = he->data; - _mesa_hash_table_remove(&ctx->batch_states, he); + hash_table_foreach(&ctx->batch_states, he) { + struct zink_fence *fence = he->data; + if (zink_screen_check_last_finished(zink_screen(ctx->base.screen), fence->batch_id) || find_unused_state(he)) { + bs = he->data; + _mesa_hash_table_remove(&ctx->batch_states, he); + break; + } } } simple_mtx_unlock(&ctx->batch_mtx); |