diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-06-22 19:17:48 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-06-22 19:26:58 +0300 |
commit | 026de343e3528fe2b2f8d8daba7fa2fd4b807337 (patch) | |
tree | b327e0615c9530b8fd62d59a8fe3882079fadf2a /source/blender/blenkernel/intern/mesh_wrapper.c | |
parent | f8d219dfd4c31a918e33cb715472d91a5cd3fd51 (diff) |
Fix deadlock with shrinkwrap and other modifiers
More code that needs task isolation. Encountered in sprite fright production
file.
Ref D11603
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_wrapper.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_wrapper.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/mesh_wrapper.c b/source/blender/blenkernel/intern/mesh_wrapper.c index cf1dba3325c..fe6af432314 100644 --- a/source/blender/blenkernel/intern/mesh_wrapper.c +++ b/source/blender/blenkernel/intern/mesh_wrapper.c @@ -40,6 +40,7 @@ #include "BLI_ghash.h" #include "BLI_math.h" +#include "BLI_task.h" #include "BLI_threads.h" #include "BLI_utildefines.h" @@ -95,15 +96,9 @@ Mesh *BKE_mesh_wrapper_from_editmesh(BMEditMesh *em, return BKE_mesh_wrapper_from_editmesh_with_coords(em, cd_mask_extra, NULL, me_settings); } -void BKE_mesh_wrapper_ensure_mdata(Mesh *me) +static void mesh_wrapper_ensure_mdata_isolated(void *userdata) { - ThreadMutex *mesh_eval_mutex = (ThreadMutex *)me->runtime.eval_mutex; - BLI_mutex_lock(mesh_eval_mutex); - - if (me->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA) { - BLI_mutex_unlock(mesh_eval_mutex); - return; - } + Mesh *me = userdata; const eMeshWrapperType geom_type_orig = me->runtime.wrapper_type; me->runtime.wrapper_type = ME_WRAPPER_TYPE_MDATA; @@ -136,6 +131,20 @@ void BKE_mesh_wrapper_ensure_mdata(Mesh *me) if (me->runtime.wrapper_type_finalize) { BKE_mesh_wrapper_deferred_finalize(me, &me->runtime.cd_mask_extra); } +} + +void BKE_mesh_wrapper_ensure_mdata(Mesh *me) +{ + ThreadMutex *mesh_eval_mutex = (ThreadMutex *)me->runtime.eval_mutex; + BLI_mutex_lock(mesh_eval_mutex); + + if (me->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA) { + BLI_mutex_unlock(mesh_eval_mutex); + return; + } + + /* Must isolate multithreaded tasks while holding a mutex lock. */ + BLI_task_isolate(mesh_wrapper_ensure_mdata_isolated, me); BLI_mutex_unlock(mesh_eval_mutex); } |