Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-06-21 19:44:40 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-06-21 20:25:12 +0300
commit41af27c582ec21e65ff3f835754c7b0bcf6d3be7 (patch)
treed0b6c01a034876cd36a21c9e3517026b05ba6e0c /source/blender/blenkernel/intern/particle_system.c
parent47473bee34897347b8a11d03a29a4efe83246e02 (diff)
Fix deadlocks in mesh modifier evaluation and particles
The recent task isolation changes missed two mutex locks that also need task isolation. Ref D11603, T89194
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r--source/blender/blenkernel/intern/particle_system.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 149e345e501..2dc752d57e1 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1320,6 +1320,14 @@ void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra
*efra = min_ii((int)(part->end + part->lifetime + 1.0f), max_ii(scene->r.pefra, scene->r.efra));
}
+/* BVH tree balancing inside a mutex lock must be run in isolation. Balancing
+ * is multithreaded, and we do not want the current thread to start another task
+ * that may involve acquiring the same mutex lock that it is waiting for. */
+static void bvhtree_balance_isolated(void *userdata)
+{
+ BLI_bvhtree_balance((BVHTree *)userdata);
+}
+
/************************************************/
/* Effectors */
/************************************************/
@@ -1356,7 +1364,8 @@ static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
}
}
}
- BLI_bvhtree_balance(psys->bvhtree);
+
+ BLI_task_isolate(bvhtree_balance_isolated, psys->bvhtree);
psys->bvhtree_frame = cfra;