[Bf-blender-cvs] [ace9a31] compositor-2016: Depsgraph: Fix wrong layers flush form children to parent

Sergey Sharybin noreply at git.blender.org
Wed Jun 8 21:51:23 CEST 2016


Commit: ace9a3132e657c954443d1a500c01334463b335d
Author: Sergey Sharybin
Date:   Mon May 30 12:32:38 2016 +0200
Branches: compositor-2016
https://developer.blender.org/rBace9a3132e657c954443d1a500c01334463b335d

Depsgraph: Fix wrong layers flush form children to parent

It was possible to have issues in cases when several child dependencies
goes to IDs with different layers. In this case order of flushing was not
really well defined, which could lead to cases when indirect dependency
via invisible object wouldn't work.

Need some sort of barrier to prevent scheduling of parent nodes for until
all children are done, but that's becoming quite nasty thing to implement.

Added a temp field to component for now. maybe it's not so crazy actually
and we might use it for evaluation as well, so we wouldn't flush updates
to components which does not affect visible stuff.

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

M	intern/cycles/blender/blender_curves.cpp
M	source/blender/depsgraph/intern/builder/deg_builder.cc
M	source/blender/depsgraph/intern/nodes/deg_node_component.cc
M	source/blender/depsgraph/intern/nodes/deg_node_component.h

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

diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 8fbb241..a1e2617 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -657,6 +657,7 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
 						radius = 0.0f;
 
 					mP[i] = ickey_loc;
+					(void)radius;
 
 					/* unlike mesh coordinates, these tend to be slightly different
 					 * between frames due to particle transforms into/out of object
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index cf9b0ce..9f80c21 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -61,9 +61,10 @@ void deg_graph_build_finalize(Depsgraph *graph)
 	std::stack<OperationDepsNode *> stack;
 
 	foreach (OperationDepsNode *node, graph->operations) {
+		IDDepsNode *id_node = node->owner->owner;
 		node->done = 0;
 		node->num_links_pending = 0;
-		foreach (DepsRelation *rel, node->inlinks) {
+		foreach (DepsRelation *rel, node->outlinks) {
 			if ((rel->from->type == DEPSNODE_TYPE_OPERATION) &&
 			    (rel->flag & DEPSREL_FLAG_CYCLIC) == 0)
 			{
@@ -72,36 +73,33 @@ void deg_graph_build_finalize(Depsgraph *graph)
 		}
 		if (node->num_links_pending == 0) {
 			stack.push(node);
+			node->done = 1;
 		}
-		IDDepsNode *id_node = node->owner->owner;
+		node->owner->layers = id_node->layers;
 		id_node->id->tag |= LIB_TAG_DOIT;
 	}
 
 	while (!stack.empty()) {
 		OperationDepsNode *node = stack.top();
-		if (node->done == 0 && node->outlinks.size() != 0) {
-			foreach (DepsRelation *rel, node->outlinks) {
-				if (rel->to->type == DEPSNODE_TYPE_OPERATION) {
-					OperationDepsNode *to = (OperationDepsNode *)rel->to;
-					if ((rel->flag & DEPSREL_FLAG_CYCLIC) == 0) {
-						BLI_assert(to->num_links_pending > 0);
-						--to->num_links_pending;
-					}
-					if (to->num_links_pending == 0) {
-						stack.push(to);
-					}
-				}
+		stack.pop();
+		/* Flush layers to parents. */
+		foreach (DepsRelation *rel, node->inlinks) {
+			if (rel->from->type == DEPSNODE_TYPE_OPERATION) {
+				OperationDepsNode *from = (OperationDepsNode *)rel->from;
+				from->owner->layers |= node->owner->layers;
 			}
-			node->done = 1;
 		}
-		else {
-			stack.pop();
-			IDDepsNode *id_node = node->owner->owner;
-			foreach (DepsRelation *rel, node->outlinks) {
-				if (rel->to->type == DEPSNODE_TYPE_OPERATION) {
-					OperationDepsNode *to = (OperationDepsNode *)rel->to;
-					IDDepsNode *id_to = to->owner->owner;
-					id_node->layers |= id_to->layers;
+		/* Schedule parent nodes. */
+		foreach (DepsRelation *rel, node->inlinks) {
+			if (rel->from->type == DEPSNODE_TYPE_OPERATION) {
+				OperationDepsNode *from = (OperationDepsNode *)rel->from;
+				if ((rel->flag & DEPSREL_FLAG_CYCLIC) == 0) {
+					BLI_assert(from->num_links_pending > 0);
+					--from->num_links_pending;
+				}
+				if (from->num_links_pending == 0 && from->done == 0) {
+					stack.push(from);
+					from->done = 1;
 				}
 			}
 		}
@@ -110,6 +108,12 @@ void deg_graph_build_finalize(Depsgraph *graph)
 	/* Re-tag IDs for update if it was tagged before the relations update tag. */
 	GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash)
 	{
+		GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp, id_node->components)
+		{
+			id_node->layers |= comp->layers;
+		}
+		GHASH_FOREACH_END();
+
 		ID *id = id_node->id;
 		if (id->tag & LIB_TAG_ID_RECALC_ALL &&
 		    id->tag & LIB_TAG_DOIT)
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
index d18047c..c529e2e 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
@@ -86,7 +86,8 @@ static void comp_node_hash_value_free(void *value_v)
 ComponentDepsNode::ComponentDepsNode() :
     entry_operation(NULL),
     exit_operation(NULL),
-    flags(0)
+    flags(0),
+    layers(0)
 {
 	operations_map = BLI_ghash_new(comp_node_hash_key,
 	                               comp_node_hash_key_cmp,
@@ -119,7 +120,10 @@ string ComponentDepsNode::identifier() const
 	char typebuf[7];
 	sprintf(typebuf, "(%d)", type);
 
-	return string(typebuf) + name + " : " + idname;
+	char layers[7];
+	sprintf(layers, "%d", this->layers);
+
+	return string(typebuf) + name + " : " + idname + " (Layers: " + layers + ")";
 }
 
 OperationDepsNode *ComponentDepsNode::find_operation(OperationIDKey key) const
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index 17e6e7e..df321ea 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -166,6 +166,9 @@ struct ComponentDepsNode : public DepsNode {
 	// XXX: a poll() callback to check if component's first node can be started?
 
 	int flags;
+
+	/* Temporary bitmask, used during graph construction. */
+	int layers;
 };
 
 /* ---------------------------------------- */




More information about the Bf-blender-cvs mailing list