Commit: 6365ddcab559bd0abdfb86e04834d3d1ecbe6e95
Author: Sergey Sharybin
Date:   Fri Dec 1 17:30:36 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB6365ddcab559bd0abdfb86e04834d3d1ecbe6e95

Depsgraph: Separate loop for ID node flags clear

This ends up in less number of memory writes, which should have positive effect
on performance.

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

M       source/blender/depsgraph/intern/eval/deg_eval_flush.cc

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

diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc 
b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 6c491c389ca..7558ef930c2 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -65,32 +65,35 @@ typedef std::deque<OperationDepsNode *> FlushQueue;
 
 namespace {
 
-void flush_init_func(void *data_v, int i)
+void flush_init_operation_node_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];
-       ComponentDepsNode *comp_node = node->owner;
-       IDDepsNode *id_node = comp_node->owner;
-       id_node->done = 0;
-       comp_node->done = COMPONENT_STATE_NONE;
        node->scheduled = false;
 }
 
+void flush_init_id_node_func(void *data_v, int i)
+{
+       Depsgraph *graph = (Depsgraph *)data_v;
+       IDDepsNode *id_node = graph->id_nodes[i];
+       id_node->done = 0;
+       GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components)
+               comp_node->done = COMPONENT_STATE_NONE;
+       GHASH_FOREACH_END();
+}
+
 BLI_INLINE void flush_prepare(Depsgraph *graph)
 {
-       /* 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,
+       BLI_task_parallel_range(0, num_operations,
+                               graph,
+                               flush_init_operation_node_func,
+                               (num_operations > 256));
+       const int num_id_nodes = graph->id_nodes.size();
+       BLI_task_parallel_range(0, num_id_nodes,
                                graph,
-                               flush_init_func,
-                               do_threads);
+                               flush_init_id_node_func,
+                               (num_id_nodes > 256));
 }
 
 BLI_INLINE void flush_schedule_entrypoints(Depsgraph *graph, FlushQueue *queue)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to