diff --git a/source/blender/depsgraph/DEG_depsgraph_debug.hh b/source/blender/depsgraph/DEG_depsgraph_debug.hh index 90b6691f0dc..44691537b97 100644 --- a/source/blender/depsgraph/DEG_depsgraph_debug.hh +++ b/source/blender/depsgraph/DEG_depsgraph_debug.hh @@ -11,6 +11,7 @@ #pragma once #include +#include #include "BLI_string_ref.hh" @@ -65,3 +66,13 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph, /** Perform consistency check on the graph. */ bool DEG_debug_consistency_check(Depsgraph *graph); + +/** Convert bitflag representation of recalculation flags to string that consists of human-readable + * names of recalculation bits that are set in the given mask. + * + * If flags == 0 the result is "NONE". + * + * Example: + * DEG_stringify_recalc_flags(ID_RECALC_GEOMETRY | ID_RECALC_SHADING) -> "GEOMETRY, SHADING". + */ +std::string DEG_stringify_recalc_flags(unsigned int flags); diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index 6161e7bef93..c410cdadd88 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -24,6 +24,8 @@ #include "intern/node/deg_node_id.hh" #include "intern/node/deg_node_time.hh" +#include "BLI_math_bits.h" + namespace deg = blender::deg; void DEG_debug_flags_set(Depsgraph *depsgraph, int flags) @@ -357,3 +359,36 @@ void DEG_debug_print_eval_time(Depsgraph *depsgraph, time); fflush(stdout); } + +static std::string stringify_append_bit(const std::string &str, IDRecalcFlag tag) +{ + const char *tag_name = DEG_update_tag_as_string(tag); + if (tag_name == nullptr) { + return str; + } + std::string result = str; + if (!result.empty()) { + result += ", "; + } + result += tag_name; + return result; +} + +std::string DEG_stringify_recalc_flags(uint flags) +{ + if (flags == 0) { + return "NONE"; + } + std::string result; + uint current_flag = flags; + /* Special cases to avoid ALL flags from being split into individual bits. */ + if ((current_flag & ID_RECALC_PSYS_ALL) == ID_RECALC_PSYS_ALL) { + result = stringify_append_bit(result, ID_RECALC_PSYS_ALL); + } + /* Handle all the rest of the flags. */ + while (current_flag != 0) { + IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_uint(¤t_flag)); + result = stringify_append_bit(result, tag); + } + return result; +} diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 14253cb6671..e80c038e301 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -401,38 +401,12 @@ void graph_id_tag_update_single_flag(Main *bmain, deg_graph_id_tag_legacy_compat(bmain, graph, id, tag, update_source); } -std::string stringify_append_bit(const std::string &str, IDRecalcFlag tag) -{ - const char *tag_name = DEG_update_tag_as_string(tag); - if (tag_name == nullptr) { - return str; - } - std::string result = str; - if (!result.empty()) { - result += ", "; - } - result += tag_name; - return result; -} - std::string stringify_update_bitfield(uint flags) { if (flags == 0) { return "LEGACY_0"; } - std::string result; - uint current_flag = flags; - /* Special cases to avoid ALL flags form being split into - * individual bits. */ - if ((current_flag & ID_RECALC_PSYS_ALL) == ID_RECALC_PSYS_ALL) { - result = stringify_append_bit(result, ID_RECALC_PSYS_ALL); - } - /* Handle all the rest of the flags. */ - while (current_flag != 0) { - IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_uint(¤t_flag)); - result = stringify_append_bit(result, tag); - } - return result; + return DEG_stringify_recalc_flags(flags); } const char *update_source_as_string(eUpdateSource source)