zink: add gfx pipeline lookup shortcut

if the final hash was the same as the last-used hash for this program,
it should be safe to reuse the last pipeline object in the presence of
dynamic vertex input since the number of permutations is low

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18135>
This commit is contained in:
Mike Blumenkrantz
2022-08-11 09:10:08 -04:00
committed by Marge Bot
parent 6a836eaff5
commit 1d521a5c15
2 changed files with 13 additions and 0 deletions

View File

@@ -211,6 +211,12 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
ctx->vertex_state_changed = false; ctx->vertex_state_changed = false;
const int rp_idx = state->render_pass ? 1 : 0; const int rp_idx = state->render_pass ? 1 : 0;
if (DYNAMIC_STATE >= ZINK_DYNAMIC_VERTEX_INPUT) {
if (prog->last_finalized_hash[rp_idx][idx] == state->final_hash && !prog->inline_variants && likely(prog->last_pipeline[rp_idx][idx])) {
state->pipeline = prog->last_pipeline[rp_idx][idx];
return state->pipeline;
}
}
entry = _mesa_hash_table_search_pre_hashed(&prog->pipelines[rp_idx][idx], state->final_hash, state); entry = _mesa_hash_table_search_pre_hashed(&prog->pipelines[rp_idx][idx], state->final_hash, state);
if (!entry) { if (!entry) {
@@ -259,6 +265,10 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
struct gfx_pipeline_cache_entry *cache_entry = (struct gfx_pipeline_cache_entry *)entry->data; struct gfx_pipeline_cache_entry *cache_entry = (struct gfx_pipeline_cache_entry *)entry->data;
state->pipeline = cache_entry->pipeline; state->pipeline = cache_entry->pipeline;
if (DYNAMIC_STATE >= ZINK_DYNAMIC_VERTEX_INPUT) {
prog->last_finalized_hash[rp_idx][idx] = state->final_hash;
prog->last_pipeline[rp_idx][idx] = state->pipeline;
}
return state->pipeline; return state->pipeline;
} }

View File

@@ -795,6 +795,9 @@ struct zink_gfx_program {
uint32_t last_variant_hash; uint32_t last_variant_hash;
uint8_t inline_variants; //which stages are using inlined uniforms uint8_t inline_variants; //which stages are using inlined uniforms
uint32_t last_finalized_hash[2][4]; //[dynamic, renderpass][primtype idx]
VkPipeline last_pipeline[2][4]; //[dynamic, renderpass][primtype idx]
struct set libs[4]; //zink_gfx_library_key[primtype] -> VkPipeline struct set libs[4]; //zink_gfx_library_key[primtype] -> VkPipeline
}; };