Commit 354b2f7f authored by Mike Blumenkrantz's avatar Mike Blumenkrantz 🏋 Committed by Marge Bot

zink: fix rp hash table

hash table keys for inserted items have to be valid memory ranges for the
lifetime of the corresponding entry, so using a stack-allocated key like this
is broken and doesn't accurately return the correct renderpass

Fixes a872f463: ("zink: cache render-passes")
Reviewed-by: Erik Faye-Lund 's avatarErik Faye-Lund <>
Part-of: <mesa/mesa!8011>
parent ec34b3f1
......@@ -634,12 +634,13 @@ get_render_pass(struct zink_context *ctx)
state.have_zsbuf = fb->zsbuf != NULL;
struct hash_entry *entry = _mesa_hash_table_search(ctx->render_pass_cache,
uint32_t hash = hash_render_pass_state(&state);
struct hash_entry *entry = _mesa_hash_table_search_pre_hashed(ctx->render_pass_cache, hash,
if (!entry) {
struct zink_render_pass *rp;
rp = zink_create_render_pass(screen, &state);
entry = _mesa_hash_table_insert(ctx->render_pass_cache, &state, rp);
entry = _mesa_hash_table_insert_pre_hashed(ctx->render_pass_cache, hash, &rp->state, rp);
if (!entry)
return NULL;
......@@ -100,7 +100,7 @@ zink_create_render_pass(struct zink_screen *screen,
rp->render_pass = create_render_pass(screen->dev, state);
if (!rp->render_pass)
goto fail;
memcpy(&rp->state, state, sizeof(struct zink_render_pass_state));
return rp;
......@@ -46,6 +46,7 @@ struct zink_render_pass {
struct pipe_reference reference;
VkRenderPass render_pass;
struct zink_render_pass_state state;
struct zink_render_pass *
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment