[Bf-blender-cvs] [c4046e9082f] master: Move ID recalc flags into dedicated field in ID

Sergey Sharybin noreply at git.blender.org
Fri Dec 15 10:29:15 CET 2017


Commit: c4046e9082f61bfef87173d20c566a065f2602d7
Author: Sergey Sharybin
Date:   Fri Dec 15 09:43:18 2017 +0100
Branches: master
https://developer.blender.org/rBc4046e9082f61bfef87173d20c566a065f2602d7

Move ID recalc flags into dedicated field in ID

Currently this is a no-visible-changes change, but the idea is to use this
dedicated flag to tell which exact components of ID changed, make it more
granular than just OBJECT and OBJECT_DATA. Allow setting this field based
on what components new dependency graph flushed on evaluation.

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

M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/mask.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/depsgraph/intern/builder/deg_builder.cc
M	source/blender/depsgraph/intern/depsgraph.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/eval/deg_eval_flush.cc
M	source/blender/makesdna/DNA_ID.h
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/modifiers/intern/MOD_correctivesmooth.c

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

diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 6107bb1e32e..ba8f454aa47 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -74,6 +74,8 @@
 
 #include "nla_private.h"
 
+#include "atomic_ops.h"
+
 /* ***************************************** */
 /* AnimData API */
 
