[Bf-blender-cvs] [fd9e1c2] depsgraph_refactor: Depsgraph: Add option to disable legacy depsgraph

Sergey Sharybin noreply at git.blender.org
Mon Dec 29 14:45:39 CET 2014


Commit: fd9e1c26f92a80836af73460aa087f7b941f17b1
Author: Sergey Sharybin
Date:   Mon Dec 29 18:12:28 2014 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBfd9e1c26f92a80836af73460aa087f7b941f17b1

Depsgraph: Add option to disable legacy depsgraph

This way it's becoming simplier to see missing parts from outside
of the depsgraph core in order to port all the things into the new
system.

Old dependency graph is enabled by default for all build systems.

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

M	CMakeLists.txt
M	build_files/scons/tools/btools.py
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/SConscript
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/depsgraph/intern/depsgraph_eval.cpp
M	source/blender/editors/transform/CMakeLists.txt
M	source/blender/editors/transform/SConscript
M	source/blender/editors/transform/transform_conversions.c

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3e78fc..9954939 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -434,6 +434,9 @@ if(MSVC)
 	set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
 endif()
 
+# Dependency graph
+option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
+
 # avoid using again
 option_defaults_clear()
 
diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py
index eb5036f..e8eb11e 100644
--- a/build_files/scons/tools/btools.py
+++ b/build_files/scons/tools/btools.py
@@ -198,7 +198,7 @@ def validate_arguments(args, bc):
             'C_WARN', 'CC_WARN', 'CXX_WARN',
             'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'XCODE_CUR_VER', 'C_COMPILER_ID',
             'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET',
-            'WITH_BF_CYCLES_DEBUG', 'WITH_BF_CYCLES_LOGGING'
+            'WITH_BF_CYCLES_DEBUG', 'WITH_BF_CYCLES_LOGGING', 'WITH_BF_LEGACY_DEPSGRAPH'
     ]
 
 
@@ -654,6 +654,8 @@ def read_opts(env, cfg, args):
         ('BF_LLVM_LIB_STATIC', 'LLVM static library', ''),
 
         ('BF_PROGRAM_LINKFLAGS', 'Link flags applied only to final binaries (blender and blenderplayer, not makesrna/makesdna)', '')
+
+        (BoolVariable('WITH_BF_LEGACY_DEPSGRAPH', 'Build Blender with legacy dependency graph', True)),
     ) # end of opts.AddOptions()
 
     return localopts
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 5c7276e..ae17900 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -466,4 +466,8 @@ endif()
 #	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
 #endif()
 
+if(WITH_LEGACY_DEPSGRAPH)
+	add_definitions(-DWITH_LEGACY_DEPSGRAPH)
+endif()
+
 blender_add_lib(bf_blenkernel "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index 0c3a444..2acac9f 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -175,6 +175,9 @@ if env['WITH_BF_BINRELOC']:
     incs += ' #extern/binreloc/include'
     defs.append('WITH_BINRELOC')
 
+if env['WITH_BF_LEGACY_DEPSGRAPH']:
+    defs.append('WITH_LEGACY_DEPSGRAPH')
+
 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
     env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25]) #, cc_compileflags = env['CCFLAGS'].append('/WX') )
 else:
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 2ca74a9..ea70fb1 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1808,9 +1808,12 @@ void BKE_pose_rebuild(Object *ob, bArmature *arm)
 
 	BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */
 
+#ifdef WITH_LEGACY_DEPSGRAPH
 	/* the sorting */
+	/* Sorting for new dependnecy graph is done on the scene graph level. */
 	if (counter > 1)
 		DAG_pose_sort(ob);
+#endif
 
 	ob->pose->flag &= ~POSE_RECALC;
 	ob->pose->flag |= POSE_WAS_REBUILT;
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 4e8e77c..afb2077 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -93,6 +93,8 @@
 #include "DEG_depsgraph_build.h"
 #include "DEG_depsgraph_debug.h"
 
+#ifdef WITH_LEGACY_DEPSGRAPH
+
 static SpinLock threaded_update_lock;
 
 void DAG_init(void)
@@ -3277,3 +3279,341 @@ bool DAG_is_acyclic(Scene *scene)
 {
 	return scene->theDag->is_acyclic;
 }
