diff options
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 0daad310543..785ca6b4e01 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -35,6 +35,7 @@ #include "util/util_path.h" #include "util/util_string.h" #include "util/util_task.h" +#include "util/util_tbb.h" #include "util/util_types.h" #ifdef WITH_OSL @@ -288,9 +289,11 @@ static PyObject *render_func(PyObject * /*self*/, PyObject *args) RNA_pointer_create(NULL, &RNA_Depsgraph, (ID *)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr); BL::Depsgraph b_depsgraph(depsgraphptr); + /* Allow Blender to execute other Python scripts, and isolate TBB tasks so we + * don't get deadlocks with Blender threads accessing shared data like images. */ python_thread_state_save(&session->python_thread_state); - session->render(b_depsgraph); + tbb::this_task_arena::isolate([&] { session->render(b_depsgraph); }); python_thread_state_restore(&session->python_thread_state); @@ -327,7 +330,8 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args) python_thread_state_save(&session->python_thread_state); - session->bake(b_depsgraph, b_object, pass_type, pass_filter, width, height); + tbb::this_task_arena::isolate( + [&] { session->bake(b_depsgraph, b_object, pass_type, pass_filter, width, height); }); python_thread_state_restore(&session->python_thread_state); @@ -373,7 +377,7 @@ static PyObject *reset_func(PyObject * /*self*/, PyObject *args) python_thread_state_save(&session->python_thread_state); - session->reset_session(b_data, b_depsgraph); + tbb::this_task_arena::isolate([&] { session->reset_session(b_data, b_depsgraph); }); python_thread_state_restore(&session->python_thread_state); @@ -395,7 +399,7 @@ static PyObject *sync_func(PyObject * /*self*/, PyObject *args) python_thread_state_save(&session->python_thread_state); - session->synchronize(b_depsgraph); + tbb::this_task_arena::isolate([&] { session->synchronize(b_depsgraph); }); python_thread_state_restore(&session->python_thread_state); |