@@ -1663,8 +1665,11 @@ static bool animsys_write_rna_setting(PathResolvedRNA *anim_rna, const float val
 
 		/* for cases like duplifarmes it's only a temporary so don't
 		 * notify anyone of updates */
-		if (!(id->tag & LIB_TAG_ANIM_NO_RECALC)) {
-			BKE_id_tag_set_atomic(id, LIB_TAG_ID_RECALC);
+		if (!(id->recalc & ID_RECALC_SKIP_ANIM_TAG)) {
+			/* NOTE: This is a bit annoying to use atomic API here, but this
+			 * code is at it's EOL and removed already in 2.8 branch.
+			 */
+			atomic_fetch_and_or_int32(&id->recalc, ID_RECALC);
 			DAG_id_type_tag(G.main, GS(id->name));
 		}
 	}
@@ -2618,8 +2623,8 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
 	 */
 	if (ptr->id.data != NULL) {
 		ID *id = ptr->id.data;
-		if (!(id->tag & LIB_TAG_ANIM_NO_RECALC)) {
-			id->tag |= LIB_TAG_ID_RECALC;
+		if (!(id->recalc & ID_RECALC_SKIP_ANIM_TAG)) {
+			id->recalc |= ID_RECALC;
 			DAG_id_type_tag(G.main, GS(id->name));
 		}
 	}
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index e9b83b27ef2..81e88bd3019 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -1532,7 +1532,7 @@ static bool check_object_tagged_for_update(Object *object)
 
 	if (ELEM(object->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) {
 		ID *data_id = object->data;
-		return (data_id->tag & LIB_TAG_ID_RECALC_ALL) != 0;
+		return (data_id->recalc & ID_RECALC_ALL) != 0;
 	}
 
 	return false;
@@ -1780,13 +1780,13 @@ void DAG_scene_free(Scene *sce)
 
 static void lib_id_recalc_tag(Main *bmain, ID *id)
 {
-	id->tag |= LIB_TAG_ID_RECALC;
+	id->recalc |= ID_RECALC;
 	DAG_id_type_tag(bmain, GS(id->name));
 }
 
 static void lib_id_recalc_data_tag(Main *bmain, ID *id)
 {
-	id->tag |= LIB_TAG_ID_RECALC_DATA;
+	id->recalc |= ID_RECALC_DATA;
 	DAG_id_type_tag(bmain, GS(id->name));
 }
 
@@ -2825,7 +2825,7 @@ void DAG_ids_flush_tagged(Main *bmain)
 
 		if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) {
 			for (; id; id = id->next) {
-				if (id->tag & LIB_TAG_ID_RECALC_ALL) {
+				if (id->recalc & ID_RECALC_ALL) {
 					for (dsl = listbase.first; dsl; dsl = dsl->next)
 						dag_id_flush_update(bmain, dsl->scene, id);
 					
@@ -2945,12 +2945,12 @@ void DAG_ids_clear_recalc(Main *bmain)
 
 		if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) {
 			for (; id; id = id->next) {
-				id->tag &= ~LIB_TAG_ID_RECALC_ALL;
+				id->recalc &= ~ID_RECALC_ALL;
 
 				/* some ID's contain semi-datablock nodetree */
 				ntree = ntreeFromID(id);
 				if (ntree)
-					ntree->id.tag &= ~LIB_TAG_ID_RECALC_ALL;
+					ntree->id.recalc &= ~ID_RECALC_ALL;
 			}
 		}
 	}
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index cd697cadc0e..ff4e7f36018 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1463,8 +1463,8 @@ void BKE_mask_update_scene(Main *bmain, Scene *scene)
 	Mask *mask;
 
 	for (mask = bmain->mask.first; mask; mask = mask->id.next) {
-		if (mask->id.tag & LIB_TAG_ID_RECALC_ALL) {
-			bool do_new_frame = (mask->id.tag & LIB_TAG_ID_RECALC_DATA) != 0;
+		if (mask->id.recalc & ID_RECALC_ALL) {
+			bool do_new_frame = (mask->id.recalc & ID_RECALC_DATA) != 0;
 			BKE_mask_evaluate_all_masks(bmain, CFRA, do_new_frame);
 		}
 	}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index b49e481b068..93bc79095d7 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -379,7 +379,7 @@ static void make_duplis_frames(const DupliContext *ctx)
 
 	/* special flag to avoid setting recalc flags to notify the depsgraph of
 	 * updates, as this is not a permanent change to the object */
-	ob->id.tag |= LIB_TAG_ANIM_NO_RECALC;
+	ob->id.recalc |= ID_RECALC_SKIP_ANIM_TAG;
 
 	for (scene->r.cfra = ob->dupsta; scene->r.cfra <= dupend; scene->r.cfra++) {
 		int ok = 1;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 9ce578a9105..e45d2887250 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1841,8 +1841,8 @@ static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene)
 	if (obedit) {
 		Mesh *mesh = obedit->data;
 		if ((obedit->type == OB_MESH) &&
-		    ((obedit->id.tag & LIB_TAG_ID_RECALC_ALL) ||
-		     (mesh->id.tag & LIB_TAG_ID_RECALC_ALL)))
+		    ((obedit->id.recalc & ID_RECALC_ALL) ||
+		     (mesh->id.recalc & ID_RECALC_ALL)))
 		{
 			if (check_rendered_viewport_visible(bmain)) {
 				BMesh *bm = mesh->edit_btmesh->bm;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b6543fc8662..f43eecffe60 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3077,7 +3077,7 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
 	ntree->adt = newdataadr(fd, ntree->adt);
 	direct_link_animdata(fd, ntree->adt);
 	
-	ntree->id.tag &= ~LIB_TAG_ID_RECALC_ALL;
+	ntree->id.recalc &= ~ID_RECALC_ALL;
 
 	link_list(fd, &ntree->nodes);
 	for (node = ntree->nodes.first; node; node = node->next) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index e3494e4756e..26f729a16d7 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -153,7 +153,7 @@ void deg_graph_build_finalize(Depsgraph *graph)
 
 		if ((id_node->layers & graph->layers) != 0 || graph->layers == 0) {
 			ID *id = id_node->id;
-			if ((id->tag & LIB_TAG_ID_RECALC_ALL) &&
+			if ((id->recalc & ID_RECALC_ALL) &&
 			    (id->tag & LIB_TAG_DOIT))
 			{
 				id_node->tag_update(graph);
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 7e9b2f5c58c..dd7284eb629 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -312,7 +312,7 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from,
 	if (comp_node->type == DEG_NODE_TYPE_GEOMETRY) {
 		IDDepsNode *id_to = to->owner->owner;
 		IDDepsNode *id_from = from->owner->owner;
-		if (id_to != id_from && (id_to->id->tag & LIB_TAG_ID_RECALC_ALL)) {
+		if (id_to != id_from && (id_to->id->recalc & ID_RECALC_ALL)) {
 			if ((id_from->eval_flags & DAG_EVAL_NEED_CPU) == 0) {
 				id_from->tag_update(this);
 				id_from->eval_flags |= DAG_EVAL_NEED_CPU;
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 8f91a826760..79c30e7904d 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -83,13 +83,13 @@ namespace {
 
 void lib_id_recalc_tag(Main *bmain, ID *id)
 {
-	id->tag |= LIB_TAG_ID_RECALC;
+	id->recalc |= ID_RECALC;
 	DEG_id_type_tag(bmain, GS(id->name));
 }
 
 void lib_id_recalc_data_tag(Main *bmain, ID *id)
 {
-	id->tag |= LIB_TAG_ID_RECALC_DATA;
+	id->recalc |= ID_RECALC_DATA;
 	DEG_id_type_tag(bmain, GS(id->name));
 }
 
@@ -295,7 +295,7 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene)
 		GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash)
 		{
 			ID *id = id_node->id;
-			if ((id->tag & LIB_TAG_ID_RECALC_ALL) != 0 ||
+			if ((id->recalc & ID_RECALC_ALL) != 0 ||
 			    (id_node->layers & scene->lay_updated) == 0)
 			{
 				id_node->tag_update(graph);
@@ -307,7 +307,7 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene)
 			 */
 			if (GS(id->name) == ID_OB) {
 				Object *object = (Object *)id;
-				if ((id->tag & LIB_TAG_ID_RECALC_ALL) == 0 &&
+				if ((id->recalc & ID_RECALC_ALL) == 0 &&
 				    (object->recalc & OB_RECALC_ALL) != 0)
 				{
 					id_node->tag_update(graph);
@@ -409,12 +409,12 @@ void DEG_ids_clear_recalc(Main *bmain)
 
 		if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) {
 			for (; id; id = (ID *)id->next) {
-				id->tag &= ~LIB_TAG_ID_RECALC_ALL;
+				id->recalc &= ~ID_RECALC_ALL;
 
 				/* Some ID's contain semi-datablock nodetree */
 				ntree = ntreeFromID(id);
 				if (ntree != NULL) {
-					ntree->id.tag &= ~LIB_TAG_ID_RECALC_ALL;
+					ntree->id.recalc &= ~ID_RECALC_ALL;
 				}
 			}
 		}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index dcd9a17761d..107bbda1030 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -65,13 +65,13 @@ namespace {
 // TODO(sergey): De-duplicate with depsgraph_tag,cc
 void lib_id_recalc_tag(Main *bmain, ID *id)
 {
-	id->tag |= LIB_TAG_ID_RECALC;
+	id->recalc |= ID_RECALC;
 	DEG_id_type_tag(bmain, GS(id->name));
 }
 
 void lib_id_recalc_data_tag(Main *bmain, ID *id)
 {
-	id->tag |= LIB_TAG_ID_RECALC_DATA;
+	id->recalc |= ID_RECALC_DATA;
 	DEG_id_type_tag(bmain, GS(id->name));
 }
 
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index f0fc651353f..c1c4d6c5376 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -348,18 +348,20 @@ enum {
 	/* RESET_AFTER_USE tag existing data before linking so we know what is new. */
 	LIB_TAG_PRE_EXISTING    = 1 << 11,
 
-	/* RESET_AFTER_USE, used by update code (depsgraph). */
-	LIB_TAG_ID_RECALC       = 1 << 12,
-	LIB_TAG_ID_RECALC_DATA  = 1 << 13,
-	LIB_TAG_ANIM_NO_RECALC  = 1 << 14,
-	LIB_TAG_ID_RECALC_ALL   = (LIB_TAG_ID_RECALC | LIB_TAG_ID_RECALC_DATA),
-
 	/* RESET_NEVER tag datablock for freeing etc. behavior (usually set when 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list