From bb75c4cbe9f54b643106a999a077d64b20f6d97a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 2 May 2018 11:52:49 +0200 Subject: Depsgraph: Make all print messages to respect per-depsgraph debug flags --- .../blender/depsgraph/intern/builder/deg_builder_relations.cc | 6 ++++-- .../depsgraph/intern/builder/deg_builder_relations_rig.cc | 5 +++-- .../depsgraph/intern/builder/deg_builder_transitive.cc | 2 +- source/blender/depsgraph/intern/depsgraph_build.cc | 3 ++- source/blender/depsgraph/intern/depsgraph_intern.h | 11 ++++++++++- source/blender/depsgraph/intern/eval/deg_eval_flush.cc | 3 ++- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index c862b0e7af4..8eb4d502410 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -251,7 +251,8 @@ DepsRelation *DepsgraphRelationBuilder::add_time_relation( return graph_->add_new_relation(timesrc, node_to, description, check_unique); } else { - DEG_DEBUG_PRINTF(BUILD, "add_time_relation(%p = %s, %p = %s, %s) Failed\n", + DEG_DEBUG_PRINTF((::Depsgraph *)graph_, + BUILD, "add_time_relation(%p = %s, %p = %s, %s) Failed\n", timesrc, (timesrc) ? timesrc->identifier().c_str() : "", node_to, (node_to) ? node_to->identifier().c_str() : "", description); @@ -272,7 +273,8 @@ DepsRelation *DepsgraphRelationBuilder::add_operation_relation( check_unique); } else { - DEG_DEBUG_PRINTF(BUILD, "add_operation_relation(%p = %s, %p = %s, %s) Failed\n", + DEG_DEBUG_PRINTF((::Depsgraph *)graph_, + BUILD, "add_operation_relation(%p = %s, %p = %s, %s) Failed\n", node_from, (node_from) ? node_from->identifier().c_str() : "", node_to, (node_to) ? node_to->identifier().c_str() : "", description); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc index c80e0d568f3..126aa85edd3 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -176,7 +176,8 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object, } } - DEG_DEBUG_PRINTF(BUILD, "\nStarting IK Build: pchan = %s, target = (%s, %s), segcount = %d\n", + DEG_DEBUG_PRINTF((::Depsgraph *)graph_, + BUILD, "\nStarting IK Build: pchan = %s, target = (%s, %s), segcount = %d\n", pchan->name, data->tar->id.name, data->subtarget, data->rootbone); bPoseChannel *parchan = pchan; @@ -219,7 +220,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object, root_map->add_bone(parchan->name, rootchan->name); /* continue up chain, until we reach target number of items... */ - DEG_DEBUG_PRINTF(BUILD, " %d = %s\n", segcount, parchan->name); + DEG_DEBUG_PRINTF((::Depsgraph *)graph_, BUILD, " %d = %s\n", segcount, parchan->name); segcount++; if ((segcount == data->rootbone) || (segcount > 255)) break; /* 255 is weak */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc index 12760cad73c..17e64c5f685 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc @@ -117,7 +117,7 @@ void deg_graph_transitive_reduction(Depsgraph *graph) } } } - DEG_DEBUG_PRINTF(BUILD, "Removed %d relations\n", num_removed_relations); + DEG_DEBUG_PRINTF((::Depsgraph *)graph, BUILD, "Removed %d relations\n", num_removed_relations); } } // namespace DEG diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index 0a958fa67d3..a827e428fdf 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -276,6 +276,7 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph, /* Tag graph relations for update. */ void DEG_graph_tag_relations_update(Depsgraph *graph) { + DEG_DEBUG_PRINTF(graph, TAG, "%s: Tagging relations for update.\n", __func__); DEG::Depsgraph *deg_graph = reinterpret_cast(graph); deg_graph->need_update = true; /* NOTE: When relations are updated, it's quite possible that @@ -310,7 +311,7 @@ void DEG_graph_relations_update(Depsgraph *graph, /* Tag all relations for update. */ void DEG_relations_tag_update(Main *bmain) { - DEG_DEBUG_PRINTF(TAG, "%s: Tagging relations for update.\n", __func__); + DEG_GLOBAL_DEBUG_PRINTF(TAG, "%s: Tagging relations for update.\n", __func__); LISTBASE_FOREACH (Scene *, scene, &bmain->scene) { LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { Depsgraph *depsgraph = diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h index 9961723ed17..dda482efc8d 100644 --- a/source/blender/depsgraph/intern/depsgraph_intern.h +++ b/source/blender/depsgraph/intern/depsgraph_intern.h @@ -46,6 +46,8 @@ extern "C" { #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph.h" +#include "DEG_depsgraph_debug.h" + struct DEGEditorUpdateContext; struct Group; struct Main; @@ -112,7 +114,14 @@ void deg_editors_id_update(const DEGEditorUpdateContext *update_ctx, void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, bool updated); -#define DEG_DEBUG_PRINTF(type, ...) \ +#define DEG_DEBUG_PRINTF(depsgraph, type, ...) \ + do { \ + if (DEG_get_debug_flags(depsgraph) & G_DEBUG_DEPSGRAPH_ ## type) { \ + fprintf(stderr, __VA_ARGS__); \ + } \ + } while (0) + +#define DEG_GLOBAL_DEBUG_PRINTF(type, ...) \ do { \ if (G.debug & G_DEBUG_DEPSGRAPH_ ## type) { \ fprintf(stderr, __VA_ARGS__); \ diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 2778dadcb6e..02f10130fed 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -239,7 +239,8 @@ void flush_editors_id_update(Main *bmain, id_cow->recalc |= factory->id_recalc_tag(); } GHASH_FOREACH_END(); - DEG_DEBUG_PRINTF(EVAL, "Accumulated recalc bits for %s: %u\n", + DEG_DEBUG_PRINTF((::Depsgraph *)graph, + EVAL, "Accumulated recalc bits for %s: %u\n", id_orig->name, (unsigned int)id_cow->recalc); /* Inform editors. */ if (deg_copy_on_write_is_expanded(id_cow)) { -- cgit v1.2.3