[Bf-blender-cvs] [5726ab7] depsgraph_refactor: Moved DepsRelations (i.e. inlinks/outlinks lists) back to DepsNode as originally intended

Joshua Leung noreply at git.blender.org
Thu Dec 18 09:18:22 CET 2014


Commit: 5726ab7daae2163a517bf850ad22615defaacc20
Author: Joshua Leung
Date:   Thu Dec 18 19:30:39 2014 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB5726ab7daae2163a517bf850ad22615defaacc20

Moved DepsRelations (i.e. inlinks/outlinks lists) back to DepsNode as originally intended

Otherwise, it really doesn't make much sense that we're deriving all these different
node types from DepsNode, when these can't represent relationships between different
nodes. Also, this will be useful for some upcoming new node types for keeping track
of other kinds of dependencies other than what's executable.

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

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/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode.h
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 a8aa5aa..7c8d0ca 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -265,6 +265,16 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from,
 	return rel;
 }
 
+/* Add new relation between two nodes */
+DepsRelation *Depsgraph::add_new_relation(DepsNode *from, DepsNode *to, 
+                                          eDepsRelation_Type type, 
+                                          const string &description)
+{
+	/* Create new relation, and add it to the graph. */
+	DepsRelation *rel = OBJECT_GUARDED_NEW(DepsRelation, from, to, type, description);
+	return rel;
+}
+
 /* Sort nodes to determine evaluation order for operation nodes
  * where dependency relationships won't get violated.
  */
@@ -289,8 +299,8 @@ void Depsgraph::sort()
 /* ************************************************** */
 /* Relationships Management */
 
