[Bf-blender-cvs] [4045a51a116] blender2.8: Depsgraph: Rework tagging and flushing routines

Sergey Sharybin noreply at git.blender.org
Tue Dec 19 11:49:31 CET 2017


Commit: 4045a51a116156c2a6465577eef65d36c5c5c4e8
Author: Sergey Sharybin
Date:   Tue Dec 19 11:24:34 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB4045a51a116156c2a6465577eef65d36c5c5c4e8

Depsgraph: Rework tagging and flushing routines

The goal is: have id->recalc flags set to components which got changed.
To make it possible for render engines to check on a more granular basis
what changed in the object. For example, is it a transform which changed
or is it just some ID property changed which has nothing to do with rendering.

The tricky part is: we don't want duplicated logic in tagging and flushing.
In order to avoid this duplication, we store ID recalc flag in the component
node type information. That type information could easily be accessed by both
tagging and flushing routines.

Remaining part of the changes are related on changing the way how tagging
works. The new idea here is to have utility function which maps update tag to
a component. This way we can easily set ID recalc flags right away. Without
any duplication of ID recalc flags set in multiple flag handler functions.

With all this being said, there should be no user measurable difference for
now, it's a gigantic basement for some upcoming work and fixes.

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

M	source/blender/depsgraph/intern/depsgraph_intern.h
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/eval/deg_eval_flush.cc

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

diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h
index ba984f1c13b..5db138ecda8 100644
--- a/source/blender/depsgraph/intern/depsgraph_intern.h
+++ b/source/blender/depsgraph/intern/depsgraph_intern.h
@@ -115,10 +115,6 @@ void deg_editors_id_update(const DEGEditorUpdateContext *update_ctx,
 void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx,
                               bool updated);
 
