[Bf-blender-cvs] [749d5c033c6] blender2.8: Depsgraph: Make visible update to operate on per-component level

Sergey Sharybin noreply at git.blender.org
Wed Sep 19 16:10:30 CEST 2018


Commit: 749d5c033c62a0cb082f7c9dbbe3e742f043d83e
Author: Sergey Sharybin
Date:   Wed Sep 19 15:46:03 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB749d5c033c62a0cb082f7c9dbbe3e742f043d83e

Depsgraph: Make visible update to operate on per-component level

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

M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/nodes/deg_node_id.cc
M	source/blender/depsgraph/intern/nodes/deg_node_id.h

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index da47465dd47..07b819a4d72 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -163,16 +163,18 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
 {
 	IDDepsNode *id_node = NULL;
 	ID *id_cow = NULL;
-	bool is_previous_directly_visible = false;
+	IDComponentsMask previously_visible_components_mask = 0;
 	IDInfo *id_info = (IDInfo *)BLI_ghash_lookup(id_info_hash_, id);
 	if (id_info != NULL) {
 		id_cow = id_info->id_cow;
-		is_previous_directly_visible = id_info->is_directly_visible;
+		previously_visible_components_mask =
+		        id_info->previously_visible_components_mask;
 		/* Tag ID info to not free the CoW ID pointer. */
 		id_info->id_cow = NULL;
 	}
 	id_node = graph_->add_id_node(id, id_cow);
-	id_node->is_previous_directly_visible = is_previous_directly_visible;
+	id_node->previously_visible_components_mask =
+	        previously_visible_components_mask;
 	/* Currently all ID nodes are supposed to have copy-on-write logic.
 	 *
 	 * NOTE: Zero number of components indicates that ID node was just created.
@@ -352,7 +354,8 @@ void DepsgraphNodeBuilder::begin_build()
 		else {
 			id_info->id_cow = NULL;
 		}
-		id_info->is_directly_visible = id_node->is_directly_visible;
+		id_info->previously_visible_components_mask =
+		        id_node->visible_components_mask;
 		BLI_ghash_insert(id_info_hash_, id_node->id_orig, id_info);
 		id_node->id_cow = NULL;
 	}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 37000c958ce..74709f2b57f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -35,6 +35,8 @@
 
 #include "DEG_depsgraph.h"
 
+#include "intern/nodes/deg_node_id.h"
+
 struct Base;
 struct bArmature;
 struct bAction;
@@ -225,10 +227,10 @@ struct DepsgraphNodeBuilder {
 	struct IDInfo {
 		/* Copy-on-written pointer of the corresponding ID. */
 		ID *id_cow;
-		/* State of the is_visible from ID node from previous state of the
+		/* Mask of visible components from previous state of the
 		 * dependency graph.
 		 */
-		bool is_directly_visible;
+		IDComponentsMask previously_visible_components_mask;
 	};
 
 protected:
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 4d4e0e8be15..4609cc9051a 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -485,17 +485,16 @@ void deg_id_tag_update(Main *bmain, ID *id, int flag)
 
 void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph)
 {
-	/* TODO(sergey): We might want to tag components which did not affect
-	 * anything visible before new objects became visible.
-	 */
 	foreach (DEG::IDDepsNode *id_node, graph->id_nodes) {
-		if (!id_node->is_directly_visible) {
-			/* ID is not visible within the current dependency graph, no need
-			 * botherwith it to tag or anything.
+		if (!id_node->visible_components_mask) {
+			/* ID cas no components which affects anything visible. no meed
+			 * bother with it to tag or anything.
 			 */
 			continue;
 		}
-		if (id_node->is_previous_directly_visible) {
+		if (id_node->visible_components_mask ==
+		    id_node->previously_visible_components_mask)
+		{
 			/* The ID was already visible and evaluated, all the subsequent
 			 * updates and tags are to be done explicitly.
 			 */
@@ -530,7 +529,8 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph)
 		 * tags we request from here will be applied in the updated state of
 		 * dependency graph.
 		 */
-		id_node->is_previous_directly_visible = true;
+		id_node->previously_visible_components_mask =
+		        id_node->visible_components_mask;
 	}
 }
 
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_id.cc b/source/blender/depsgraph/intern/nodes/deg_node_id.cc
index 7589be8c0a8..caf7c8da3c1 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_id.cc
@@ -105,7 +105,9 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
 	eval_flags = 0;
 	linked_state = DEG_ID_LINKED_INDIRECTLY;
 	is_directly_visible = true;
-	is_previous_directly_visible = false;
+
+	visible_components_mask = 0;
+	previously_visible_components_mask = 0;
 
 	components = BLI_ghash_new(id_deps_node_hash_key,
 	                           id_deps_node_hash_key_cmp,
@@ -218,6 +220,21 @@ void IDDepsNode::finalize_build(Depsgraph *graph)
 		comp_node->finalize_build(graph);
 	}
 	GHASH_FOREACH_END();
+	visible_components_mask = get_visible_components_mask();
+}
+
+IDComponentsMask IDDepsNode::get_visible_components_mask() const {
+	IDComponentsMask result = 0;
+	GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, components)
+	{
+		if (comp_node->affects_directly_visible) {
+			const int component_type = comp_node->type;
+			BLI_assert(component_type < 64);
+			result |= (1 << component_type);
+		}
+	}
+	GHASH_FOREACH_END();
+	return result;
 }
 
 }  // namespace DEG
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_id.h b/source/blender/depsgraph/intern/nodes/deg_node_id.h
index 187b5067c5b..359410d0be0 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_id.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_id.h
@@ -31,11 +31,14 @@
 #pragma once
 
 #include "intern/nodes/deg_node.h"
+#include "BLI_sys_types.h"
 
 namespace DEG {
 
 struct ComponentDepsNode;
 
+typedef uint64_t IDComponentsMask;
+
 /* ID-Block Reference */
 struct IDDepsNode : public DepsNode {
 	struct ComponentIDKey {
@@ -62,6 +65,8 @@ struct IDDepsNode : public DepsNode {
 
 	void finalize_build(Depsgraph *graph);
 
+	IDComponentsMask get_visible_components_mask() const;
+
 	/* ID Block referenced. */
 	ID *id_orig;
 	ID *id_cow;
@@ -79,13 +84,9 @@ struct IDDepsNode : public DepsNode {
 
 	/* Indicates the datablock is visible in the evaluated scene. */
 	bool is_directly_visible;
-	/* Is used to detect when ID becomes visible within a dependency graph,
-	 * this value equals to:
-	 *   - False if the ID was never inside of the dependency graph.
-	 *   - Value if is_visible of ID node from the previous state of the
-	 *     dependency graph.
-	 */
-	bool is_previous_directly_visible;
+
+	IDComponentsMask visible_components_mask;
+	IDComponentsMask previously_visible_components_mask;
 
 	DEG_DEPSNODE_DECLARE;
 };



More information about the Bf-blender-cvs mailing list