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:
authorSergey Sharybin <sergey@blender.org>2021-10-27 15:40:18 +0300
committerSergey Sharybin <sergey@blender.org>2021-10-27 15:52:53 +0300
commit8507336e76902604a2128b23a4d8e52094031ab0 (patch)
tree9e1d598f40c8e8537d2a7190eeafa67214ff8ed5 /source/blender/modifiers/intern/MOD_fluid.c
parent82cf25dfbfad39a64b620c20bbd0d65915827a44 (diff)
Fix T92423: Blender freeze rendering animation with Mantaflow
Mantaflow could steal tasks from dependency graph, which under certain conditions causes a recursive lock involving GIL. Isolate threading done in mantaflow when it is interfaced form the dependency graph. Isolation done from the modifier, since the deeper calls are branching out quite quickly. Differential Revision: https://developer.blender.org/D13011
Diffstat (limited to 'source/blender/modifiers/intern/MOD_fluid.c')
-rw-r--r--source/blender/modifiers/intern/MOD_fluid.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_fluid.c b/source/blender/modifiers/intern/MOD_fluid.c
index a14d582063a..acc92fde766 100644
--- a/source/blender/modifiers/intern/MOD_fluid.c
+++ b/source/blender/modifiers/intern/MOD_fluid.c
@@ -25,6 +25,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
@@ -112,6 +113,29 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
+typedef struct FluidIsolationData {
+ Depsgraph *depsgraph;
+ Object *object;
+ Mesh *mesh;
+ FluidModifierData *fmd;
+
+ Mesh *result;
+} FluidIsolationData;
+
+static void fluid_modifier_do_isolated(void *userdata)
+{
+ FluidIsolationData *isolation_data = (FluidIsolationData *)userdata;
+
+ Scene *scene = DEG_get_evaluated_scene(isolation_data->depsgraph);
+
+ Mesh *result = BKE_fluid_modifier_do(isolation_data->fmd,
+ isolation_data->depsgraph,
+ scene,
+ isolation_data->object,
+ isolation_data->mesh);
+ isolation_data->result = result ? result : isolation_data->mesh;
+}
+
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *me)
{
#ifndef WITH_FLUID
@@ -125,10 +149,19 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
return me;
}
- Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
-
- result = BKE_fluid_modifier_do(fmd, ctx->depsgraph, scene, ctx->object, me);
- return result ? result : me;
+ /* Isolate execution of Mantaflow when running from dependency graph. The reason for this is
+ * because Mantaflow uses TBB to parallel its own computation which without isolation will start
+ * stealing tasks from dependency graph. Stealing tasks from the dependency graph might cause
+ * a recursive lock when Python drivers are used (because Mantaflow is interfaced via Python as
+ * well. */
+ FluidIsolationData isolation_data;
+ isolation_data.depsgraph = ctx->depsgraph;
+ isolation_data.object = ctx->object;
+ isolation_data.mesh = me;
+ isolation_data.fmd = fmd;
+ BLI_task_isolate(fluid_modifier_do_isolated, &isolation_data);
+
+ return isolation_data.result;
#endif /* WITH_FLUID */
}