-/* Tagging helpers ------------------------------------------------------ */
-
-void lib_id_recalc_tag(struct Main *bmain, struct ID *id);
-
 #define DEG_DEBUG_PRINTF(...)               \
 	do {                                    \
 		if (G.debug & G_DEBUG_DEPSGRAPH) {  \
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 750d300f688..aa75176db12 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -35,8 +35,9 @@
 #include <queue>
 
 #include "BLI_utildefines.h"
-#include "BLI_task.h"
 #include "BLI_listbase.h"
+#include "BLI_math_bits.h"
+#include "BLI_task.h"
 
 extern "C" {
 #include "DNA_object_types.h"
@@ -68,227 +69,57 @@ extern "C" {
 #include "intern/depsgraph_intern.h"
 #include "util/deg_util_foreach.h"
 
-/* Define this in order to have more strict sanitization of what tagging flags
- * are used for ID databnlocks. Ideally, we would always want this, but there
- * are cases in generic modules (like IR remapping) where we don't want to spent
- * lots of time trying to guess which components are to be updated.
- */
-// #define STRICT_COMPONENT_TAGGING
-
 /* *********************** */
 /* Update Tagging/Flushing */
 
 namespace DEG {
 
-/* Data-Based Tagging ------------------------------- */
-
-void lib_id_recalc_tag(Main *bmain, ID *id)
-{
-	id->recalc |= ID_RECALC;
-	DEG_id_type_tag(bmain, GS(id->name));
-}
-
 namespace {
 
 void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag);
 
-void lib_id_recalc_tag_flag(Main *bmain, ID *id, int flag)
+void depsgraph_geometry_tag_to_component(const ID *id,
+                                         eDepsNode_Type *component_type)
 {
-	/* This bit of code ensures legacy object->recalc flags are still filled in
-	 * the same way as it was expected with the old dependency graph.
-	 *
-	 * This is because some areas like motion paths and likely some other
-	 * physics baking process are doing manual scene update on all the frames,
-	 * trying to minimize number of updates.
-	 *
-	 * But this flag will also let us to re-construct entry nodes for update
-	 * after relations update and after layer visibility changes.
-	 */
-	if (flag) {
-		if (flag & OB_RECALC_OB) {
-			lib_id_recalc_tag(bmain, id);
-		}
-		if (flag & (OB_RECALC_DATA)) {
-			if (GS(id->name) == ID_OB) {
-				Object *object = (Object *)id;
-				ID *object_data = (ID *)object->data;
-				if (object_data != NULL) {
-					lib_id_recalc_tag(bmain, object_data);
-				}
-			}
-			else {
-				// BLI_assert(!"Tagging non-object as object data update");
-				lib_id_recalc_tag(bmain, id);
-			}
-		}
-		if (flag & PSYS_RECALC) {
-			lib_id_recalc_tag(bmain, id);
-		}
-	}
-	else {
-		lib_id_recalc_tag(bmain, id);
-	}
-}
-
-/* Special tagging  */
-void id_tag_update_special_zero_flag(Depsgraph *graph, IDDepsNode *id_node)
-{
-	/* NOTE: Full ID node update for now, need to minimize that in the future. */
-	id_node->tag_update(graph);
-}
-
-/* Tag corresponding to OB_RECALC_OB. */
-void id_tag_update_object_transform(Depsgraph *graph, IDDepsNode *id_node)
-{
-	ComponentDepsNode *transform_comp =
-	        id_node->find_component(DEG_NODE_TYPE_TRANSFORM);
-	if (transform_comp == NULL) {
-#ifdef STRICT_COMPONENT_TAGGING
-		DEG_ERROR_PRINTF("ERROR: Unable to find transform component for %s\n",
-		                 id_node->id_orig->name);
-		BLI_assert(!"This is not supposed to happen!");
-#endif
-		return;
-	}
-	transform_comp->tag_update(graph);
-}
-
-/* Tag corresponding to OB_RECALC_DATA. */
-void id_tag_update_object_data(Depsgraph *graph, IDDepsNode *id_node)
-{
-	const ID_Type id_type = GS(id_node->id_orig->name);
-	ComponentDepsNode *data_comp = NULL;
+	const ID_Type id_type = GS(id->name);
 	switch (id_type) {
 		case ID_OB:
 		{
-			const Object *object = (Object *)id_node->id_orig;
+			const Object *object = (Object *)id;
 			switch (object->type) {
 				case OB_MESH:
 				case OB_CURVE:
 				case OB_SURF:
 				case OB_FONT:
 				case OB_MBALL:
-					data_comp = id_node->find_component(DEG_NODE_TYPE_GEOMETRY);
+					*component_type = DEG_NODE_TYPE_GEOMETRY;
 					break;
 				case OB_ARMATURE:
-					data_comp = id_node->find_component(DEG_NODE_TYPE_EVAL_POSE);
+					*component_type = DEG_NODE_TYPE_EVAL_POSE;
 					break;
-				/* TODO(sergey): More cases here? */
+					/* TODO(sergey): More cases here? */
 			}
 			break;
 		}
 		case ID_ME:
-			data_comp = id_node->find_component(DEG_NODE_TYPE_GEOMETRY);
+			*component_type = DEG_NODE_TYPE_GEOMETRY;
 			break;
 		case ID_PA:
 			return;
 		case ID_LP:
-			data_comp = id_node->find_component(DEG_NODE_TYPE_PARAMETERS);
+			*component_type = DEG_NODE_TYPE_PARAMETERS;
 			break;
 		default:
 			break;
 	}
-	if (data_comp == NULL) {
-#ifdef STRICT_COMPONENT_TAGGING
-		DEG_ERROR_PRINTF("ERROR: Unable to find data component for %s\n",
-		                 id_node->id_orig->name);
-		BLI_assert(!"This is not supposed to happen!");
-#endif
-		return;
-	}
-	data_comp->tag_update(graph);
-	/* Special legacy compatibility code, tag data ID for update when object
-	 * is tagged for data update.
-	 */
-	if (id_type == ID_OB) {
-		Object *object = (Object *)id_node->id_orig;
-		ID *data_id = (ID *)object->data;
-		if (data_id != NULL) {
-			IDDepsNode *data_id_node = graph->find_id_node(data_id);
-			// BLI_assert(data_id_node != NULL);
-			/* TODO(sergey): Do we want more granular tags here? */
-			/* TODO(sergey): Hrm, during some operations it's possible to have
-			 * object node existing but not it's data. For example, when making
-			 * objects local. This is valid situation, but how can we distinguish
-			 * that from someone trying to do stupid things with dependency
-			 * graph?
-			 */
-			if (data_id_node != NULL) {
-				data_id_node->tag_update(graph);
-			}
-		}
-	}
-}
-
-/* Tag corresponding to OB_RECALC_TIME. */
-void id_tag_update_object_time(Depsgraph *graph, IDDepsNode *id_node)
-{
-	ComponentDepsNode *animation_comp =
-	        id_node->find_component(DEG_NODE_TYPE_ANIMATION);
-	if (animation_comp == NULL) {
-		/* It's not necessarily we've got animation component in cases when
-		 * we are tagging for time updates.
-		 */
-		return;
-	}
-	animation_comp->tag_update(graph);
-	/* TODO(sergey): More components to tag here? */
-}
-
-void id_tag_update_particle(Depsgraph *graph, IDDepsNode *id_node, int tag)
-{
-	ComponentDepsNode *particle_comp =
-	        id_node->find_component(DEG_NODE_TYPE_PARAMETERS);
-	ParticleSettings *particle_settings = (ParticleSettings *)id_node->id_orig;
-	particle_settings->recalc |= (tag & PSYS_RECALC);
-	if (particle_comp == NULL) {
-#ifdef STRICT_COMPONENT_TAGGING
-		DEG_ERROR_PRINTF("ERROR: Unable to find particle component for %s\n",
-		                 id_node->id_orig->name);
-		BLI_assert(!"This is not supposed to happen!");
-#endif
-		return;
-	}
-	particle_comp->tag_update(graph);
 }
 
-void id_tag_update_shading(Depsgraph *graph, IDDepsNode *id_node)
+void depsgraph_select_tag_to_component_opcode(
+        const ID *id,
+        eDepsNode_Type *component_type,
+        eDepsOperation_Code *operation_code)
 {
-	ComponentDepsNode *shading_comp;
-	if (GS(id_node->id_orig->name) == ID_NT) {
-		shading_comp = id_node->find_component(DEG_NODE_TYPE_SHADING_PARAMETERS);
-	}
-	else {
-		shading_comp = id_node->find_component(DEG_NODE_TYPE_SHADING);
-	}
-	if (shading_comp == NULL) {
-#ifdef STRICT_COMPONENT_TAGGING
-		DEG_ERROR_PRINTF("ERROR: Unable to find shading component for %s\n",
-		                 id_node->id_orig->name);
-		BLI_assert(!"This is not supposed to happen!");
-#endif
-		return;
-	}
-	shading_comp->tag_update(graph);
-}
-
-/* Tag corresponding to DEG_TAG_COPY_ON_WRITE. */
-void id_tag_update_copy_on_write(Depsgraph *graph, IDDepsNode *id_node)
-{
-	if (!DEG_depsgraph_use_copy_on_write()) {
-		return;
-	}
-	ComponentDepsNode *cow_comp =
-	        id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
-	OperationDepsNode *cow_node = cow_comp->get_entry_operation();
-	cow_node->tag_update(graph);
-}
-
-void id_tag_update_select_update(Depsgraph *graph, IDDepsNode *id_node)
-{
-	ComponentDepsNode *component;
-	OperationDepsNode *node = NULL;
-	const ID_Type id_type = GS(id_node->id_orig->name);
+	const ID_Type id_type = GS(id->name);
 	if (id_type == ID_SCE) {
 		/* We need to flush base flags to all objects in a scene since we
 		 * don't know which ones changed. However, we don't want to update
@@ -299,62 +130,107 @@ void id_tag_update_select_update(Depsgraph *graph, IDDepsNode *id_node)
 		 * does nothing and which is only used to cascade flush down the
 		 * road.
 		 */
-		component = id_node->find_component(DEG_NODE_TYPE_LAYER_COLLECTIONS);
-		BLI_assert(component != NULL);
-		if (component != NULL) {
-			node = component->find_operation(DEG_OPCODE_VIEW_LAYER_DONE);
-		}
+		*component_type = DEG_NODE_TYPE_LAYER_COLLECTIONS;
+		*operation_code = DEG_OPCODE_VIEW_LAYER_DONE;
 	}
 	else if (id_type == ID_OB) {
-		component = id_node->find_component(DEG_NODE_TYPE_LAYER_COLLECTIONS);
-		/* NOTE: This component might be missing for indirectly linked
-		 * objects.
-		 */
-		if (component != NULL) {
-			node = component->find_operation(DEG_OPCODE_OBJECT_BASE_FLAGS);
-		}
+		*component_type = DEG_NODE_TYPE_LAYER_COLLECTIONS;
+		*operation_code = DEG_OPCODE_OBJECT_BASE_FLAGS;
 	}
 	else {
-		component = id_node->find_component(DEG_NODE_TYPE_BATCH_CACHE);
-		BLI_assert(component != NULL);
-		if (component != NULL) {
-			node = component->find_operation(DEG_OPCODE_GEOMETRY_SELECT_UPDATE,
-			                                 "", -1);
-		}
-	}
-	if (node != NULL) {
-		node->tag_update(graph);
+		*component_type = DEG_NODE_TYPE_BAT

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list