From 7ee936bf65593c73a5eaa1be822b05f31d96b68e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 29 Mar 2024 19:22:33 -0400 Subject: [PATCH] radeonsi: convert the compute blit shader hash table to u64 keys 32 bits is not enough anymore. We'll add more. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_compute_blit.c | 8 ++------ src/gallium/drivers/radeonsi/si_pipe.c | 8 ++++---- src/gallium/drivers/radeonsi/si_pipe.h | 6 ++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_compute_blit.c b/src/gallium/drivers/radeonsi/si_compute_blit.c index 48905d2af86..f3580221031 100644 --- a/src/gallium/drivers/radeonsi/si_compute_blit.c +++ b/src/gallium/drivers/radeonsi/si_compute_blit.c @@ -1106,7 +1106,6 @@ bool si_compute_blit(struct si_context *sctx, const struct pipe_blit_info *info, union si_compute_blit_shader_key options; options.key = 0; - options.always_true = true; options.is_clear = is_clear; options.wg_dim = wg_dim; options.has_start_xyz = start_x || start_y || start_z; @@ -1164,13 +1163,10 @@ bool si_compute_blit(struct si_context *sctx, const struct pipe_blit_info *info, (is_resolve ? 10 : 11)); } - struct hash_entry *entry = _mesa_hash_table_search(sctx->cs_blit_shaders, - (void*)(uintptr_t)options.key); - void *shader = entry ? entry->data : NULL; + void *shader = _mesa_hash_table_u64_search(sctx->cs_blit_shaders, options.key); if (!shader) { shader = si_create_blit_cs(sctx, &options); - _mesa_hash_table_insert(sctx->cs_blit_shaders, - (void*)(uintptr_t)options.key, shader); + _mesa_hash_table_u64_insert(sctx->cs_blit_shaders, options.key, shader); } sctx->cs_user_data[0] = (info->src.box.x & 0xffff) | ((info->dst.box.x & 0xffff) << 16); diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index ad18e5d0f39..b013344b9d4 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -366,10 +366,10 @@ static void si_destroy_context(struct pipe_context *context) p_atomic_dec(&context->screen->num_contexts); if (sctx->cs_blit_shaders) { - hash_table_foreach(sctx->cs_blit_shaders, entry) { - context->delete_compute_state(context, entry->data); + hash_table_u64_foreach(sctx->cs_blit_shaders, entry) { + context->delete_compute_state(context, entry.data); } - _mesa_hash_table_destroy(sctx->cs_blit_shaders, NULL); + _mesa_hash_table_u64_destroy(sctx->cs_blit_shaders); } FREE(sctx); @@ -864,7 +864,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign sctx->initial_gfx_cs_size = sctx->gfx_cs.current.cdw; sctx->last_timestamp_cmd = NULL; - sctx->cs_blit_shaders = _mesa_hash_table_create_u32_keys(NULL); + sctx->cs_blit_shaders = _mesa_hash_table_u64_create(NULL); if (!sctx->cs_blit_shaders) goto fail; diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index d31d65b0161..cb3b04973b0 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -993,7 +993,7 @@ struct si_context { void *cs_clear_12bytes_buffer; void *cs_dcc_retile[32]; void *cs_fmask_expand[3][2]; /* [log2(samples)-1][is_array] */ - struct hash_table *cs_blit_shaders; + struct hash_table_u64 *cs_blit_shaders; struct si_screen *screen; struct util_debug_callback debug; struct ac_llvm_compiler *compiler; /* only non-threaded compilation */ @@ -1634,8 +1634,6 @@ void *si_clear_image_dcc_single_shader(struct si_context *sctx, bool is_msaa, un union si_compute_blit_shader_key { struct { - /* The key saved in _mesa_hash_table_create_u32_keys() can't be 0. */ - bool always_true:1; /* Workgroup settings. */ uint8_t wg_dim:2; /* 1, 2, or 3 */ bool has_start_xyz:1; @@ -1662,7 +1660,7 @@ union si_compute_blit_shader_key { uint8_t last_src_channel:2; uint8_t last_dst_channel:2; }; - uint32_t key; + uint64_t key; }; void *si_create_blit_cs(struct si_context *sctx, const union si_compute_blit_shader_key *options);