Mesa (main): zink: avoid hashing shader stages multiple times for new gfx programs
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Aug 25 22:38:31 UTC 2021
Module: Mesa
Branch: main
Commit: e14ecb903b8ba1c66a309e73cb47851b786d4311
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e14ecb903b8ba1c66a309e73cb47851b786d4311
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Jun 9 19:38:27 2021 -0400
zink: avoid hashing shader stages multiple times for new gfx programs
Reviewed-by: Hoe Hao Cheng <haochengho12907 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12532>
---
src/gallium/drivers/zink/zink_draw.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index e8c262908c2..196a7a8f7ee 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -203,13 +203,15 @@ update_gfx_program(struct zink_context *ctx)
unsigned bits = u_bit_consecutive(PIPE_SHADER_VERTEX, 5);
if (ctx->dirty_shader_stages & bits) {
struct zink_gfx_program *prog = NULL;
- struct hash_entry *entry = _mesa_hash_table_search(&ctx->program_cache[ctx->shader_stages >> 2],
- ctx->gfx_stages);
+
+ struct hash_table *ht = &ctx->program_cache[ctx->shader_stages >> 2];
+ uint32_t hash = ht->key_hash_function(ctx->gfx_stages);
+ struct hash_entry *entry = _mesa_hash_table_search_pre_hashed(ht, hash, ctx->gfx_stages);
if (entry)
zink_update_gfx_program(ctx, (struct zink_gfx_program*)entry->data);
else {
prog = zink_create_gfx_program(ctx, ctx->gfx_stages);
- entry = _mesa_hash_table_insert(&ctx->program_cache[ctx->shader_stages >> 2], prog->shaders, prog);
+ entry = _mesa_hash_table_insert_pre_hashed(ht, hash, prog->shaders, prog);
}
prog = (struct zink_gfx_program*)(entry ? entry->data : NULL);
if (prog && prog != ctx->curr_program) {
More information about the mesa-commit
mailing list