[Bf-blender-cvs] [93b2871cf5c] master: Depsgraph: Remove node class stored in both type info and node

Sergey Sharybin noreply at git.blender.org
Thu Dec 21 10:37:15 CET 2017


Commit: 93b2871cf5c4a3c5346d9861c01b011021b7384d
Author: Sergey Sharybin
Date:   Wed Dec 20 17:54:52 2017 +0100
Branches: master
https://developer.blender.org/rB93b2871cf5c4a3c5346d9861c01b011021b7384d

Depsgraph: Remove node class stored in both type info and node

This is something deliver form node type, there is no reason to try cache it
anywhere, especially since it's not used in any performance critical code.

Lighter weight dependency graph is what we want.

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

M	source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph_intern.h
M	source/blender/depsgraph/intern/nodes/deg_node.cc
M	source/blender/depsgraph/intern/nodes/deg_node.h

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

diff --git a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
index 159e9bcf9a7..6d8fda97321 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
@@ -115,7 +115,7 @@ static int deg_debug_node_color_index(const DepsNode *node)
 			break;
 	}
 	/* Do others based on class. */
-	switch (node->tclass) {
+	switch (node->get_class()) {
 		case DEG_NODE_CLASS_OPERATION:
 			return 4;
 		case DEG_NODE_CLASS_COMPONENT:
@@ -202,7 +202,7 @@ static void deg_debug_graphviz_node_color(const DebugContext &ctx,
 	const char *color_update = "dodgerblue3";
 	const char *color = color_default;
 	if (ctx.show_tags) {
-		if (node->tclass == DEG_NODE_CLASS_OPERATION) {
+		if (node->get_class() == DEG_NODE_CLASS_OPERATION) {
 			OperationDepsNode *op_node = (OperationDepsNode *)node;
 			if (op_node->flag & DEPSOP_FLAG_DIRECTLY_MODIFIED) {
 				color = color_modified;
@@ -223,7 +223,7 @@ static void deg_debug_graphviz_node_penwidth(const DebugContext &ctx,
 	float penwidth_update = 4.0f;
 	float penwidth = penwidth_default;
 	if (ctx.show_tags) {
-		if (node->tclass == DEG_NODE_CLASS_OPERATION) {
+		if (node->get_class() == DEG_NODE_CLASS_OPERATION) {
 			OperationDepsNode *op_node = (OperationDepsNode *)node;
 			if (op_node->flag & DEPSOP_FLAG_DIRECTLY_MODIFIED) {
 				penwidth = penwidth_modified;
@@ -261,14 +261,14 @@ static void deg_debug_graphviz_node_style(const DebugContext &ctx, const DepsNod
 {
 	const char *base_style = "filled"; /* default style */
 	if (ctx.show_tags) {
-		if (node->tclass == DEG_NODE_CLASS_OPERATION) {
+		if (node->get_class() == DEG_NODE_CLASS_OPERATION) {
 			OperationDepsNode *op_node = (OperationDepsNode *)node;
 			if (op_node->flag & (DEPSOP_FLAG_DIRECTLY_MODIFIED | DEPSOP_FLAG_NEEDS_UPDATE)) {
 				base_style = "striped";
 			}
 		}
 	}
-	switch (node->tclass) {
+	switch (node->get_class()) {
 		case DEG_NODE_CLASS_GENERIC:
 			deg_debug_fprintf(ctx, "\"%s\"", base_style);
 			break;
@@ -293,7 +293,7 @@ static void deg_debug_graphviz_node_single(const DebugContext &ctx,
 		BLI_snprintf(buf, sizeof(buf), " (Layers: %u)", id_node->layers);
 		name += buf;
 	}
-	if (ctx.show_eval_priority && node->tclass == DEG_NODE_CLASS_OPERATION) {
+	if (ctx.show_eval_priority && node->get_class() == DEG_NODE_CLASS_OPERATION) {
 		priority = ((OperationDepsNode *)node)->eval_priority;
 	}
 	deg_debug_fprintf(ctx, "// %s\n", name.c_str());
@@ -440,7 +440,7 @@ 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) {
+	switch (node->get_class()) {
 		case DEG_NODE_CLASS_COMPONENT:
 		{
 			ComponentDepsNode *comp_node = (ComponentDepsNode *)node;
diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h
index f562f5d64f8..40229ef8f37 100644
--- a/source/blender/depsgraph/intern/depsgraph_intern.h
+++ b/source/blender/depsgraph/intern/depsgraph_intern.h
@@ -59,7 +59,6 @@ namespace DEG {
 /* Typeinfo Struct (nti) */
 struct DepsNodeFactory {
 	virtual eDepsNode_Type type() const = 0;
-	virtual eDepsNode_Class tclass() const = 0;
 	virtual const char *tname() const = 0;
 	virtual int id_recalc_tag() const = 0;
 
@@ -71,7 +70,6 @@ struct DepsNodeFactory {
 template <class NodeType>
 struct DepsNodeFactoryImpl : public DepsNodeFactory {
 	eDepsNode_Type type() const { return NodeType::typeinfo.type; }
-	eDepsNode_Class tclass() const { return NodeType::typeinfo.tclass; }
 	const char *tname() const { return NodeType::typeinfo.tname; }
 	int id_recalc_tag() const { return NodeType::typeinfo.id_recalc_tag; }
 
@@ -81,7 +79,6 @@ struct DepsNodeFactoryImpl : public DepsNodeFactory {
 
 		/* populate base node settings */
 		node->type = type();
-		node->tclass = tclass();
 
 		if (name[0] != '\0') {
 			/* set name if provided ... */
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc b/source/blender/depsgraph/intern/nodes/deg_node.cc
index e163e88e0ed..2c6c29fc14d 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node.cc
@@ -56,12 +56,6 @@ DepsNode::TypeInfo::TypeInfo(eDepsNode_Type type,
           tname(tname),
           id_recalc_tag(id_recalc_tag)
 {
-	if (type == DEG_NODE_TYPE_OPERATION)
-		this->tclass = DEG_NODE_CLASS_OPERATION;
-	else if (type < DEG_NODE_TYPE_PARAMETERS)
-		this->tclass = DEG_NODE_CLASS_GENERIC;
-	else
-		this->tclass = DEG_NODE_CLASS_COMPONENT;
 }
 
 DepsNode::DepsNode()
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.h b/source/blender/depsgraph/intern/nodes/deg_node.h
index 54042ae4a1b..05c787fba11 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node.h
@@ -52,23 +52,10 @@ struct DepsNode {
 	/* Helper class for static typeinfo in subclasses. */
 	struct TypeInfo {
 		TypeInfo(eDepsNode_Type type, const char *tname, int id_recalc_tag = 0);
-
 		eDepsNode_Type type;
-		eDepsNode_Class tclass;
 		const char *tname;
-
 		int id_recalc_tag;
 	};
-
-	/* Identifier - mainly for debugging purposes. */
-	const char *name;
-
-	/* Structural type of node. */
-	eDepsNode_Type type;
-
-	/* Type of data/behaviour represented by node... */
-	eDepsNode_Class tclass;
-
 	/* Relationships between nodes
 	 * The reason why all depsgraph nodes are descended from this type (apart
 	 * from basic serialization benefits - from the typeinfo) is that we can have
@@ -76,9 +63,12 @@ struct DepsNode {
 	 */
 	typedef vector<DepsRelation *> Relations;
 
+	/* Identifier - mainly for debugging purposes. */
+	const char *name;
+	/* Structural type of node. */
+	eDepsNode_Type type;
 	/* Nodes which this one depends on. */
 	Relations inlinks;
-
 	/* Nodes which depend on this one. */
 	Relations outlinks;
 
@@ -87,7 +77,6 @@ struct DepsNode {
 	int tag;
 
 	/* Methods. */
-
 	DepsNode();
 	virtual ~DepsNode();
 
@@ -101,6 +90,18 @@ struct DepsNode {
 
 	virtual OperationDepsNode *get_entry_operation() { return NULL; }
 	virtual OperationDepsNode *get_exit_operation() { return NULL; }
+
+	virtual eDepsNode_Class get_class() const {
+		if (type == DEG_NODE_TYPE_OPERATION) {
+			return DEG_NODE_CLASS_OPERATION;
+		}
+		else if (type < DEG_NODE_TYPE_PARAMETERS) {
+			return DEG_NODE_CLASS_GENERIC;
+		}
+		else {
+			return DEG_NODE_CLASS_COMPONENT;
+		}
+	}
 };
 
 /* Macros for common static typeinfo. */



More information about the Bf-blender-cvs mailing list