[Bf-blender-cvs] [2da7977e3ef] master: Depsgraph: Implement backtrace functionality

Sergey Sharybin noreply at git.blender.org
Tue May 24 14:48:58 CEST 2022


Commit: 2da7977e3ef50049e0ebc4f0f668ce4ef2231a54
Author: Sergey Sharybin
Date:   Tue May 24 11:45:56 2022 +0200
Branches: master
https://developer.blender.org/rB2da7977e3ef50049e0ebc4f0f668ce4ef2231a54

Depsgraph: Implement backtrace functionality

The goal is to make it easier to track down sources of errors during
the dependency graph builder.

With this change whenever a relation can not be added a trace to the
entity which requested the relation will be printed. For example:

```
Failed to add relation "Copy Location"
Could not find op_from: OperationKey(type: BONE, component name: 'MissingBone', operation code: BONE_DONE)

Trace:

Depth    Type                     Name
-----    ----                     ----
1        Object                   Armature.001
2        Pose Channel             Bone
3        Constraint               Copy Location
```

On an implementation detail traced places where `checkIsBuiltAndTag`
is called, with some additional places to help tracking pose channels,
constraints, and modifiers.

Further improvements in granularity are possible, but that could happen
as a followup development once the core part is proven to work.

An example of such improvement would be to have entries in the trace
which will indicate NLA and drivers building. Currently it might be
a bit confusing to see IDs in the trace referenced from driver.

Even with such limitation the current state of the patch brings a
very valuable information (some information is much better than no
information at all).

Differential Revision: https://developer.blender.org/D15017

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

M	source/blender/depsgraph/CMakeLists.txt
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
A	source/blender/depsgraph/intern/builder/deg_builder_stack.cc
A	source/blender/depsgraph/intern/builder/deg_builder_stack.h

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

diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index a5693cb0fd7..3d539018cef 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -40,6 +40,7 @@ set(SRC
   intern/builder/deg_builder_relations_view_layer.cc
   intern/builder/deg_builder_remove_noop.cc
   intern/builder/deg_builder_rna.cc
+  intern/builder/deg_builder_stack.cc
   intern/builder/deg_builder_transitive.cc
   intern/builder/pipeline.cc
   intern/builder/pipeline_all_objects.cc
@@ -103,6 +104,7 @@ set(SRC
   intern/builder/deg_builder_relations_impl.h
   intern/builder/deg_builder_remove_noop.h
   intern/builder/deg_builder_rna.h
+  intern/builder/deg_builder_stack.h
   intern/builder/deg_builder_transitive.h
   intern/builder/pipeline.h
   intern/builder/pipeline_all_objects.h
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 3eeab23823c..0d4f9103149 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -586,11 +586,12 @@ void DepsgraphRelationBuilder::build_id(ID *id)
 
 void DepsgraphRelationBuilder::build_generic_id(ID *id)
 {
-
   if (built_map_.checkIsBuiltAndTag(id)) {
     return;
   }
 
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(*id);
+
   build_idproperties(id->properties);
   build_animdata(id);
   build_parameters(id);
@@ -621,6 +622,9 @@ void DepsgraphRelationBuilder::build_collection(LayerCollection *from_layer_coll
      * recurses into all the nested objects and collections. */
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(collection->id);
+
   const bool group_done = built_map_.checkIsBuiltAndTag(collection);
   OperationKey object_transform_final_key(object != nullptr ? &object->id : nullptr,
                                           NodeType::TRANSFORM,
@@ -684,6 +688,9 @@ void DepsgraphRelationBuilder::build_object(Object *object)
   if (built_map_.checkIsBuiltAndTag(object)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(object->id);
+
   /* Object Transforms */
   OperationCode base_op = (object->parent) ? OperationCode::TRANSFORM_PARENT :
                                              OperationCode::TRANSFORM_LOCAL;
@@ -1133,6 +1140,9 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
     if (cti == nullptr) {
       continue;
     }
+
+    const BuilderStack::ScopedEntry stack_entry = stack_.trace(*con);
+
     /* Special case for camera tracking -- it doesn't use targets to
      * define relations. */
     /* TODO: we can now represent dependencies in a much richer manner,
@@ -1500,6 +1510,9 @@ void DepsgraphRelationBuilder::build_action(bAction *action)
   if (built_map_.checkIsBuiltAndTag(action)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(action->id);
+
   build_idproperties(action->id.properties);
   if (!BLI_listbase_is_empty(&action->curves)) {
     TimeSourceKey time_src_key;
@@ -1787,6 +1800,9 @@ void DepsgraphRelationBuilder::build_world(World *world)
   if (built_map_.checkIsBuiltAndTag(world)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(world->id);
+
   build_idproperties(world->id.properties);
   /* animation */
   build_animdata(&world->id);
@@ -2012,6 +2028,9 @@ void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part)
   if (built_map_.checkIsBuiltAndTag(part)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(part->id);
+
   /* Animation data relations. */
   build_animdata(&part->id);
   build_parameters(&part->id);
@@ -2070,6 +2089,9 @@ void DepsgraphRelationBuilder::build_shapekeys(Key *key)
   if (built_map_.checkIsBuiltAndTag(key)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(key->id);
+
   build_idproperties(key->id.properties);
   /* Attach animdata to geometry. */
   build_animdata(&key->id);
@@ -2131,6 +2153,8 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
     LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
       const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
       if (mti->updateDepsgraph) {
+        const BuilderStack::ScopedEntry stack_entry = stack_.trace(*md);
+
         DepsNodeHandle handle = create_node_handle(obdata_ubereval_key);
         ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
         mti->updateDepsgraph(md, &ctx);
@@ -2251,6 +2275,9 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
   if (built_map_.checkIsBuiltAndTag(obdata)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(*obdata);
+
   build_idproperties(obdata->properties);
   /* Animation. */
   build_animdata(obdata);
@@ -2369,6 +2396,9 @@ void DepsgraphRelationBuilder::build_armature(bArmature *armature)
   if (built_map_.checkIsBuiltAndTag(armature)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(armature->id);
+
   build_idproperties(armature->id.properties);
   build_animdata(&armature->id);
   build_parameters(&armature->id);
@@ -2388,6 +2418,9 @@ void DepsgraphRelationBuilder::build_camera(Camera *camera)
   if (built_map_.checkIsBuiltAndTag(camera)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(camera->id);
+
   build_idproperties(camera->id.properties);
   build_animdata(&camera->id);
   build_parameters(&camera->id);
@@ -2405,6 +2438,9 @@ void DepsgraphRelationBuilder::build_light(Light *lamp)
   if (built_map_.checkIsBuiltAndTag(lamp)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(lamp->id);
+
   build_idproperties(lamp->id.properties);
   build_animdata(&lamp->id);
   build_parameters(&lamp->id);
@@ -2469,6 +2505,9 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
   if (built_map_.checkIsBuiltAndTag(ntree)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(ntree->id);
+
   build_idproperties(ntree->id.properties);
   build_animdata(&ntree->id);
   build_parameters(&ntree->id);
@@ -2574,6 +2613,9 @@ void DepsgraphRelationBuilder::build_material(Material *material)
   if (built_map_.checkIsBuiltAndTag(material)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(material->id);
+
   build_idproperties(material->id.properties);
   /* animation */
   build_animdata(&material->id);
@@ -2610,6 +2652,9 @@ void DepsgraphRelationBuilder::build_texture(Tex *texture)
   if (built_map_.checkIsBuiltAndTag(texture)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(texture->id);
+
   /* texture itself */
   ComponentKey texture_key(&texture->id, NodeType::GENERIC_DATABLOCK);
   build_idproperties(texture->id.properties);
@@ -2651,6 +2696,9 @@ void DepsgraphRelationBuilder::build_image(Image *image)
   if (built_map_.checkIsBuiltAndTag(image)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(image->id);
+
   build_idproperties(image->id.properties);
   build_parameters(&image->id);
 }
@@ -2660,6 +2708,9 @@ void DepsgraphRelationBuilder::build_cachefile(CacheFile *cache_file)
   if (built_map_.checkIsBuiltAndTag(cache_file)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(cache_file->id);
+
   build_idproperties(cache_file->id.properties);
   /* Animation. */
   build_animdata(&cache_file->id);
@@ -2689,6 +2740,9 @@ void DepsgraphRelationBuilder::build_mask(Mask *mask)
   if (built_map_.checkIsBuiltAndTag(mask)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(mask->id);
+
   ID *mask_id = &mask->id;
   build_idproperties(mask_id->properties);
   /* F-Curve animation. */
@@ -2727,6 +2781,8 @@ void DepsgraphRelationBuilder::build_freestyle_linestyle(FreestyleLineStyle *lin
     return;
   }
 
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(linestyle->id);
+
   ID *linestyle_id = &linestyle->id;
   build_parameters(linestyle_id);
   build_idproperties(linestyle_id->properties);
@@ -2739,6 +2795,9 @@ void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip)
   if (built_map_.checkIsBuiltAndTag(clip)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(clip->id);
+
   /* Animation. */
   build_idproperties(clip->id.properties);
   build_animdata(&clip->id);
@@ -2750,6 +2809,9 @@ void DepsgraphRelationBuilder::build_lightprobe(LightProbe *probe)
   if (built_map_.checkIsBuiltAndTag(probe)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(probe->id);
+
   build_idproperties(probe->id.properties);
   build_animdata(&probe->id);
   build_parameters(&probe->id);
@@ -2760,6 +2822,9 @@ void DepsgraphRelationBuilder::build_speaker(Speaker *speaker)
   if (built_map_.checkIsBuiltAndTag(speaker)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(speaker->id);
+
   build_idproperties(speaker->id.properties);
   build_animdata(&speaker->id);
   build_parameters(&speaker->id);
@@ -2776,6 +2841,9 @@ void DepsgraphRelationBuilder::build_sound(bSound *sound)
   if (built_map_.checkIsBuiltAndTag(sound)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(sound->id);
+
   build_idproperties(sound->id.properties);
   build_animdata(&sound->id);
   build_parameters(&sound->id);
@@ -2786,6 +2854,9 @@ void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
   if (built_map_.checkIsBuiltAndTag(simulation)) {
     return;
   }
+
+  const BuilderStack::ScopedEntry stack_entry = stack_.trace(simulation->id);
+
   build_idproperties(simulation->id.properties);
   build_animdata(&simulation->id);
   build_parameters(&simulation->id);
@@ -2850,6 +2921,9 @@ void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
   if (built_map_.checkIsBuiltAndTag(scene, BuilderMap::TAG_S

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list