-DepsRelation::DepsRelation(OperationDepsNode *from,
-                           OperationDepsNode *to,
+DepsRelation::DepsRelation(DepsNode *from,
+                           DepsNode *to,
                            eDepsRelation_Type type,
                            const string &description)
 {
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 747acd3..aff3ab6 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -73,8 +73,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) */
-	OperationDepsNode *from;      /* A */
-	OperationDepsNode *to;        /* B */
+	DepsNode *from;               /* A */
+	DepsNode *to;                 /* B */
 
 	/* relationship attributes */
 	string name;                  /* label for debugging */
@@ -82,8 +82,8 @@ struct DepsRelation {
 	eDepsRelation_Type type;      /* type */
 	int flag;                     /* (eDepsRelation_Flag) */
 
-	DepsRelation(OperationDepsNode *from,
-	             OperationDepsNode *to,
+	DepsRelation(DepsNode *from,
+	             DepsNode *to,
 	             eDepsRelation_Type type,
 	             const string &description);
 
@@ -146,6 +146,11 @@ struct Depsgraph {
 	                               OperationDepsNode *to,
 	                               eDepsRelation_Type type,
 	                               const string &description);
+								   
+	DepsRelation *add_new_relation(DepsNode *from,
+	                               DepsNode *to,
+	                               eDepsRelation_Type type,
+	                               const string &description);
 
 	/* Sort nodes to determine evaluation order for operation nodes
 	 * where dependency relationships won't get violated.
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index a2f4818..598b640 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -391,6 +391,19 @@ DepsNode *DepsgraphRelationBuilder::find_node(const RNAPathKey &key) const
 	return m_graph->find_node_from_pointer(&key.ptr, key.prop);
 }
 
+void DepsgraphRelationBuilder::add_time_relation(TimeSourceDepsNode *timesrc, DepsNode *node_to, const string &description)
+{
+	if (timesrc && node_to) {
+		m_graph->add_new_relation(timesrc, node_to, DEPSREL_TYPE_TIME, description);
+	}
+	else {
+		fprintf(stderr, "add_time_relation(%p = %s, %p = %s, %s) Failed\n", 
+		        timesrc,   (timesrc) ? timesrc->identifier().c_str() : "<None>",
+		        node_to,   (node_to) ? node_to->identifier().c_str() : "<None>",
+		        description.c_str());
+	}
+}
+
 void DepsgraphRelationBuilder::add_operation_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
                                                       eDepsRelation_Type type, const string &description)
 {
@@ -424,7 +437,7 @@ enum {
 	OP_REACHABLE = 2,
 };
 
-static void deg_graph_tag_paths_recursive(OperationDepsNode *node)
+static void deg_graph_tag_paths_recursive(DepsNode *node)
 {
 	if (node->done & OP_VISITED)
 		return;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 00c15a2..006ac9f 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -262,6 +262,7 @@ protected:
 	OperationDepsNode *find_node(const OperationKey &key) const;
 	DepsNode *find_node(const RNAPathKey &key) const;
 	
+	void add_time_relation(TimeSourceDepsNode *timesrc, DepsNode *node_to, const string &description);
 	void add_operation_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
 	                            eDepsRelation_Type type, const string &description);
 	
@@ -355,9 +356,12 @@ void DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from, const
 	BLI_assert(type == DEPSREL_TYPE_TIME);
 	TimeSourceDepsNode *time_from = find_node(key_from);
 	OperationDepsNode *op_to = get_entry_operation(find_node(key_to));
+	
 	if (time_from && op_to) {
-		/* TODO(sergey): Store description as well. */
-		time_from->add_new_relation(op_to);
+		add_time_relation(time_from, op_to, description);
+	}
+	else {
+		
 	}
 }
 
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index 8878d74..45c87bb 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -131,7 +131,8 @@ static int deg_debug_node_color_index(const DepsNode *node)
 	switch (node->type) {
 		case DEPSNODE_TYPE_ID_REF:
 			return 5;
-		case DEPSNODE_TYPE_OPERATION: {
+		case DEPSNODE_TYPE_OPERATION:
+		{
 			OperationDepsNode *op_node = (OperationDepsNode *)node;
 			if (op_node->is_noop())
 				return 8;
@@ -425,7 +426,8 @@ static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const De
 static void deg_debug_graphviz_node(const DebugContext &ctx, const DepsNode *node)
 {
 	switch (node->type) {
-		case DEPSNODE_TYPE_ID_REF: {
+		case DEPSNODE_TYPE_ID_REF:
+		{
 			const IDDepsNode *id_node = (const IDDepsNode *)node;
 			if (id_node->components.empty()) {
 				deg_debug_graphviz_node_single(ctx, node);
@@ -441,7 +443,8 @@ static void deg_debug_graphviz_node(const DebugContext &ctx, const DepsNode *nod
 			break;
 		}
 		
-		case DEPSNODE_TYPE_SUBGRAPH: {
+		case DEPSNODE_TYPE_SUBGRAPH:
+		{
 			SubgraphDepsNode *sub_node = (SubgraphDepsNode *)node;
 			if (sub_node->graph) {
 				deg_debug_graphviz_node_cluster_begin(ctx, node);
@@ -518,14 +521,16 @@ static bool deg_debug_graphviz_is_cluster(const DepsNode *node)
 static bool deg_debug_graphviz_is_owner(const DepsNode *node, const DepsNode *other)
 {
 	switch (node->tclass) {
-		case DEPSNODE_CLASS_COMPONENT: {
+		case DEPSNODE_CLASS_COMPONENT:
+		{
 			ComponentDepsNode *comp_node = (ComponentDepsNode *)node;
 			if (comp_node->owner == other)
 				return true;
 			break;
 		}
 		
-		case DEPSNODE_CLASS_OPERATION: {
+		case DEPSNODE_CLASS_OPERATION:
+		{
 			OperationDepsNode *op_node = (OperationDepsNode *)node;
 			if (op_node->owner == other)
 				return true;
@@ -540,7 +545,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 OperationDepsNode *node)
+static void deg_debug_graphviz_node_relations(const DebugContext &ctx, const DepsNode *node)
 {
 	DEPSNODE_RELATIONS_ITER_BEGIN(node->inlinks, rel)
 	{
@@ -634,26 +639,10 @@ static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const De
 		}
 	}
 
-	/* TODO(sergey): Cleen this up somehow? */
 	TimeSourceDepsNode *time_source = graph->find_time_source(NULL);
 	if (time_source != NULL) {
-		for (vector<OperationDepsNode*>::const_iterator link = time_source->outlinks.begin();
-		     link != time_source->outlinks.end();
-		     ++link)
-		{
-			OperationDepsNode *node = *link;
-			deg_debug_printf(ctx, "// %s -> %s\n", time_source->identifier().c_str(), node->identifier().c_str());
-			deg_debug_printf(ctx, "\"node_%p\"", time_source);
-			deg_debug_printf(ctx, " -> ");
-			deg_debug_printf(ctx, "\"node_%p\"", node);
-
-			deg_debug_printf(ctx, "[");
-			/* TODO(sergey): Use proper relation name here. */
-			deg_debug_printf(ctx, "label=\"%s\"", "Time Dependency");
-			deg_debug_printf(ctx, ",fontname=\"%s\"", deg_debug_graphviz_fontname);
-			deg_debug_printf(ctx, "];" NL);
-			deg_debug_printf(ctx, NL);
-		}
+		printf("drawing timesource deps\n");
+		deg_debug_graphviz_node_relations(ctx, time_source);
 	}
 #endif
 }
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index 9e4740b..92ebba6 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -121,7 +121,10 @@ static void calculate_pending_parents(Depsgraph *graph)
 		if (node->flag & DEPSOP_FLAG_NEEDS_UPDATE) {
 			for (OperationDepsNode::Relations::const_iterator it_rel = node->inlinks.begin(); it_rel != node->inlinks.end(); ++it_rel) {
 				DepsRelation *rel = *it_rel;
-				if (rel->from->flag & DEPSOP_FLAG_NEEDS_UPDATE)
+				OperationDepsNode *from = (OperationDepsNode *)rel->from;
+				
+				BLI_assert(rel->from->type == DEPSNODE_TYPE_OPERATION);
+				if (from->flag & DEPSOP_FLAG_NEEDS_UPDATE)
 					++node->num_links_pending;
 			}
 		}
@@ -142,9 +145,12 @@ static void calculate_eval_priority(OperationDepsNode *node)
 		
 		for (OperationDepsNode::Relations::const_iterator it = node->outlinks.begin(); it != node->outlinks.end(); ++it) {
 			DepsRelation *rel = *it;
-			calculate_eval_priority(rel->to);
 			
-			node->eval_priority += rel->to->eval_priority;
+			OperationDepsNode *to = (OperationDepsNode *)rel->to;
+			BLI_assert(to->type == DEPSNODE_TYPE_OPERATION);
+			
+			calculate_eval_priority(to);
+			node->eval_priority += to->eval_priority;
 		}

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list