mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 13:38:06 +02:00
mesa/st: use a lock to protect access to variants when updating them
Multiple threads may access st_update_* function at same time. Issues happen when the threads modify lists managed by shader compiler. Issues were found with script that runs multithread tests 1000 times in a row with MESA_GLSL_CACHE_DISABLE=1 set. Problems start when 2 simultaneous st_create_[vp|fp]_variant calls start to compile a new shader variant for the same program and various nir passes use and modify same exec_lists. Example failure: deqp-egl: ../src/compiler/glsl/list.h:575: exec_list_validate: Assertion `node->next->prev == node' failed. v2: instead of introducing new mutex, lock shared state Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7418>
This commit is contained in:
parent
77d6fda0f5
commit
d428580534
1 changed files with 9 additions and 1 deletions
|
|
@ -160,7 +160,9 @@ st_update_fp( struct st_context *st )
|
|||
|
||||
key.external = st_get_external_sampler_key(st, &stfp->Base);
|
||||
|
||||
simple_mtx_lock(&st->ctx->Shared->Mutex);
|
||||
shader = st_get_fp_variant(st, stfp, &key)->base.driver_shader;
|
||||
simple_mtx_unlock(&st->ctx->Shared->Mutex);
|
||||
}
|
||||
|
||||
st_reference_prog(st, &st->fp, stfp);
|
||||
|
|
@ -232,7 +234,9 @@ st_update_vp( struct st_context *st )
|
|||
!st->ctx->GeometryProgram._Current)
|
||||
key.lower_ucp = st->ctx->Transform.ClipPlanesEnabled;
|
||||
|
||||
simple_mtx_lock(&st->ctx->Shared->Mutex);
|
||||
st->vp_variant = st_get_vp_variant(st, stvp, &key);
|
||||
simple_mtx_unlock(&st->ctx->Shared->Mutex);
|
||||
}
|
||||
|
||||
st_reference_prog(st, &st->vp, stvp);
|
||||
|
|
@ -291,7 +295,11 @@ st_update_common_program(struct st_context *st, struct gl_program *prog,
|
|||
key.lower_ucp = st->ctx->Transform.ClipPlanesEnabled;
|
||||
}
|
||||
|
||||
return st_get_common_variant(st, stp, &key)->driver_shader;
|
||||
simple_mtx_lock(&st->ctx->Shared->Mutex);
|
||||
void *result = st_get_common_variant(st, stp, &key)->driver_shader;
|
||||
simple_mtx_unlock(&st->ctx->Shared->Mutex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue