[Bf-blender-cvs] [e57a61c] depsgraph_refactor: Depsgraph: Add check for whether graph was properly tagged for rebuild
Sergey Sharybin
noreply at git.blender.org
Thu Dec 4 12:16:25 CET 2014
Commit: e57a61ce51837c12042109efacb4941062413ab5
Author: Sergey Sharybin
Date: Thu Dec 4 16:13:32 2014 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBe57a61ce51837c12042109efacb4941062413ab5
Depsgraph: Add check for whether graph was properly tagged for rebuild
Currently it's more like a preliminary check to catch obvious errors based on
comparing number of operations in current depsgraph and correct one. Ideally
relations and nodes themselves should be checked deeper,but that's NP-complex
problem which probably doesn't worth solving for now.
This check is commented out by default, uncomment it in BKE_scene_update_tagged
if needed.
===================================================================
M source/blender/blenkernel/BKE_depsgraph.h
M source/blender/blenkernel/intern/depsgraph.c
M source/blender/blenkernel/intern/scene.c
M source/blender/depsgraph/DEG_depsgraph_debug.h
M source/blender/depsgraph/intern/depsgraph_debug.cpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h
index 27cf19d..ebe00b0 100644
--- a/source/blender/blenkernel/BKE_depsgraph.h
+++ b/source/blender/blenkernel/BKE_depsgraph.h
@@ -92,6 +92,7 @@ void DAG_exit(void);
*/
void DAG_scene_relations_update(struct Main *bmain, struct Scene *sce);
+void DAG_scene_relations_validate(struct Main *bmain, struct Scene *sce);
void DAG_relations_tag_update(struct Main *bmain);
void DAG_scene_relations_rebuild(struct Main *bmain, struct Scene *scene);
void DAG_scene_free(struct Scene *sce);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index a938c2e..67029e8 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -91,6 +91,7 @@
#pragma message("DEPSGRAPH PORTING XXX: only needed to hijack existing tagging functions until new depsgraph API is stabilized")
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_debug.h"
static SpinLock threaded_update_lock;
@@ -1655,6 +1656,17 @@ void DAG_scene_relations_update(Main *bmain, Scene *sce)
dag_scene_build(bmain, sce);
}
+void DAG_scene_relations_validate(Main *bmain, Scene *sce)
+{
+ Depsgraph *depsgraph = DEG_graph_new();
+ DEG_graph_build_from_scene(depsgraph, bmain, sce);
+ if (!DEG_debug_compare(depsgraph, sce->depsgraph)) {
+ fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n");
+ BLI_assert(!"This should not happen!");
+ }
+ DEG_graph_free(depsgraph);
+}
+
void DAG_scene_free(Scene *sce)
{
if (sce->theDag) {
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 090133a..585395c 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1663,8 +1663,15 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
/* (re-)build dependency graph if needed */
- for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set)
+ for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set) {
DAG_scene_relations_update(bmain, sce_iter);
+ /* Uncomment this to check if graph was properly tagged for update. */
+#if 0
+ if (use_new_eval) {
+ DAG_scene_relations_validate(bmain, sce_iter);
+ }
+#endif
+ }
/* flush editing data if needed */
prepare_mesh_for_viewport_render(bmain, scene);
diff --git a/source/blender/depsgraph/DEG_depsgraph_debug.h b/source/blender/depsgraph/DEG_depsgraph_debug.h
index 33efe77..a9ed909 100644
--- a/source/blender/depsgraph/DEG_depsgraph_debug.h
+++ b/source/blender/depsgraph/DEG_depsgraph_debug.h
@@ -83,6 +83,9 @@ void DEG_debug_graphviz(const struct Depsgraph *graph, FILE *stream, const char
/* ************************************************ */
+bool DEG_debug_compare(const struct Depsgraph *graph1,
+ const struct Depsgraph *graph2);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index aedae9a..0a2c208 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -894,3 +894,21 @@ DepsgraphStatsID *DEG_stats_id(ID *id)
return DepsgraphDebug::get_id_stats(id, false);
}
+
+bool DEG_debug_compare(const struct Depsgraph *graph1,
+ const struct Depsgraph *graph2)
+{
+ BLI_assert(graph1 != NULL);
+ BLI_assert(graph2 != NULL);
+ if (graph1->operations.size() != graph2->operations.size()) {
+ return false;
+ }
+ /* TODO(sergey): Currently we only do real stupid check,
+ * which is fast but which isn't 100% reliable.
+ *
+ * Would be cool to make it more robust, but it's good enough
+ * for now. Also, proper graph check is actually NP-complex
+ * problem..
+ */
+ return true;
+}
More information about the Bf-blender-cvs
mailing list