From d50ff36d3df95fa85f2c082f4961acd4adccdb2d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 2 Jul 2013 19:23:03 +0000 Subject: [PATCH] Add workaroud to make threaded object update stable Added threading lock around unsafe part of do_makeDispListCurveTypes (parts which touches Curve->bev and Curve->path). Namely it means pre-tesselation modifiers, bevel, path and non-modified display list will be calculated inside a locked thread. Post-tessellation modifiers will eb calculated outside of locked thread, which means heavy constructive or deformation modifiers applying on tesselated spline will be nicely threaded. This makes it possible to use threaded object update by default in the branch, so everyone could start testing it. --- source/blender/blenkernel/intern/displist.c | 8 ++++++++ source/blender/blenkernel/intern/scene.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 6f2aa82a389..0efed68c41f 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -45,6 +45,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_scanfill.h" +#include "BLI_threads.h" #include "BLI_utildefines.h" #include "BKE_global.h" @@ -1394,6 +1395,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba nubase = BKE_curve_nurbs_get(cu); + /* XXX: Temp workaround for depsgraph_mt branch. */ + BLI_lock_thread(LOCK_CUSTOM1); + BLI_freelistN(&(cu->bev)); if (cu->path) free_path(cu->path); @@ -1594,6 +1598,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (cu->bb == NULL) { cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); } + + /* XXX: Temp workaround for depsgraph_mt branch. */ + BLI_unlock_thread(LOCK_CUSTOM1); + boundbox_dispbase(cu->bb, dispbase); if (!forRender) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f9db948e713..4abc04ef76f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1164,8 +1164,6 @@ static void scene_do_rb_simulation_recursive(Scene *scene, float ctime) BKE_rigidbody_do_simulation(scene, ctime); } -#undef USE_THREADED_UPDATE - typedef struct ThreadedObjectUpdateState { Scene *scene; Scene *scene_parent; @@ -1329,12 +1327,6 @@ static void scene_update_objects(Scene *scene, Scene *scene_parent) } } -#ifndef USE_THREADED_UPDATE - if (true) { - scene_update_all_bases(scene, scene_parent); - } - else -#endif if (update_count > 1) { scene_update_objects_threaded(scene, scene_parent); }