zink: fully wait on all program fences during ctx destroy

optimized pipeline compile jobs may still be ongoing during ctx
destroy, and these must complete too or else crashes will occur

fixes shutdown crash with dEQP-EGL.functional.sharing.gles2.multithread.simple.images.texture_source.teximage2d_render

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28900>
This commit is contained in:
Mike Blumenkrantz 2024-04-24 11:14:58 -04:00 committed by Marge Bot
parent f18a1d3a31
commit bd1a3921d1
3 changed files with 20 additions and 1 deletions

View file

@ -138,7 +138,7 @@ zink_context_destroy(struct pipe_context *pctx)
simple_mtx_lock((&ctx->program_lock[i]));
hash_table_foreach(&ctx->program_cache[i], entry) {
struct zink_program *pg = entry->data;
util_queue_fence_wait(&pg->cache_fence);
zink_program_finish(ctx, pg);
pg->removed = true;
}
simple_mtx_unlock((&ctx->program_lock[i]));

View file

@ -835,6 +835,23 @@ zink_gfx_program_compile_queue(struct zink_context *ctx, struct zink_gfx_pipelin
}
}
void
zink_program_finish(struct zink_context *ctx, struct zink_program *pg)
{
util_queue_fence_wait(&pg->cache_fence);
if (pg->is_compute)
return;
struct zink_gfx_program *prog = (struct zink_gfx_program*)pg;
for (int r = 0; r < ARRAY_SIZE(prog->pipelines); ++r) {
for (int i = 0; i < ARRAY_SIZE(prog->pipelines[0]); ++i) {
hash_table_foreach(&prog->pipelines[r][i], entry) {
struct zink_gfx_pipeline_cache_entry *pc_entry = entry->data;
util_queue_fence_wait(&pc_entry->fence);
}
}
}
}
static void
update_cs_shader_module(struct zink_context *ctx, struct zink_compute_program *comp)
{

View file

@ -133,6 +133,8 @@ uint32_t hash_gfx_input_dynamic(const void *key);
void
zink_gfx_program_compile_queue(struct zink_context *ctx, struct zink_gfx_pipeline_cache_entry *pc_entry);
void
zink_program_finish(struct zink_context *ctx, struct zink_program *pg);
static inline unsigned
get_primtype_idx(enum mesa_prim mode)