Commit: f20b8ae5aa4736b3d3ca976e2dadc85db70f367b
Author: Sergey Sharybin
Date:   Tue Jan 24 12:42:56 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBf20b8ae5aa4736b3d3ca976e2dadc85db70f367b

Depsgraph: Remove legacy calls from scene update routines

===================================================================

M       source/blender/blenkernel/intern/scene.c

===================================================================

diff --git a/source/blender/blenkernel/intern/scene.c 
b/source/blender/blenkernel/intern/scene.c
index 69d3b4db54..f73ee53e46 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1248,109 +1248,6 @@ void BKE_scene_frame_set(struct Scene *scene, double 
cfra)
        scene->r.cfra = (int)intpart;
 }
 
-#ifdef WITH_LEGACY_DEPSGRAPH
-/* drivers support/hacks 
- *  - this method is called from scene_update_tagged_recursive(), so gets 
included in viewport + render
- *     - these are always run since the depsgraph can't handle non-object data
- *     - these happen after objects are all done so that we can read in their 
final transform values,
- *       though this means that objects can't refer to scene info for 
guidance...
- */
-static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
-{
-       SceneRenderLayer *srl;
-       float ctime = BKE_scene_frame_get(scene);
-       
-       /* scene itself */
-       if (scene->adt && scene->adt->drivers.first) {
-               BKE_animsys_evaluate_animdata(scene, &scene->id, scene->adt, 
ctime, ADT_RECALC_DRIVERS);
-       }
-
-       /* world */
-       /* TODO: what about world textures? but then those have nodes too... */
-       if (scene->world) {
-               ID *wid = (ID *)scene->world;
-               AnimData *adt = BKE_animdata_from_id(wid);
-               
-               if (adt && adt->drivers.first)
-                       BKE_animsys_evaluate_animdata(scene, wid, adt, ctime, 
ADT_RECALC_DRIVERS);
-       }
-       
-       /* nodes */
-       if (scene->nodetree) {
-               ID *nid = (ID *)scene->nodetree;
-               AnimData *adt = BKE_animdata_from_id(nid);
-               
-               if (adt && adt->drivers.first)
-                       BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, 
ADT_RECALC_DRIVERS);
-       }
-
-       /* world nodes */
-       if (scene->world && scene->world->nodetree) {
-               ID *nid = (ID *)scene->world->nodetree;
-               AnimData *adt = BKE_animdata_from_id(nid);
-               
-               if (adt && adt->drivers.first)
-                       BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, 
ADT_RECALC_DRIVERS);
-       }
-
-       /* freestyle */
-       for (srl = scene->r.layers.first; srl; srl = srl->next) {
-               FreestyleConfig *config = &srl->freestyleConfig;
-               FreestyleLineSet *lineset;
-
-               for (lineset = config->linesets.first; lineset; lineset = 
lineset->next) {
-                       if (lineset->linestyle) {
-                               ID *lid = &lineset->linestyle->id;
-                               AnimData *adt = BKE_animdata_from_id(lid);
-
-                               if (adt && adt->drivers.first)
-                                       BKE_animsys_evaluate_animdata(scene, 
lid, adt, ctime, ADT_RECALC_DRIVERS);
-                       }
-               }
-       }
-}
-
-/* deps hack - do extra recalcs at end */
-static void scene_depsgraph_hack(EvaluationContext *eval_ctx, Scene *scene, 
Scene *scene_parent)
-{
-       Base *base;
-               
-       scene->customdata_mask = scene_parent->customdata_mask;
-       
-       /* sets first, we allow per definition current scene to have
-        * dependencies on sets, but not the other way around. */
-       if (scene->set)
-               scene_depsgraph_hack(eval_ctx, scene->set, scene_parent);
-       
-       for (base = scene->base.first; base; base = base->next) {
-               Object *ob = base->object;
-               
-               if (ob->depsflag) {
-                       int recalc = 0;
-                       // printf("depshack %s\n", ob->id.name + 2);
-                       
-                       if (ob->depsflag & OB_DEPS_EXTRA_OB_RECALC)
-                               recalc |= OB_RECALC_OB;
-                       if (ob->depsflag & OB_DEPS_EXTRA_DATA_RECALC)
-                               recalc |= OB_RECALC_DATA;
-                       
-                       ob->recalc |= recalc;
-                       BKE_object_handle_update(eval_ctx, scene_parent, ob);
-                       
-                       if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) {
-                               GroupObject *go;
-                               
-                               for (go = ob->dup_group->gobject.first; go; go 
= go->next) {
-                                       if (go->ob)
-                                               go->ob->recalc |= recalc;
-                               }
-                               BKE_group_handle_recalc_and_update(eval_ctx, 
scene_parent, ob, ob->dup_group);
-                       }
-               }
-       }
-}
-#endif  /* WITH_LEGACY_DEPSGRAPH */
-
 /* That's like really a bummer, because currently animation data for armatures
  * might want to use pose, and pose might be missing on the object.
  * This happens when changing visible layers, which leads to situations when
@@ -1379,350 +1276,6 @@ static void scene_armature_depsgraph_workaround(Main 
*bmain)
 }
 #endif
 
-#ifdef WITH_LEGACY_DEPSGRAPH
-static void scene_rebuild_rbw_recursive(Scene *scene, float ctime)
-{
-       if (scene->set)
-               scene_rebuild_rbw_recursive(scene->set, ctime);
-
-       if (BKE_scene_check_rigidbody_active(scene))
-               BKE_rigidbody_rebuild_world(scene, ctime);
-}
-
-static void scene_do_rb_simulation_recursive(Scene *scene, float ctime)
-{
-       if (scene->set)
-               scene_do_rb_simulation_recursive(scene->set, ctime);
-
-       if (BKE_scene_check_rigidbody_active(scene))
-               BKE_rigidbody_do_simulation(scene, ctime);
-}
-#endif
-
-/* Used to visualize CPU threads activity during threaded object update,
- * would pollute STDERR with whole bunch of timing information which then
- * could be parsed and nicely visualized.
- */
-#ifdef WITH_LEGACY_DEPSGRAPH
-#  undef DETAILED_ANALYSIS_OUTPUT
-#else
-/* ALWAYS KEEY DISABLED! */
-#  undef DETAILED_ANALYSIS_OUTPUT
-#endif
-
-/* Mballs evaluation uses BKE_scene_base_iter_next which calls
- * duplilist for all objects in the scene. This leads to conflict
- * accessing and writing same data from multiple threads.
- *
- * Ideally Mballs shouldn't do such an iteration and use DAG
- * queries instead. For the time being we've got new DAG
- * let's keep it simple and update mballs in a single thread.
- */
-#define MBALL_SINGLETHREAD_HACK
-
-#ifdef WITH_LEGACY_DEPSGRAPH
-typedef struct StatisicsEntry {
-       struct StatisicsEntry *next, *prev;
-       Object *object;
-       double start_time;
-       double duration;
-} StatisicsEntry;
-
-typedef struct ThreadedObjectUpdateState {
-       /* TODO(sergey): We might want this to be per-thread object. */
-       EvaluationContext *eval_ctx;
-       Scene *scene;
-       Scene *scene_parent;
-       double base_time;
-
-#ifdef MBALL_SINGLETHREAD_HACK
-       bool has_mballs;
-#endif
-
-       /* Execution statistics */
-       bool has_updated_objects;
-       ListBase *statistics;
-} ThreadedObjectUpdateState;
-
-static void scene_update_object_add_task(void *node, void *user_data);
-
-static void scene_update_all_bases(EvaluationContext *eval_ctx, Scene *scene, 
Scene *scene_parent)
-{
-       Base *base;
-
-       for (base = scene->base.first; base; base = base->next) {
-               Object *object = base->object;
-
-               BKE_object_handle_update_ex(eval_ctx, scene_parent, object, 
scene->rigidbody_world, true);
-
-               if (object->dup_group && (object->transflag & OB_DUPLIGROUP))
-                       BKE_group_handle_recalc_and_update(eval_ctx, 
scene_parent, object, object->dup_group);
-
-               /* always update layer, so that animating layers works (joshua 
july 2010) */
-               /* XXX commented out, this has depsgraph issues anyway - and 
this breaks setting scenes
-                * (on scene-set, the base-lay is copied to ob-lay (ton nov 
2012) */
-               // base->lay = ob->lay;
-       }
-}
-
-static void scene_update_object_func(TaskPool * __restrict pool, void 
*taskdata, int threadid)
-{
-/* Disable print for now in favor of summary statistics at the end of update. 
*/
-#define PRINT if (false) printf
-
-       ThreadedObjectUpdateState *state = (ThreadedObjectUpdateState *) 
BLI_task_pool_userdata(pool);
-       void *node = taskdata;
-       Object *object = DAG_get_node_object(node);
-       EvaluationContext *eval_ctx = state->eval_ctx;
-       Scene *scene = state->scene;
-       Scene *scene_parent = state->scene_parent;
-
-#ifdef MBALL_SINGLETHREAD_HACK
-       if (object && object->type == OB_MBALL) {
-               state->has_mballs = true;
-       }
-       else
-#endif
-       if (object) {
-               double start_time = 0.0;
-               bool add_to_stats = false;
-
-               if (G.debug & G_DEBUG_DEPSGRAPH) {
-                       if (object->recalc & OB_RECALC_ALL) {
-                               printf("Thread %d: update object %s\n", 
threadid, object->id.name);
-                       }
-
-                       start_time = PIL_check_seconds_timer();
-
-                       if (object->recalc & OB_RECALC_ALL) {
-                               state->has_updated_objects = true;
-                               add_to_stats = true;
-                       }
-               }
-
-               /* We only update object itself here, dupli-group will be 
updated
-                * separately from main thread because of we've got no idea 
about
-                * dependencies inside the group.
-                */
-               BKE_object_handle_update_ex(eval_ctx, scene_parent, object, 
scene->rigidbody_world, false);
-
-               /* Calculate statistics. */
-               if (add_to_stats) {
-                       StatisicsEntry *entry;
-
-                       BLI_assert(threadid < BLI_pool_get_num_threads(pool));
-
-                       entry = MEM_mallocN(sizeof(StatisicsEntry), "update 
thread statistics");
-                       entry->object = object;
-                       entry->start_time = start_time;
-                       entry->duration = PIL_check_seconds_timer() - 
start_time;
-
-                       BLI_addtail(&state->statistics[threadid], entry);
-               }
-       }
-       else {
-               PRINT("Threda %d: update node %s\n", threadid,
-                     DAG_get_node_name(scene, node));
-       }
-
-       /* Update will decrease child's valency and schedule child with zero 
valency. */
-       DAG_threaded_update_handle_node_updated(node, 
scene_update_object_add_task, pool);
-
-#undef PRINT
-}
-
-static void scene_update_object_add_task(void *node, void *user_data)
-{
-       TaskPool *task_pool = user_data;
-
-       BLI_task_pool_push(task_pool, scene_update_object_func, node, false, 
TASK_PRIORITY_LOW);
-}
-
-static void print_threads_statistics(ThreadedObjectUpdateState *state)
-{
-       int i, tot_thread;
-       double finish_time;
-
-       if ((G.debug & G_DEBUG_DEPSGRAPH) == 0) {
-               return;
-       }
-
-#ifdef DETAILED_ANALYSIS_OUTPUT
-       if (state->has_updated_objects) {
-               tot_thread = BLI_system_thread_count();
-
-               fprintf(stderr, "objects update base time %f\n", 
state->base_time);
-
-               for (i = 0; i < tot_thread; i++) {
-                       StatisicsEntry *entry;
-                       for (entry = state->statistics[i].first;
-                            entry;
-                            entry = entry->next)
-                       {
-                               fprintf(stderr, "thread %d object %s start_time 
%f duration %f\n",
-                                       i, entry->object->id.name + 2,
-                                       entry->start_time, entry->duration);
-                       }
-                       BLI_freelistN(&state->statistics[i]);
-               }
-       }
-#else
-       finish_time = PIL_check_seconds_timer();
-       tot_thread = BLI_system_thread_count();
-       int total_objects = 0;
-
-       for (i = 0; i < tot_thread; i++) {
-               int thread_total_objects = 0;
-               double thread_total_time = 0.0;
-               StatisicsEntry *entry;
-
-               if (state->has_updated_objects) {
-                       /* Don't pollute output if no objects were updated. */
-                       for (entry = state->statistics[i].first;
-                            entry;
-                            entry = entry->next)
-                       {
-                               thread_total_objects++;
-                               thread_total_time += entry->duration;
-                       }
-
-                       printf("Thread %d: total %d objects in %f sec.\n",
-                              i,
-                              thread_total_objects

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to