[Bf-blender-cvs] [d68f7c8e11d] blender2.8: Depsgraph: Make update flags debug print more useful

Sergey Sharybin noreply at git.blender.org
Mon Apr 23 12:54:00 CEST 2018


Commit: d68f7c8e11d9c26e6d02f9b0aaed3adef4db7140
Author: Sergey Sharybin
Date:   Mon Apr 23 12:52:53 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBd68f7c8e11d9c26e6d02f9b0aaed3adef4db7140

Depsgraph: Make update flags debug print more useful

Will print list of human-readable update flags, not the combined bitfield
printed as a number.

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

M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_tag.cc

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

diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index b30c99cbc0e..a158279a9d1 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -156,6 +156,9 @@ typedef enum eDepsgraph_Tag {
 	/* Only inform editors about the change. Don't modify datablock itself. */
 	DEG_TAG_EDITORS_UPDATE = (1 << 12),
 } eDepsgraph_Tag;
+
+const char *DEG_update_tag_as_string(eDepsgraph_Tag flag);
+
 void DEG_id_tag_update(struct ID *id, int flag);
 void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag);
 
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index bf5d594f97e..826194c09a3 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -473,10 +473,64 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph)
 	}
 }
 
+string stringify_append_bit(const string& str, eDepsgraph_Tag tag)
+{
+	string result = str;
+	if (!result.empty()) {
+		result += ", ";
+	}
+	result += DEG_update_tag_as_string(tag);
+	return result;
+}
+
+string stringify_update_bitfield(int flag)
+{
+	if (flag == 0) {
+		return "LEGACY_0";
+	}
+	string result = "";
+	int current_flag = flag;
+	/* Special cases to avoid ALL flags form being split into
+	 * individual bits.
+	 */
+	if ((current_flag & DEG_TAG_PSYS_ALL) == DEG_TAG_PSYS_ALL) {
+		result = stringify_append_bit(result, DEG_TAG_PSYS_ALL);
+	}
+	/* Handle all the rest of the flags. */
+	while (current_flag != 0) {
+		eDepsgraph_Tag tag =
+		        (eDepsgraph_Tag)(1 << bitscan_forward_clear_i(&current_flag));
+		result = stringify_append_bit(result, tag);
+	}
+	return result;
+}
+
 }  /* namespace */
 
 }  // namespace DEG
 
+const char *DEG_update_tag_as_string(eDepsgraph_Tag flag)
+{
+	switch (flag) {
+		case DEG_TAG_TRANSFORM: return "TRANSFORM";
+		case DEG_TAG_GEOMETRY: return "GEOMETRY";
+		case DEG_TAG_TIME: return "TIME";
+		case DEG_TAG_PSYS_REDO: return "PSYS_REDO";
+		case DEG_TAG_PSYS_RESET: return "PSYS_RESET";
+		case DEG_TAG_PSYS_TYPE: return "PSYS_TYPE";
+		case DEG_TAG_PSYS_CHILD: return "PSYS_CHILD";
+		case DEG_TAG_PSYS_PHYS: return "PSYS_PHYS";
+		case DEG_TAG_PSYS_ALL: return "PSYS_ALL";
+		case DEG_TAG_COPY_ON_WRITE: return "COPY_ON_WRITE";
+		case DEG_TAG_SHADING_UPDATE: return "SHADING_UPDATE";
+		case DEG_TAG_SELECT_UPDATE: return "SELECT_UPDATE";
+		case DEG_TAG_BASE_FLAGS_UPDATE: return "BASE_FLAGS_UPDATE";
+		case DEG_TAG_EDITORS_UPDATE: return "EDITORS_UPDATE";
+	}
+	BLI_assert(!"Unhandled update flag, should never happen!");
+	return "UNKNOWN";
+}
+
 /* Data-Based Tagging  */
 
 /* Tag given ID for an update in all the dependency graphs. */
@@ -492,7 +546,10 @@ void DEG_id_tag_update_ex(Main *bmain, ID *id, int flag)
 		return;
 	}
 	if (G.debug & G_DEBUG_DEPSGRAPH_TAG) {
-		printf("%s: id=%s flag=%d\n", __func__, id->name, flag);
+		printf("%s: id=%s flags=%s\n",
+		       __func__,
+		       id->name,
+		       DEG::stringify_update_bitfield(flag).c_str());
 	}
 	DEG::deg_id_tag_update(bmain, id, flag);
 }



More information about the Bf-blender-cvs mailing list