+
+#else
+
+void DAG_init(void)
+{
+#pragma message "need to be re-implemented actually"
+}
+
+void DAG_exit(void)
+{
+#pragma message "need to be re-implemented actually"
+}
+
+DagNodeQueue *queue_create(int UNUSED(slots))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void queue_raz(DagNodeQueue *UNUSED(queue))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void queue_delete(DagNodeQueue *UNUSED(queue))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void push_queue(DagNodeQueue *UNUSED(queue), DagNode *UNUSED(node))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void push_stack(DagNodeQueue *UNUSED(queue), DagNode *UNUSED(node))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+DagNode *pop_queue(DagNodeQueue *UNUSED(queue))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+	return NULL;
+}
+
+DagNode *get_top_node_queue(DagNodeQueue *UNUSED(queue))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+	return NULL;
+}
+
+DagForest *dag_init(void)
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+	return NULL;
+}
+
+DagForest *build_dag(Main *UNUSED(bmain),
+                     Scene *UNUSED(sce),
+                     short UNUSED(mask))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void free_forest(DagForest *UNUSED(Dag))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+DagNode *dag_find_node(DagForest *UNUSED(forest), void *UNUSED(fob))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+	return NULL;
+}
+
+DagNode *dag_add_node(DagForest *UNUSED(forest), void *UNUSED(fob))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+	return NULL;
+}
+
+DagNode *dag_get_node(DagForest *UNUSED(forest), void *UNUSED(fob))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+	return NULL;
+}
+
+DagNode *dag_get_sub_node(DagForest *UNUSED(forest), void *UNUSED(fob))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+	return NULL;
+}
+
+void dag_add_relation(DagForest *UNUSED(forest),
+                      DagNode *UNUSED(fob1),
+                      DagNode *UNUSED(fob2),
+                      short UNUSED(rel),
+                      const char *UNUSED(name))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+/* debug test functions */
+
+void graph_print_queue(DagNodeQueue *UNUSED(nqueue))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void graph_print_queue_dist(DagNodeQueue *UNUSED(nqueue))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void graph_print_adj_list(DagForest *UNUSED(dag))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+/* ************************ API *********************** */
+
+/* mechanism to allow editors to be informed of depsgraph updates,
+ * to do their own updates based on changes... */
+static void (*EditorsUpdateIDCb)(Main *bmain, ID *id) = NULL;
+static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated) = NULL;
+
+void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated))
+{
+#pragma message "need to be re-implemented actually"
+	EditorsUpdateIDCb = id_func;
+	EditorsUpdateSceneCb = scene_func;
+}
+
+/* Tag all relations for update. */
+void DAG_relations_tag_update(Main *bmain)
+{
+	Scene *scene;
+	for (scene = bmain->scene.first;
+	     scene != NULL;
+	     scene = scene->id.next)
+	{
+		if (scene->depsgraph != NULL) {
+			DEG_graph_tag_relations_update(scene->depsgraph);
+		}
+	}
+}
+
+/* Rebuild dependency graph only for a given scene. */
+void DAG_scene_relations_rebuild(Main *bmain, Scene *scene)
+{
+	DAG_scene_free(scene);
+	DAG_scene_relations_update(bmain, scene);
+}
+
+/* Create dependency graph if it was cleared or didn't exist yet. */
+void DAG_scene_relations_update(Main *bmain,
+                                Scene *scene)
+{
+	if (scene->depsgraph != NULL) {
+		DEG_scene_relations_update(bmain, scene);
+	}
+	else {
+		scene->depsgraph = DEG_graph_new();
+		DEG_graph_build_from_scene(scene->depsgraph, bmain, scene);
+	}
+}
+
+/* Tag specific ID node for rebuild, keep rest of the graph untouched. */
+void DAG_relations_tag_id_update(Main *bmain, ID *UNUSED(id))
+{
+	/* TODO(sergey): For now we tag the whole graph for rebuild,
+	 * once we'll have partial rebuilds implemented we'll use them.
+	 */
+	DAG_relations_tag_update(bmain);
+}
+
+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 *scene)
+{
+	if (scene->depsgraph) {
+		DEG_graph_free(scene->depsgraph);
+		scene->depsgraph = NULL;
+	}
+}
+
+void DAG_scene_flush_update(Main *UNUSED(bmain),
+                            Scene *UNUSED(sce),
+                            unsigned int UNUSED(lay),
+                            const short UNUSED(time))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void DAG_scene_update_flags(Main *UNUSED(bmain),
+                            Scene *UNUSED(scene),
+                            unsigned int UNUSED(lay),
+                            const bool UNUSED(do_time),
+                            const bool UNUSED(do_invisible_flush))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void DAG_on_visible_update(Main *bmain, const bool UNUSED(do_time))
+{
+#pragma message "do_time is not currently supported in the new depsgraph"
+	Scene *scene;
+	for (scene = bmain->scene.first; scene != NULL; scene = scene->id.next) {
+		if (scene->depsgraph != NULL) {
+			DEG_graph_on_visible_update(bmain, scene->depsgraph);
+		}
+	}
+}
+
+void DAG_ids_flush_tagged(Main *UNUSED(bmain))
+{
+	BLI_assert(!"Should not be used with new dependnecy graph");
+}
+
+void DAG_ids_check_recalc(Main *UNUSED(bmain),
+                          Scene *UNUSED(scene),
+                          bool UNUSED(time))
+{
+#pragma message "Need to be ported to new depsgraph"
+}
+
+void DAG_ids_clear_recalc(Main *UNUSED(bmain))
+{
+	BLI_assert(!"Should 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list