Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-09-03 15:35:42 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-09-03 16:20:06 +0300
commitd57cb8fa22eb757e0960cb1336f00e495519a939 (patch)
tree0b8c3267b56524233f36c766a80a3d17c5523d4d /source
parente152483a320d2da88199697da02ddb2befc73778 (diff)
Depsgraph: Use more meaningful name for flags storage
Diffstat (limited to 'source')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc14
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cycle.cc10
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_transitive.cc15
-rw-r--r--source/blender/depsgraph/intern/depsgraph_debug.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_filter.cc10
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_foreach.cc17
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc1
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc22
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node.h8
9 files changed, 59 insertions, 44 deletions
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, user_data);
- id_node->done = true;
+ id_node->custom_flags |= DEG_NODE_VISITED;
}
/* Schedule incoming operation nodes. */
if (op_node->inlinks.size() == 1) {
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index fb8b8e73ef6..0d1adfb0144 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -178,7 +178,6 @@ static void initialize_execution(DepsgraphEvalState *state, Depsgraph *graph)
calculate_pending_parents(graph);
/* Clear tags and other things which needs to be clear. */
foreach (OperationDepsNode *node, graph->operations) {
- node->done = 0;
if (do_stats) {
node->stats.reset_current();
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 16cb1b394f6..e59aed0f8d8 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -106,9 +106,9 @@ void flush_init_id_node_func(
{
Depsgraph *graph = (Depsgraph *)data_v;
IDDepsNode *id_node = graph->id_nodes[i];
- id_node->done = ID_STATE_NONE;
+ id_node->custom_flags = ID_STATE_NONE;
GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components)
- comp_node->done = COMPONENT_STATE_NONE;
+ comp_node->custom_flags = COMPONENT_STATE_NONE;
GHASH_FOREACH_END();
}
@@ -151,7 +151,7 @@ BLI_INLINE void flush_schedule_entrypoints(Depsgraph *graph, FlushQueue *queue)
BLI_INLINE void flush_handle_id_node(IDDepsNode *id_node)
{
- id_node->done = ID_STATE_MODIFIED;
+ id_node->custom_flags = ID_STATE_MODIFIED;
}
/* TODO(sergey): We can reduce number of arguments here. */
@@ -160,10 +160,10 @@ BLI_INLINE void flush_handle_component_node(IDDepsNode *id_node,
FlushQueue *queue)
{
/* We only handle component once. */
- if (comp_node->done == COMPONENT_STATE_DONE) {
+ if (comp_node->custom_flags == COMPONENT_STATE_DONE) {
return;
}
- comp_node->done = COMPONENT_STATE_DONE;
+ comp_node->custom_flags = COMPONENT_STATE_DONE;
/* Tag all required operations in component for update. */
foreach (OperationDepsNode *op, comp_node->operations) {
/* We don't want to flush tags in "upstream" direction for
@@ -183,9 +183,9 @@ BLI_INLINE void flush_handle_component_node(IDDepsNode *id_node,
ComponentDepsNode *pose_comp =
id_node->find_component(DEG_NODE_TYPE_EVAL_POSE);
BLI_assert(pose_comp != NULL);
- if (pose_comp->done == COMPONENT_STATE_NONE) {
+ if (pose_comp->custom_flags == COMPONENT_STATE_NONE) {
queue->push_front(pose_comp->get_entry_operation());
- pose_comp->done = COMPONENT_STATE_SCHEDULED;
+ pose_comp->custom_flags = COMPONENT_STATE_SCHEDULED;
}
}
}
@@ -236,7 +236,7 @@ void flush_editors_id_update(Main *bmain,
const DEGEditorUpdateContext *update_ctx)
{
foreach (IDDepsNode *id_node, graph->id_nodes) {
- if (id_node->done != ID_STATE_MODIFIED) {
+ if (id_node->custom_flags != ID_STATE_MODIFIED) {
continue;
}
DEG_id_type_tag(bmain, GS(id_node->id_orig->name));
@@ -251,7 +251,7 @@ void flush_editors_id_update(Main *bmain,
/* Gather recalc flags from all changed components. */
GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components)
{
- if (comp_node->done != COMPONENT_STATE_DONE) {
+ if (comp_node->custom_flags != COMPONENT_STATE_DONE) {
continue;
}
DepsNodeFactory *factory = deg_type_get_factory(comp_node->type);
@@ -311,7 +311,7 @@ void invalidate_tagged_evaluated_data(Depsgraph *graph)
{
#ifdef INVALIDATE_ON_FLUSH
foreach (IDDepsNode *id_node, graph->id_nodes) {
- if (id_node->done != ID_STATE_MODIFIED) {
+ if (id_node->custom_flags != ID_STATE_MODIFIED) {
continue;
}
ID *id_cow = id_node->id_cow;
@@ -320,7 +320,7 @@ void invalidate_tagged_evaluated_data(Depsgraph *graph)
}
GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components)
{
- if (comp_node->done != COMPONENT_STATE_DONE) {
+ if (comp_node->custom_flags != COMPONENT_STATE_DONE) {
continue;
}
switch (comp_node->type) {
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.h b/source/blender/depsgraph/intern/nodes/deg_node.h
index 603a6be7ceb..ef2a73258fd 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node.h
@@ -80,9 +80,15 @@ struct DepsNode {
eDepsNode_Type type; /* Structural type of node. */
Relations inlinks; /* Nodes which this one depends on. */
Relations outlinks; /* Nodes which depend on this one. */
- int done; /* Generic tags for traversal algorithms. */
Stats stats; /* Evaluation statistics. */
+ /* Generic tags for traversal algorithms and such.
+ *
+ * Actual meaning of values depends on a specific area. Every area is to
+ * clean this before use.
+ */
+ int custom_flags;
+
/* Methods. */
DepsNode();
virtual ~DepsNode();