zink: inline gfx pipeline hash table
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 17 Jun 2021 18:20:40 +0000 (14:20 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 1 Sep 2021 03:28:11 +0000 (03:28 +0000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12605>

src/gallium/drivers/zink/zink_program.c
src/gallium/drivers/zink/zink_program.h

index 018344b..6c5d749 100644 (file)
@@ -467,11 +467,7 @@ zink_create_gfx_program(struct zink_context *ctx,
       prog->last_vertex_stage = stages[PIPE_SHADER_VERTEX];
 
    for (int i = 0; i < ARRAY_SIZE(prog->pipelines); ++i) {
-      prog->pipelines[i] = _mesa_hash_table_create(NULL,
-                                                   NULL,
-                                                   equals_gfx_pipeline_state);
-      if (!prog->pipelines[i])
-         goto fail;
+      _mesa_hash_table_init(&prog->pipelines[i], prog, NULL, equals_gfx_pipeline_state);
       /* only need first 3/4 for point/line/tri/patch */
       if (screen->info.have_EXT_extended_dynamic_state &&
           i == (prog->last_vertex_stage->nir->info.stage == MESA_SHADER_TESS_EVAL ? 4 : 3))
@@ -711,13 +707,12 @@ zink_destroy_gfx_program(struct zink_screen *screen,
    }
 
    for (int i = 0; i < max_idx; ++i) {
-      hash_table_foreach(prog->pipelines[i], entry) {
+      hash_table_foreach(&prog->pipelines[i], entry) {
          struct gfx_pipeline_cache_entry *pc_entry = entry->data;
 
          vkDestroyPipeline(screen->dev, pc_entry->pipeline, NULL);
          free(pc_entry);
       }
-      _mesa_hash_table_destroy(prog->pipelines[i], NULL);
    }
    if (prog->base.pipeline_cache)
       vkDestroyPipelineCache(screen->dev, prog->base.pipeline_cache, NULL);
@@ -824,7 +819,7 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
    state->modules_changed = false;
    ctx->vertex_state_changed = false;
 
-   entry = _mesa_hash_table_search_pre_hashed(prog->pipelines[idx], state->final_hash, state);
+   entry = _mesa_hash_table_search_pre_hashed(&prog->pipelines[idx], state->final_hash, state);
 
    if (!entry) {
       util_queue_fence_wait(&prog->base.cache_fence);
@@ -840,7 +835,7 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
       memcpy(&pc_entry->state, state, sizeof(*state));
       pc_entry->pipeline = pipeline;
 
-      entry = _mesa_hash_table_insert_pre_hashed(prog->pipelines[idx], state->final_hash, pc_entry, pc_entry);
+      entry = _mesa_hash_table_insert_pre_hashed(&prog->pipelines[idx], state->final_hash, pc_entry, pc_entry);
       assert(entry);
    }
 
index f7ed7c9..c4e1c43 100644 (file)
@@ -103,7 +103,7 @@ struct zink_gfx_program {
    struct zink_shader *last_vertex_stage;
 
    struct zink_shader *shaders[ZINK_SHADER_COUNT];
-   struct hash_table *pipelines[11]; // number of draw modes we support
+   struct hash_table pipelines[11]; // number of draw modes we support
    uint32_t default_variant_hash;
    uint32_t last_variant_hash;
 };