[Bf-blender-cvs] [00eeb05f4c0] blender2.8: Depsgraph: Make certain components NOT tag copy-on-write when they are tagged

Sergey Sharybin noreply at git.blender.org
Thu Jun 14 16:04:16 CEST 2018


Commit: 00eeb05f4c0bf233dfa80a5c7f9b154046521afc
Author: Sergey Sharybin
Date:   Thu Jun 14 15:33:41 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB00eeb05f4c0bf233dfa80a5c7f9b154046521afc

Depsgraph: Make certain components NOT tag copy-on-write when they are tagged

Currently done for mesh batch cache update, and for base flags sync.
Those components do not need anything from original object, and hence
can skip CoW tag and have faster update after them used.

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

M	source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/nodes/deg_node_component.h

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

diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index 72b86f698ef..df6e72f490f 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -271,6 +271,26 @@ static void deg_debug_graphviz_relation_style(const DebugContext &ctx,
 	deg_debug_fprintf(ctx, "%s", style);
 }
 
+static void deg_debug_graphviz_relation_arrowhead(const DebugContext &ctx,
+                                                  const DepsRelation *rel)
+{
+	const char *shape_default = "normal";
+	const char *shape_no_cow = "box";
+	const char *shape = shape_default;
+	if (rel->from->get_class() == DEG_NODE_CLASS_OPERATION &&
+	    rel->to->get_class() == DEG_NODE_CLASS_OPERATION)
+	{
+		OperationDepsNode *op_from = (OperationDepsNode *)rel->from;
+		OperationDepsNode *op_to = (OperationDepsNode *)rel->to;
+		if (op_from->owner->type == DEG_NODE_TYPE_COPY_ON_WRITE &&
+		    !op_to->owner->need_tag_cow_before_update())
+		{
+			shape = shape_no_cow;
+		}
+	}
+	deg_debug_fprintf(ctx, "%s", shape);
+}
+
 static void deg_debug_graphviz_node_style(const DebugContext &ctx, const DepsNode *node)
 {
 	const char *base_style = "filled"; /* default style */
@@ -485,6 +505,8 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx,
 		deg_debug_graphviz_relation_color(ctx, rel);
 		deg_debug_fprintf(ctx, ",style=");
 		deg_debug_graphviz_relation_style(ctx, rel);
+		deg_debug_fprintf(ctx, ",arrowhead=");
+		deg_debug_graphviz_relation_arrowhead(ctx, rel);
 		deg_debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
 		/* NOTE: edge from node to own cluster is not possible and gives graphviz
 		 * warning, avoid this here by just linking directly to the invisible
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 0c349ba5265..9128571155f 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -284,7 +284,7 @@ void depsgraph_tag_component(Depsgraph *graph,
 		}
 	}
 	/* If component depends on copy-on-write, tag it as well. */
-	if (component_node->depends_on_cow()) {
+	if (component_node->need_tag_cow_before_update()) {
 		ComponentDepsNode *cow_comp =
 		        id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
 		cow_comp->tag_update(graph);
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index 7338a99dfcb..5e79dc1c685 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -144,8 +144,12 @@ struct ComponentDepsNode : public DepsNode {
 	OperationDepsNode *entry_operation;
 	OperationDepsNode *exit_operation;
 
-	// XXX: a poll() callback to check if component's first node can be started?
 	virtual bool depends_on_cow() { return true; }
+
+	/* Denotes whether COW component is to be tagged when this component
+	 * is tagged for update.
+	 */
+	virtual bool need_tag_cow_before_update() { return true; }
 };
 
 /* ---------------------------------------- */
@@ -168,8 +172,14 @@ struct ComponentDepsNode : public DepsNode {
 		DEG_COMPONENT_NODE_DECLARE;                                \
 	}
 
+#define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name)      \
+	struct name ## ComponentDepsNode : public ComponentDepsNode {  \
+		DEG_COMPONENT_NODE_DECLARE;                                \
+		virtual bool need_tag_cow_before_update() { return false; }  \
+	}
+
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation);
-DEG_COMPONENT_NODE_DECLARE_GENERIC(BatchCache);
+DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Cache);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(CopyOnWrite);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Geometry);
@@ -182,7 +192,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Sequencer);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Shading);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
-DEG_COMPONENT_NODE_DECLARE_GENERIC(ObjectFromLayer);
+DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer);
 
 /* Bone Component */
 struct BoneComponentDepsNode : public ComponentDepsNode {



More information about the Bf-blender-cvs mailing list