Commit: d4132afe67a8f1b79c7c01523608af7c3de08ea1
Author: Sergey Sharybin
Date:   Wed May 25 17:15:55 2016 +0200
Branches: depsgraph_cleanup
https://developer.blender.org/rBd4132afe67a8f1b79c7c01523608af7c3de08ea1

Depsgraph: Move update tag flushing to eval folder

Those are mainly used by evaluation, so makes sense to have it there.

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

M       source/blender/depsgraph/CMakeLists.txt
M       source/blender/depsgraph/DEG_depsgraph.h
M       source/blender/depsgraph/intern/depsgraph_eval.cc
M       source/blender/depsgraph/intern/depsgraph_tag.cc
M       source/blender/depsgraph/intern/eval/deg_eval.cc
A       source/blender/depsgraph/intern/eval/deg_eval_flush.cc
A       source/blender/depsgraph/intern/eval/deg_eval_flush.h

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

diff --git a/source/blender/depsgraph/CMakeLists.txt 
b/source/blender/depsgraph/CMakeLists.txt
index 27cdb02..4ff2505 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -47,6 +47,7 @@ set(SRC
        intern/builder/deg_builder_relations.cc
        intern/eval/deg_eval.cc
        intern/eval/deg_eval_debug.cc
+       intern/eval/deg_eval_flush.cc
        intern/depsgraph.cc
        intern/depsnode.cc
        intern/depsnode_component.cc
@@ -73,6 +74,7 @@ set(SRC
        intern/builder/deg_builder_relations.h
        intern/eval/deg_eval.h
        intern/eval/deg_eval_debug.h
+       intern/eval/deg_eval_flush.h
        intern/depsgraph.h
        intern/depsnode.h
        intern/depsnode_component.h
diff --git a/source/blender/depsgraph/DEG_depsgraph.h 
b/source/blender/depsgraph/DEG_depsgraph.h
index f37ba71..79b0f5c 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -131,9 +131,6 @@ void DEG_ids_clear_recalc(struct Main *bmain);
 
 /* Update Flushing ------------------------------- */
 
-/* Flush updates */
-void DEG_graph_flush_updates(struct Main *bmain, Depsgraph *graph);
-
 /* Flush updates for all IDs */
 void DEG_ids_flush_tagged(struct Main *bmain);
 
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc 
b/source/blender/depsgraph/intern/depsgraph_eval.cc
index ec884b6..29a1b22 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -42,6 +42,7 @@ extern "C" {
 } /* extern "C" */
 
 #include "eval/deg_eval.h"
+#include "eval/deg_eval_flush.h"
 #include "depsgraph.h"
 #include "depsnode_operation.h"
 
@@ -136,7 +137,7 @@ void DEG_evaluate_on_framechange(EvaluationContext 
*eval_ctx,
 
        tsrc->tag_update(graph);
 
-       DEG_graph_flush_updates(bmain, graph);
+       DEG::deg_graph_flush_updates(bmain, graph);
 
        /* Perform recalculation updates. */
        DEG::deg_evaluate_on_refresh(eval_ctx, graph, layers);
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc 
b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 9676fb0..e74b064 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -55,6 +55,7 @@ extern "C" {
 #include "DEG_depsgraph.h"
 } /* extern "C" */
 
+#include "eval/deg_eval_flush.h"
 #include "depsgraph_debug.h"
 #include "depsnode.h"
 #include "depsnode_component.h"
@@ -260,123 +261,6 @@ void DEG_id_type_tag(Main *bmain, short idtype)
        bmain->id_tag_update[((unsigned char *)&idtype)[0]] = 1;
 }
 
-/* Update Flushing ---------------------------------- */
-
-/* FIFO queue for tagged nodes that need flushing */
-/* XXX This may get a dedicated implementation later if needed - lukas */
-typedef std::queue<OperationDepsNode *> FlushQueue;
-
-static void flush_init_func(void *data_v, int i)
-{
-       /* ID node's done flag is used to avoid multiple editors update
-        * for the same ID.
-        */
-       Depsgraph *graph = (Depsgraph *)data_v;
-       OperationDepsNode *node = graph->operations[i];
-       IDDepsNode *id_node = node->owner->owner;
-       id_node->done = 0;
-       node->scheduled = false;
-       node->owner->flags &= ~DEPSCOMP_FULLY_SCHEDULED;
-}
-
-/* Flush updates from tagged nodes outwards until all affected nodes are 
tagged. */
-void DEG_graph_flush_updates(Main *bmain, Depsgraph *graph)
-{
-       /* sanity check */
-       if (graph == NULL)
-               return;
-
-       /* Nothing to update, early out. */
-       if (graph->entry_tags.size() == 0) {
-               return;
-       }
-
-       /* TODO(sergey): With a bit of flag magic we can get rid of this
-        * extra loop.
-        */
-       const int num_operations = graph->operations.size();
-       const bool do_threads = num_operations > 256;
-       BLI_task_parallel_range(0, num_operations, graph, flush_init_func, 
do_threads);
-
-       FlushQueue queue;
-       /* Starting from the tagged "entry" nodes, flush outwards... */
-       /* NOTE: Also need to ensure that for each of these, there is a path 
back to
-        *       root, or else they won't be done.
-        * NOTE: Count how many nodes we need to handle - entry nodes may be
-        *       component nodes which don't count for this purpose!
-        */
-       foreach (OperationDepsNode *node, graph->entry_tags) {
-               IDDepsNode *id_node = node->owner->owner;
-               queue.push(node);
-               if (id_node->done == 0) {
-                       deg_editors_id_update(bmain, id_node->id);
-                       id_node->done = 1;
-               }
-               node->scheduled = true;
-       }
-
-       while (!queue.empty()) {
-               OperationDepsNode *node = queue.front();
-               queue.pop();
-
-               IDDepsNode *id_node = node->owner->owner;
-               lib_id_recalc_tag(bmain, id_node->id);
-               /* TODO(sergey): For until we've got proper data nodes in the 
graph. */
-               lib_id_recalc_data_tag(bmain, id_node->id);
-
-               ID *id = id_node->id;
-               /* This code is used to preserve those areas which does direct
-                * object update,
-                *
-                * Plus it ensures visibility changes and relations and layers
-                * visibility update has proper flags to work with.
-                */
-               if (GS(id->name) == ID_OB) {
-                       Object *object = (Object *)id;
-                       ComponentDepsNode *comp_node = node->owner;
-                       if (comp_node->type == DEPSNODE_TYPE_ANIMATION) {
-                               object->recalc |= OB_RECALC_TIME;
-                       }
-                       else if (comp_node->type == DEPSNODE_TYPE_TRANSFORM) {
-                               object->recalc |= OB_RECALC_OB;
-                       }
-                       else {
-                               object->recalc |= OB_RECALC_DATA;
-                       }
-               }
-
-               /* Flush to nodes along links... */
-               foreach (DepsRelation *rel, node->outlinks) {
-                       OperationDepsNode *to_node = (OperationDepsNode 
*)rel->to;
-                       if (to_node->scheduled == false) {
-                               to_node->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
-                               queue.push(to_node);
-                               to_node->scheduled = true;
-                               if (id_node->done == 0) {
-                                       deg_editors_id_update(bmain, 
id_node->id);
-                                       id_node->done = 1;
-                               }
-                       }
-               }
-
-               /* TODO(sergey): For until incremental updates are possible
-                * witin a component at least we tag the whole component
-                * for update.
-                */
-               ComponentDepsNode *component = node->owner;
-               if ((component->flags & DEPSCOMP_FULLY_SCHEDULED) == 0) {
-                       for (ComponentDepsNode::OperationMap::iterator it = 
component->operations.begin();
-                            it != node->owner->operations.end();
-                            ++it)
-                       {
-                               OperationDepsNode *op = it->second;
-                               op->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
-                       }
-                       component->flags |= DEPSCOMP_FULLY_SCHEDULED;
-               }
-       }
-}
-
 /* Recursively push updates out to all nodes dependent on this,
  * until all affected are tagged and/or scheduled up for eval
  */
@@ -388,7 +272,7 @@ void DEG_ids_flush_tagged(Main *bmain)
        {
                /* TODO(sergey): Only visible scenes? */
                if (scene->depsgraph != NULL) {
-                       DEG_graph_flush_updates(bmain, scene->depsgraph);
+                       DEG::deg_graph_flush_updates(bmain, scene->depsgraph);
                }
        }
 }
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc 
b/source/blender/depsgraph/intern/eval/deg_eval.cc
index ecd026c..340ef49 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -47,6 +47,7 @@ extern "C" {
 #include "atomic_ops.h"
 
 #include "eval/deg_eval_debug.h"
+#include "eval/deg_eval_flush.h"
 #include "depsgraph.h"
 #include "depsnode.h"
 #include "depsnode_component.h"
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc 
b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
new file mode 100644
index 0000000..4b5233e
--- /dev/null
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -0,0 +1,191 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013 Blender Foundation.
+ * All rights reserved.
+ *
+ * Original Author: Joshua Leung
+ * Contributor(s): None Yet
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/depsgraph/intern/depsgraph_tag.cc
+ *  \ingroup depsgraph
+ *
+ * Core routines for how the Depsgraph works.
+ */
+
+#include "eval/deg_eval_flush.h"
+
+// TODO(sergey): Use some sort of wrapper.
+#include <queue>
+
+extern "C" {
+#include "DNA_object_types.h"
+
+#include "BLI_task.h"
+
+#include "DEG_depsgraph.h"
+} /* extern "C" */
+
+#include "depsnode.h"
+#include "depsnode_component.h"
+#include "depsnode_operation.h"
+#include "depsgraph_intern.h"
+#include "depsgraph_util_foreach.h"
+
+namespace DEG {
+
+namespace {
+
+// TODO(sergey): De-duplicate with depsgraph_tag,cc
+void lib_id_recalc_tag(Main *bmain, ID *id)
+{
+       id->tag |= LIB_TAG_ID_RECALC;
+       DEG_id_type_tag(bmain, GS(id->name));
+}
+
+void lib_id_recalc_data_tag(Main *bmain, ID *id)
+{
+       id->tag |= LIB_TAG_ID_RECALC_DATA;
+       DEG_id_type_tag(bmain, GS(id->name));
+}
+
+}  /* namespace */
+
+typedef std::queue<OperationDepsNode *> FlushQueue;
+
+static void flush_init_func(void *data_v, int i)
+{
+       /* ID node's done flag is used to avoid multiple editors update
+        * for the same ID.
+        */
+       Depsgraph *graph = (Depsgraph *)data_v;
+       OperationDepsNode *node = graph->operations[i];
+       IDDepsNode *id_node = node->owner->owner;
+       id_node->done = 0;
+       node->scheduled = false;
+       node->owner->flags &= ~DEPSCOMP_FULLY_SCHEDULED;
+}
+
+/* Flush updates from tagged nodes outwards until all affected nodes
+ * are tagged.
+ */
+void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
+{
+       /* Sanity check. */
+       if (graph == NULL) {
+               return;
+       }
+
+       /* Nothing to update, early out. */
+       if (graph->entry_tags.size() == 0) {
+               return;
+       }
+
+       /* TODO(sergey): With a bit of flag magic we can get rid of this
+        * extra loop.
+        */
+       const int num_operations = graph->operations.size();
+       const bool do_threads = num_operations > 256;
+       BLI_task_parallel_range(0,
+                               num_op

@@ 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