[Bf-blender-cvs] [a9907e2] depsgraph_refactor: Moved relations from generic DepsNode base class into OperationDepsNode.

Lukas Tönne noreply at git.blender.org
Tue May 13 18:41:03 CEST 2014


Commit: a9907e2c50f560dc86cce5fc0ca68c488b9a0e68
Author: Lukas Tönne
Date:   Sun May 11 08:46:27 2014 +0200
https://developer.blender.org/rBa9907e2c50f560dc86cce5fc0ca68c488b9a0e68

Moved relations from generic DepsNode base class into OperationDepsNode.

Rationale here is that only relations between operations matter for the
final evaluation. Keeping this specific makes it easier to avoid
implicit assumptions and confusing upcasts in the evaluation code.

Relations between "outer" nodes (ID nodes and components) will be
translated directly into relations of their inner operation nodes (this
will require fully built operations lists at the time relations are
constructed). Higher level relations may be used for debugging purposes,
but they are not required for evaluation and should be handled in a
separate structure.

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

M	source/blender/depsgraph/intern/depsgraph.cpp
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_debug.cpp
M	source/blender/depsgraph/intern/depsgraph_eval.cpp
M	source/blender/depsgraph/intern/depsgraph_query.cpp
M	source/blender/depsgraph/intern/depsgraph_tag.cpp
M	source/blender/depsgraph/intern/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode.h
M	source/blender/depsgraph/intern/depsnode_component.cpp
M	source/blender/depsgraph/intern/depsnode_component.h
M	source/blender/depsgraph/intern/depsnode_operation.cpp
M	source/blender/depsgraph/intern/depsnode_operation.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index c920b12..03706a3 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -197,7 +197,7 @@ void Depsgraph::clear_id_nodes()
 }
 
 /* Add new relationship between two nodes */
