From cdb9bec202bc0eb18af985bb59290efdfcbb5e6c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 13 Feb 2025 12:23:25 -0500 Subject: [PATCH] zink: move buffer hashlist clear to normal batch state reset this is threaded now so it doesn't need to be in the submit thread Part-of: --- src/gallium/drivers/zink/zink_batch.c | 16 ++-------------- src/gallium/drivers/zink/zink_types.h | 2 -- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index d965e317e18..abb15cfbe48 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -81,6 +81,8 @@ reset_batch_state_internal(struct zink_screen *screen, struct zink_batch_state * reset_obj(screen, bs, obj); } + memset(&bs->buffer_indices_hashlist, -1, sizeof(bs->buffer_indices_hashlist)); + /* queries must only be destroyed once they are inactive */ set_foreach_remove(&bs->active_queries, entry) { struct zink_query *query = (void*)entry->key; @@ -618,11 +620,6 @@ post_submit(void *data, void *gdata, int thread_index) /* throttle in case something crazy is happening */ zink_screen_timeline_wait(screen, bs->fence.batch_id - 2500, OS_TIMEOUT_INFINITE); } - /* this resets the buffer hashlist for the state's next use */ - if (bs->hashlist_min != UINT16_MAX) - /* only reset a min/max region */ - memset(&bs->buffer_indices_hashlist[bs->hashlist_min], -1, (bs->hashlist_max - bs->hashlist_min + 1) * sizeof(int16_t)); - bs->hashlist_min = bs->hashlist_max = UINT16_MAX; } typedef enum { @@ -944,13 +941,6 @@ zink_end_batch(struct zink_context *ctx) } } -ALWAYS_INLINE static void -batch_hashlist_update(struct zink_batch_state *bs, unsigned hash) -{ - bs->hashlist_min = bs->hashlist_min == UINT16_MAX ? hash : MIN2(hash, bs->hashlist_min); - bs->hashlist_max = bs->hashlist_max == UINT16_MAX ? hash : MAX2(hash, bs->hashlist_max); -} - static int batch_find_resource(struct zink_batch_state *bs, struct zink_resource_object *obj, struct zink_batch_obj_list *list) { @@ -974,7 +964,6 @@ batch_find_resource(struct zink_batch_state *bs, struct zink_resource_object *ob * will collide here: ^ and here: ^, * meaning that we should get very few collisions in the end. */ bs->buffer_indices_hashlist[hash] = i & (BUFFER_HASHLIST_SIZE-1); - batch_hashlist_update(bs, hash); return i; } } @@ -1045,7 +1034,6 @@ batch_reference_resource_move_internal(struct zink_batch_state *bs, struct zink_ list->objs[idx] = res->obj; unsigned hash = bo->unique_id & (BUFFER_HASHLIST_SIZE-1); bs->buffer_indices_hashlist[hash] = idx & 0x7fff; - batch_hashlist_update(bs, hash); bs->last_added_obj = res->obj; if (!(res->base.b.flags & PIPE_RESOURCE_FLAG_SPARSE)) { bs->resource_size += res->obj->size; diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 12c09d7fb4b..6c80b0fca0e 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -637,8 +637,6 @@ struct zink_batch_state { * batch_find_resource uses this hint to speed up buffers look up. */ int16_t buffer_indices_hashlist[BUFFER_HASHLIST_SIZE]; - uint16_t hashlist_min; - uint16_t hashlist_max; struct zink_batch_obj_list real_objs; struct zink_batch_obj_list slab_objs; struct zink_batch_obj_list sparse_objs;