[Bf-blender-cvs] [d57cb8fa22e] blender2.8: Depsgraph: Use more meaningful name for flags storage
Sergey Sharybin
noreply at git.blender.org
Mon Sep 3 15:20:10 CEST 2018
Commit: d57cb8fa22eb757e0960cb1336f00e495519a939
Author: Sergey Sharybin
Date: Mon Sep 3 14:35:42 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBd57cb8fa22eb757e0960cb1336f00e495519a939
Depsgraph: Use more meaningful name for flags storage
===================================================================
M source/blender/depsgraph/intern/builder/deg_builder.cc
M source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
M source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
M source/blender/depsgraph/intern/depsgraph_debug.cc
M source/blender/depsgraph/intern/depsgraph_query_filter.cc
M source/blender/depsgraph/intern/depsgraph_query_foreach.cc
M source/blender/depsgraph/intern/eval/deg_eval.cc
M source/blender/depsgraph/intern/eval/deg_eval_flush.cc
M source/blender/depsgraph/intern/nodes/deg_node.h
===================================================================
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index 73edf0ef993..aacd106ceed 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -58,10 +58,14 @@ namespace {
void deg_graph_build_flush_visibility(Depsgraph *graph)
{
+ enum {
+ DEG_NODE_VISITED = (1 << 0),
+ };
+
BLI_Stack *stack = BLI_stack_new(sizeof(OperationDepsNode *),
"DEG flush layers stack");
foreach (OperationDepsNode *op_node, graph->operations) {
- op_node->done = 0;
+ op_node->custom_flags = 0;
op_node->num_links_pending = 0;
foreach (DepsRelation *rel, op_node->outlinks) {
if ((rel->from->type == DEG_NODE_TYPE_OPERATION) &&
@@ -72,7 +76,7 @@ void deg_graph_build_flush_visibility(Depsgraph *graph)
}
if (op_node->num_links_pending == 0) {
BLI_stack_push(stack, &op_node);
- op_node->done = 1;
+ op_node->custom_flags |= DEG_NODE_VISITED;
}
}
while (!BLI_stack_is_empty(stack)) {
@@ -94,9 +98,11 @@ void deg_graph_build_flush_visibility(Depsgraph *graph)
BLI_assert(op_from->num_links_pending > 0);
--op_from->num_links_pending;
}
- if (op_from->num_links_pending == 0 && op_from->done == 0) {
+ if ((op_from->num_links_pending == 0) &&
+ (op_from->custom_flags & DEG_NODE_VISITED) == 0)
+ {
BLI_stack_push(stack, &op_from);
- op_from->done = 1;
+ op_from->custom_flags |= DEG_NODE_VISITED;
}
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
index feaba1a4aa8..0d28344ef95 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
@@ -86,22 +86,22 @@ struct CyclesSolverState {
BLI_INLINE void set_node_visited_state(DepsNode *node,
eCyclicCheckVisitedState state)
{
- node->done = (node->done & ~0x3) | (int)state;
+ node->custom_flags = (node->custom_flags & ~0x3) | (int)state;
}
BLI_INLINE eCyclicCheckVisitedState get_node_visited_state(DepsNode *node)
{
- return (eCyclicCheckVisitedState)(node->done & 0x3);
+ return (eCyclicCheckVisitedState)(node->custom_flags & 0x3);
}
BLI_INLINE void set_node_num_visited_children(DepsNode *node, int num_children)
{
- node->done = (node->done & 0x3) | (num_children << 2);
+ node->custom_flags = (node->custom_flags & 0x3) | (num_children << 2);
}
BLI_INLINE int get_node_num_visited_children(DepsNode *node)
{
- return node->done >> 2;
+ return node->custom_flags >> 2;
}
void schedule_node_to_stack(CyclesSolverState *state, OperationDepsNode *node)
@@ -124,7 +124,7 @@ void schedule_leaf_nodes(CyclesSolverState *state)
has_inlinks = true;
}
}
- node->done = 0;
+ node->custom_flags = 0;
if (has_inlinks == false) {
schedule_node_to_stack(state, node);
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
index 17e64c5f685..a39b18f2f0a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
@@ -65,16 +65,16 @@ enum {
static void deg_graph_tag_paths_recursive(DepsNode *node)
{
- if (node->done & OP_VISITED) {
+ if (node->custom_flags & OP_VISITED) {
return;
}
- node->done |= OP_VISITED;
+ node->custom_flags |= OP_VISITED;
foreach (DepsRelation *rel, node->inlinks) {
deg_graph_tag_paths_recursive(rel->from);
/* Do this only in inlinks loop, so the target node does not get
* flagged.
*/
- rel->from->done |= OP_REACHABLE;
+ rel->from->custom_flags |= OP_REACHABLE;
}
}
@@ -84,13 +84,13 @@ void deg_graph_transitive_reduction(Depsgraph *graph)
foreach (OperationDepsNode *target, graph->operations) {
/* Clear tags. */
foreach (OperationDepsNode *node, graph->operations) {
- node->done = 0;
+ node->custom_flags = 0;
}
/* Mark nodes from which we can reach the target
* start with children, so the target node and direct children are not
* flagged.
*/
- target->done |= OP_VISITED;
+ target->custom_flags |= OP_VISITED;
foreach (DepsRelation *rel, target->inlinks) {
deg_graph_tag_paths_recursive(rel->from);
}
@@ -101,13 +101,14 @@ void deg_graph_transitive_reduction(Depsgraph *graph)
{
DepsRelation *rel = *it_rel;
if (rel->from->type == DEG_NODE_TYPE_TIMESOURCE) {
- /* HACK: time source nodes don't get "done" flag set/cleared. */
+ /* HACK: time source nodes don't get "custom_flags" flag
+ * set/cleared. */
/* TODO: there will be other types in future, so iterators above
* need modifying.
*/
++it_rel;
}
- else if (rel->from->done & OP_REACHABLE) {
+ else if (rel->from->custom_flags & OP_REACHABLE) {
rel->unlink();
OBJECT_GUARDED_DELETE(rel, DepsRelation);
++num_removed_relations;
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index f7adaafe5b3..91db054b006 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -171,11 +171,11 @@ bool DEG_debug_consistency_check(Depsgraph *graph)
/* Validate node valency calculated in both directions. */
foreach (DEG::OperationDepsNode *node, deg_graph->operations) {
node->num_links_pending = 0;
- node->done = 0;
+ node->custom_flags = 0;
}
foreach (DEG::OperationDepsNode *node, deg_graph->operations) {
- if (node->done) {
+ if (node->custom_flags) {
printf("Node %s is twice in the operations!\n",
node->identifier().c_str());
return false;
@@ -187,7 +187,7 @@ bool DEG_debug_consistency_check(Depsgraph *graph)
++to->num_links_pending;
}
}
- node->done = 1;
+ node->custom_flags = 1;
}
foreach (DEG::OperationDepsNode *node, deg_graph->operations) {
diff --git a/source/blender/depsgraph/intern/depsgraph_query_filter.cc b/source/blender/depsgraph/intern/depsgraph_query_filter.cc
index 46abd9d9941..11858bd1b1c 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_filter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_filter.cc
@@ -120,12 +120,12 @@ static void deg_unlink_opnode(Depsgraph *graph, OperationDepsNode *op_node)
static void deg_filter_remove_unwanted_ids(Depsgraph *graph, GSet *retained_ids)
{
/* 1) First pass over ID nodes + their operations
- * - Identify and tag ID's (via "done = 1") to be removed
+ * - Identify and tag ID's (via "custom_flags = 1") to be removed
* - Remove all links to/from operations that will be removed
*/
foreach (IDDepsNode *id_node, graph->id_nodes) {
- id_node->done = !BLI_gset_haskey(retained_ids, (void *)id_node->id_orig);
- if (id_node->done) {
+ id_node->custom_flags = !BLI_gset_haskey(retained_ids, (void *)id_node->id_orig);
+ if (id_node->custom_flags) {
GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components)
{
foreach (OperationDepsNode *op_node, comp_node->operations) {
@@ -143,7 +143,7 @@ static void deg_filter_remove_unwanted_ids(Depsgraph *graph, GSet *retained_ids)
{
OperationDepsNode *op_node = *it_opnode;
IDDepsNode *id_node = op_node->owner->owner;
- if (id_node->done) {
+ if (id_node->custom_flags) {
it_opnode = graph->operations.erase(it_opnode);
}
else {
@@ -164,7 +164,7 @@ static void deg_filter_remove_unwanted_ids(Depsgraph *graph, GSet *retained_ids)
IDDepsNode *id_node = *it_id;
ID *id = id_node->id_orig;
- if (id_node->done) {
+ if (id_node->custom_flags) {
/* Destroy node data, then remove from collections, and free */
id_node->destroy();
diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
index c8aaf353874..b6138e4e81c 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
@@ -60,6 +60,9 @@ extern "C" {
namespace DEG {
typedef std::deque<OperationDepsNode *> TraversalQueue;
+enum {
+ DEG_NODE_VISITED = (1 << 0),
+};
static void deg_foreach_clear_flags(const Depsgraph *graph)
{
@@ -67,7 +70,7 @@ static void deg_foreach_clear_flags(const Depsgraph *graph)
op_node->scheduled = false;
}
foreach (IDDepsNode *id_node, graph->id_nodes) {
- id_node->done = false;
+ id_node->custom_flags = 0;
}
}
@@ -96,7 +99,7 @@ static void deg_foreach_dependent_ID(const Depsgraph *graph,
}
}
GHASH_FOREACH_END();
- target_id_node->done = true;
+ target_id_node->custom_flags |= DEG_NODE_VISITED;
/* Process the queue. */
while (!queue.empty()) {
/* get next operation node to process. */
@@ -106,10 +109,10 @@ static void deg_foreach_dependent_ID(const Depsgraph *graph,
/* Check whether we need to inform callee about corresponding ID node. */
ComponentDepsNode *comp_node = op_node->owner;
IDDepsNode *id_node = comp_node->owner;
- if (!id_node->done) {
+ if ((id_node->custom_flags & DEG_NODE_VISITED) == 0) {
/* TODO(sergey): Is it orig or CoW? */
callback(id_node->id_orig, user_data);
- id_node->done = true;
+ id_node->custom_flags |= DEG_NODE_VISITED;
}
/* Schedule outgoing operation nodes. */
if (op_node->outlinks.size() == 1) {
@@ -161,7 +164,7 @@ static void deg_foreach_ancestor_ID(const Depsgraph *graph,
}
}
GHASH_FOREACH_END();
- target_id_node->done = true;
+ target_id_node->custom_flags |= DEG_NODE_VISITED;
/* Process the queue. */
while (!queue.empty()) {
/* get next operation node to process. */
@@ -171,10 +174,10 @@ static void deg_foreach_ancestor_ID(const Depsgraph *graph,
/* Check whether we need to inform callee about corresponding ID node. */
ComponentDepsNode *comp_node = op_node->owner;
IDDepsNode *id_node = comp_node->owner;
- if (!id_node->done) {
+ if ((id_node->custom_flags & DEG_NODE_VISITED) == 0) {
/* TODO(sergey): Is it orig or CoW? */
callback(id_node->id_orig
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list