-DepsRelation *Depsgraph::add_new_relation(DepsNode *from, DepsNode *to, 
+DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from, OperationDepsNode *to, 
                                           eDepsRelation_Type type, 
                                           const string &description)
 {
@@ -247,7 +247,7 @@ void Depsgraph::sort()
 /* ************************************************** */
 /* Relationships Management */
 
-DepsRelation::DepsRelation(DepsNode *from, DepsNode *to, eDepsRelation_Type type, const string &description)
+DepsRelation::DepsRelation(OperationDepsNode *from, OperationDepsNode *to, eDepsRelation_Type type, const string &description)
 {
 	this->from = from;
 	this->to = to;
@@ -271,15 +271,12 @@ DepsRelation::~DepsRelation()
 /* Low level tagging -------------------------------------- */
 
 /* Tag a specific node as needing updates */
-void Depsgraph::tag_update(DepsNode *node)
+void Depsgraph::add_entry_tag(OperationDepsNode *node)
 {
 	/* sanity check */
 	if (!node)
 		return;
 	
-	/* tag for update, but also not that this was the source of an update */
-	node->flag |= (DEPSNODE_FLAG_NEEDS_UPDATE | DEPSNODE_FLAG_DIRECTLY_MODIFIED);
-	
 	/* add to graph-level set of directly modified nodes to start searching from
 	 * NOTE: this is necessary since we have several thousand nodes to play with...
 	 */
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 30d201a..88d40e8 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -74,8 +74,8 @@ typedef enum eDepsRelation_Flag {
 /* B depends on A (A -> B) */
 struct DepsRelation {
 	/* the nodes in the relationship (since this is shared between the nodes) */
-	DepsNode *from;               /* A */
-	DepsNode *to;                 /* B */
+	OperationDepsNode *from;      /* A */
+	OperationDepsNode *to;        /* B */
 	
 	/* relationship attributes */
 	string name;                  /* label for debugging */
@@ -83,7 +83,7 @@ struct DepsRelation {
 	eDepsRelation_Type type;      /* type */
 	int flag;                     /* (eDepsRelation_Flag) */
 	
-	DepsRelation(DepsNode *from, DepsNode *to, eDepsRelation_Type type, const string &description);
+	DepsRelation(OperationDepsNode *from, OperationDepsNode *to, eDepsRelation_Type type, const string &description);
 	~DepsRelation();
 	
 #ifdef WITH_CXX_GUARDEDALLOC
@@ -98,8 +98,8 @@ struct DepsRelation {
 struct Depsgraph {
 	typedef unordered_map<const ID *, IDDepsNode *> IDNodeMap;
 	typedef unordered_set<SubgraphDepsNode *> Subgraphs;
-	typedef unordered_set<DepsNode *> EntryTags;
-	typedef vector<DepsNode *> OperationNodes;
+	typedef unordered_set<OperationDepsNode *> EntryTags;
+	typedef vector<OperationDepsNode *> OperationNodes;
 	
 	Depsgraph();
 	~Depsgraph();
@@ -136,7 +136,7 @@ struct Depsgraph {
 	void clear_id_nodes();
 	
 	/* Add new relationship between two nodes */
-	DepsRelation *add_new_relation(DepsNode *from, DepsNode *to,
+	DepsRelation *add_new_relation(OperationDepsNode *from, OperationDepsNode *to,
 	                               eDepsRelation_Type type, 
 	                               const string &description);
 	
@@ -151,7 +151,7 @@ struct Depsgraph {
 	void sort();
 	
 	/* Tag a specific node as needing updates */
-	void tag_update(DepsNode *node);
+	void add_entry_tag(OperationDepsNode *node);
 	
 	
 	/* Core Graph Functionality ........... */
@@ -184,7 +184,7 @@ struct Depsgraph {
  */
 #define DEPSNODE_RELATIONS_ITER_BEGIN(relations_set_, relation_)                          \
 	{                                                                                \
-		DepsNode::Relations::const_iterator __rel_iter = relations_set_.begin();     \
+		OperationDepsNode::Relations::const_iterator __rel_iter = relations_set_.begin();     \
 		while (__rel_iter != relations_set_.end()) {                                 \
 			DepsRelation *relation_ = *__rel_iter;                                   \
 			++__rel_iter;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 2fb0032..49a419a 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -313,12 +313,25 @@ DepsNode *DepsgraphRelationBuilder::find_node(const RNAPathKey &key) const
 	return m_graph->find_node_from_pointer(&key.ptr, key.prop);
 }
 
-void DepsgraphRelationBuilder::add_node_relation(DepsNode *node_from, DepsNode *node_to,
-                                            eDepsRelation_Type type, const string &description)
+void DepsgraphRelationBuilder::add_operation_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
+                                                      eDepsRelation_Type type, const string &description)
 {
 	m_graph->add_new_relation(node_from, node_to, type, description);
 }
 
+void DepsgraphRelationBuilder::add_node_relation(DepsNode *node_from, DepsNode *node_to,
+                                                 eDepsRelation_Type type, const string &description)
+{
+	OperationDepsNode *op_from = node_from->find_exit_operation();
+	OperationDepsNode *op_to = node_to->find_entry_operation();
+	if (op_from && op_to) {
+		add_operation_relation(op_from, op_to, type, description);
+	}
+	else {
+		/* XXX error handling necessary? */
+	}
+}
+
 /* -------------------------------------------------- */
 
 /* Build depsgraph for the given scene, and dump results in given graph container */
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index afc6f7b..b716950 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -199,8 +199,10 @@ protected:
 	OperationDepsNode *find_node(const OperationKey &key) const;
 	DepsNode *find_node(const RNAPathKey &key) const;
 	
+	void add_operation_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
+	                            eDepsRelation_Type type, const string &description);
 	void add_node_relation(DepsNode *node_from, DepsNode *node_to,
-	                  eDepsRelation_Type type, const string &description);
+	                       eDepsRelation_Type type, const string &description);
 	
 	template <typename KeyType>
 	DepsNodeHandle create_node_handle(const KeyType &key, const string &default_name = "");
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index 94f9e6c..1d09e3a 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -482,7 +482,7 @@ static bool deg_debug_graphviz_is_owner(const DepsNode *node, const DepsNode *ot
 	return false;
 }
 
-static void deg_debug_graphviz_node_relations(const DebugContext &ctx, const DepsNode *node)
+static void deg_debug_graphviz_node_relations(const DebugContext &ctx, const OperationDepsNode *node)
 {
 	DEPSNODE_RELATIONS_ITER_BEGIN(node->inlinks, rel)
 	{
@@ -512,6 +512,7 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx, const Dep
 	}
 	DEPSNODE_RELATIONS_ITER_END;
 
+#if 0
 	if (node->tclass == DEPSNODE_CLASS_COMPONENT) {
 		const ComponentDepsNode *comp_node = (const ComponentDepsNode *)node;
 		for (ComponentDepsNode::OperationMap::const_iterator it = comp_node->operations.begin(); it != comp_node->operations.end(); ++it) {
@@ -532,6 +533,7 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx, const Dep
 			deg_debug_graphviz_graph_relations(ctx, sub_node->graph);
 		}
 	}
+#endif
 }
 
 static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx, const Depsgraph *graph)
@@ -546,12 +548,19 @@ static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx, const Depsgr
 
 static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const Depsgraph *graph)
 {
+#if 0
 	if (graph->root_node)
 		deg_debug_graphviz_node_relations(ctx, graph->root_node);
 	for (Depsgraph::IDNodeMap::const_iterator it = graph->id_hash.begin(); it != graph->id_hash.end(); ++it) {
-		DepsNode *node = it->second;
-		deg_debug_graphviz_node_relations(ctx, node);
+		DepsNode *id_node = it->second;
+		deg_debug_graphviz_node_relations(ctx, id_node);
 	}
+#else
+	for (Depsgraph::OperationNodes::const_iterator it = graph->all_opnodes.begin(); it != graph->all_opnodes.end(); ++it) {
+		OperationDepsNode *op_node = *it;
+		deg_debug_graphviz_node_relations(ctx, op_node);
+	}
+#endif
 }
 
 void DEG_debug_graphviz(const Depsgraph *graph, FILE *f, const char *label, bool show_tags)
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index 4f057ee..49db9fb 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -153,7 +153,9 @@ void DEG_evaluate_on_framechange(Depsgraph *graph, eEvaluationContextType contex
 	tsrc = (TimeSourceDepsNode *)graph->find_node(NULL, "", DEPSNODE_TYPE_TIMESOURCE, "");
 	tsrc->cfra = ctime;
 	
+#if 0 /* XXX TODO */
 	graph->tag_update(tsrc);
+#endif
 	
 	/* recursively push updates out to all nodes dependent on this, 
 	 * until all affected are tagged and/or scheduled up for eval
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cpp b/source/blender/depsgraph/intern/depsgraph_query.cpp
index 1ba4b38..5632a5a 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_query.cpp
@@ -71,7 +71,7 @@ void DEG_graph_traverse_begin(Depsgraph *graph)
 
 /* Perform a traversal of graph from given starting node (in execution order) */
 // TODO: additional flags for controlling the process?
-void DEG_graph_traverse_from_nod

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list