From 84e845c9696ab673f1d95fda47843028ed0c71a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Wed, 1 Apr 2020 12:08:41 +0300 Subject: [PATCH] mesa/st: release variants for active programs before unref MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Programs can be shared among many contexts and each program holds a variant list which has context specific variants. When context gets destroyed it must make sure it relases all variants, otherwise remaining context that utilizes same program will attempt to save a zombie shader for already deleted context when releasing program and its variants. Fixes: dEQP-EGL.functional.sharing.gles2.program.render and other flaky multihread dEQP-EGL failures. v2: pass program pointer via & (Marek) Signed-off-by: Tapani Pälli Reviewed-by: Marek Olšák Reviewed-by: Jordan Justen Cc: mesa-stable@lists.freedesktop.org Tested-by: Marge Bot Part-of: --- src/mesa/state_tracker/st_context.c | 12 ++++++------ src/mesa/state_tracker/st_program.c | 13 +++++++++++++ src/mesa/state_tracker/st_program.h | 3 +++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index fa309436408..645c02f3dfd 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -1070,12 +1070,12 @@ st_destroy_context(struct st_context *st) simple_mtx_destroy(&st->zombie_sampler_views.mutex); simple_mtx_destroy(&st->zombie_shaders.mutex); - st_reference_prog(st, &st->fp, NULL); - st_reference_prog(st, &st->gp, NULL); - st_reference_prog(st, &st->vp, NULL); - st_reference_prog(st, &st->tcp, NULL); - st_reference_prog(st, &st->tep, NULL); - st_reference_prog(st, &st->cp, NULL); + st_release_program(st, &st->fp); + st_release_program(st, &st->gp); + st_release_program(st, &st->vp); + st_release_program(st, &st->tcp); + st_release_program(st, &st->tep); + st_release_program(st, &st->cp); /* release framebuffer in the winsys buffers list */ LIST_FOR_EACH_ENTRY_SAFE_REV(stfb, next, &st->winsys_buffers, head) { diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 466c3f1a29e..c0e63b8a98c 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -334,6 +334,19 @@ st_release_variants(struct st_context *st, struct st_program *p) */ } +/** + * Free all basic program variants and unref program. + */ +void +st_release_program(struct st_context *st, struct st_program **p) +{ + if (!*p) + return; + + st_release_variants(st, *p); + st_reference_prog(st, p, NULL); +} + void st_finalize_nir_before_variants(struct nir_shader *nir) { diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 87ac3388d72..286fabc0117 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -317,6 +317,9 @@ st_get_common_variant(struct st_context *st, extern void st_release_variants(struct st_context *st, struct st_program *p); +extern void +st_release_program(struct st_context *st, struct st_program **p); + extern void st_destroy_program_variants(struct st_context *st); -- 2.30.2