[Bf-blender-cvs] [bac7353] master: Depsgraph: New dependency graph integration commit

Sergey Sharybin noreply at git.blender.org
Tue May 12 13:07:03 CEST 2015


Commit: bac735380189c63d2b8824cba8e0398bb35e9af2
Author: Sergey Sharybin
Date:   Tue May 12 15:05:57 2015 +0500
Branches: master
https://developer.blender.org/rBbac735380189c63d2b8824cba8e0398bb35e9af2

Depsgraph: New dependency graph integration commit

This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:

- More granular dependency relation nature, which solves issues with fake cycles
  in the dependencies.

- Move towards all-animatable, by better integration of drivers into the system.

- Lay down some basis for upcoming copy-on-write, overrides and so on.

The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.

It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.

There are number of assorted documents related on the design of the new system:

* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph

There are also some user-related information online:

* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/

Kudos to everyone who was involved into the project:

- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
  project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
  issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)

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

M	CMakeLists.txt
M	build_files/cmake/macros.cmake
M	build_files/scons/tools/Blender.py
M	build_files/scons/tools/btools.py
M	source/blender/CMakeLists.txt
M	source/blender/SConscript
M	source/blender/blenkernel/BKE_depsgraph.h
M	source/blender/blenkernel/BKE_modifier.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/SConscript
M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/armature_update.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/mesh.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
A	source/blender/depsgraph/CMakeLists.txt
A	source/blender/depsgraph/DEG_depsgraph.h
A	source/blender/depsgraph/DEG_depsgraph_build.h
A	source/blender/depsgraph/DEG_depsgraph_debug.h
A	source/blender/depsgraph/DEG_depsgraph_query.h
A	source/blender/depsgraph/SConscript
A	source/blender/depsgraph/intern/depsgraph.cc
A	source/blender/depsgraph/intern/depsgraph.h
A	source/blender/depsgraph/intern/depsgraph_build.cc
A	source/blender/depsgraph/intern/depsgraph_build.h
A	source/blender/depsgraph/intern/depsgraph_build_nodes.cc
A	source/blender/depsgraph/intern/depsgraph_build_relations.cc
A	source/blender/depsgraph/intern/depsgraph_debug.cc
A	source/blender/depsgraph/intern/depsgraph_debug.h
A	source/blender/depsgraph/intern/depsgraph_eval.cc
A	source/blender/depsgraph/intern/depsgraph_intern.h
A	source/blender/depsgraph/intern/depsgraph_query.cc
A	source/blender/depsgraph/intern/depsgraph_queue.cc
A	source/blender/depsgraph/intern/depsgraph_queue.h
A	source/blender/depsgraph/intern/depsgraph_tag.cc
A	source/blender/depsgraph/intern/depsgraph_type_defines.cc
A	source/blender/depsgraph/intern/depsgraph_types.h
A	source/blender/depsgraph/intern/depsnode.cc
A	source/blender/depsgraph/intern/depsnode.h
A	source/blender/depsgraph/intern/depsnode_component.cc
A	source/blender/depsgraph/intern/depsnode_component.h
A	source/blender/depsgraph/intern/depsnode_opcodes.h
A	source/blender/depsgraph/intern/depsnode_operation.cc
A	source/blender/depsgraph/intern/depsnode_operation.h
A	source/blender/depsgraph/util/depsgraph_util_cycle.cc
A	source/blender/depsgraph/util/depsgraph_util_cycle.h
A	source/blender/depsgraph/util/depsgraph_util_function.h
A	source/blender/depsgraph/util/depsgraph_util_hash.h
A	source/blender/depsgraph/util/depsgraph_util_map.h
A	source/blender/depsgraph/util/depsgraph_util_pchanmap.cc
A	source/blender/depsgraph/util/depsgraph_util_pchanmap.h
A	source/blender/depsgraph/util/depsgraph_util_set.h
A	source/blender/depsgraph/util/depsgraph_util_transitive.cc
A	source/blender/depsgraph/util/depsgraph_util_transitive.h
M	source/blender/editors/space_view3d/CMakeLists.txt
M	source/blender/editors/space_view3d/SConscript
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/transform/CMakeLists.txt
M	source/blender/editors/transform/SConscript
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/SConscript
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/SConscript
M	source/blender/makesrna/intern/makesrna.c
A	source/blender/makesrna/intern/rna_depsgraph.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_object_api.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/SConscript
M	source/blender/modifiers/intern/MOD_armature.c
M	source/blender/modifiers/intern/MOD_array.c
M	source/blender/modifiers/intern/MOD_bevel.c
M	source/blender/modifiers/intern/MOD_boolean.c
M	source/blender/modifiers/intern/MOD_build.c
M	source/blender/modifiers/intern/MOD_cast.c
M	source/blender/modifiers/intern/MOD_cloth.c
M	source/blender/modifiers/intern/MOD_collision.c
M	source/blender/modifiers/intern/MOD_correctivesmooth.c
M	source/blender/modifiers/intern/MOD_curve.c
M	source/blender/modifiers/intern/MOD_datatransfer.c
M	source/blender/modifiers/intern/MOD_decimate.c
M	source/blender/modifiers/intern/MOD_displace.c
M	source/blender/modifiers/intern/MOD_dynamicpaint.c
M	source/blender/modifiers/intern/MOD_edgesplit.c
M	source/blender/modifiers/intern/MOD_explode.c
M	source/blender/modifiers/intern/MOD_fluidsim.c
M	source/blender/modifiers/intern/MOD_hook.c
M	source/blender/modifiers/intern/MOD_laplaciandeform.c
M	source/blender/modifiers/intern/MOD_laplaciansmooth.c
M	source/blender/modifiers/intern/MOD_lattice.c
M	source/blender/modifiers/intern/MOD_mask.c
M	source/blender/modifiers/intern/MOD_meshcache.c
M	source/blender/modifiers/intern/MOD_meshdeform.c
M	source/blender/modifiers/intern/MOD_mirror.c
M	source/blender/modifiers/intern/MOD_multires.c
M	source/blender/modifiers/intern/MOD_none.c
M	source/blender/modifiers/intern/MOD_normal_edit.c
M	source/blender/modifiers/intern/MOD_ocean.c
M	source/blender/modifiers/intern/MOD_particleinstance.c
M	source/blender/modifiers/intern/MOD_particlesystem.c
M	source/blender/modifiers/intern/MOD_remesh.c
M	source/blender/modifiers/intern/MOD_screw.c
M	source/blender/modifiers/intern/MOD_shapekey.c
M	source/blender/modifiers/intern/MOD_shrinkwrap.c
M	source/blender/modifiers/intern/MOD_simpledeform.c
M	source/blender/modifiers/intern/MOD_skin.c
M	source/blender/modifiers/intern/MOD_smoke.c
M	source/blender/modifiers/intern/MOD_smooth.c
M	source/blender/modifiers/intern/MOD_softbody.c
M	source/blender/modifiers/intern/MOD_solidify.c
M	source/blender/modifiers/intern/MOD_subsurf.c
M	source/blender/modifiers/intern/MOD_surface.c
M	source/blender/modifiers/intern/MOD_triangulate.c
M	source/blender/modifiers/intern/MOD_util.h
M	source/blender/modifiers/intern/MOD_uvproject.c
M	source/blender/modifiers/intern/MOD_uvwarp.c
M	source/blender/modifiers/intern/MOD_warp.c
M	source/blender/modifiers/intern/MOD_wave.c
M	source/blender/modifiers/intern/MOD_weightvgedit.c
M	source/blender/modifiers/intern/MOD_weightvgmix.c
M	source/blender/modifiers/intern/MOD_weightvgproximity.c
M	source/blender/modifiers/intern/MOD_wireframe.c
M	source/blender/render/CMakeLists.txt
M	source/blender/render/SConscript
M	source/blender/render/intern/source/pipeline.c
M	source/blenderplayer/CMakeLists.txt
M	source/creator/CMakeLists.txt
M	source/creator/creator.c

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae2c67b..a8b32b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -449,6 +449,9 @@ endif()
 option(WITH_CPP11 "Build with C++11 standard enabled, for development use only!" OFF)
 mark_as_advanced(WITH_CPP11)
 
+# Dependency graph
+option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
+
 # avoid using again
 option_defaults_clear()
 
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 8b2f3f1..7de2b25 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -524,6 +524,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
 		bf_blenloader
 		bf_imbuf
 		bf_blenlib
+		bf_depsgraph
 		bf_intern_ghost
 		bf_intern_string
 		bf_avi
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index 6e7417c..ecf3475 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -372,7 +372,7 @@ def propose_priorities():
 def creator(env):
     sources = ['creator.c']# + Blender.buildinfo(env, "dynamic") + Blender.resources
 
-    incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', env['BF_OPENGL_INC']]
+    incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/depsgraph', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', env['BF_OPENGL_INC']]
 
     defs = []
 
diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py
index c5342d6..76450fb 100644
--- a/build_files/scons/tools/btools.py
+++ b/build_files/scons/tools/btools.py
@@ -199,7 +199,7 @@ def validate_arguments(args, bc):
             '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_CPP11'
+            'WITH_BF_CPP11', 'WITH_BF_LEGACY_DEPSGRAPH',
     ]
 
 
@@ -657,6 +657,8 @@ def read_opts(env, cfg, args):
         ('BF_PROGRAM_LINKFLAGS', 'Link flags applied only to final binaries (blender and blenderplayer, not makesrna/makesdna)', ''),
 
         (BoolVariable('WITH_BF_CPP11', '"Build with C++11 standard enabled, for development use only!', False)),
+
+        (BoolVariable('WITH_BF_LEGACY_DEPSGRAPH', 'Build Blender with legacy dependency graph', True)),
     ) # end of opts.AddOptions()
 
     return localopts
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index d87d5df..9a73921 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -102,6 +102,7 @@ add_subdirectory(bmesh)
 add_subdirectory(render)
 add_subdirectory(blenfont)
 add_subdirectory(blenloader)
+add_subdirectory(depsgraph)
 add_subdirectory(ikplugin)
 add_subdirectory(physics)
 add_subdirectory(gpu)
diff --git a/source/blender/SConscript b/source/blender/SConscript
index 64eca6a..e987b6b 100644
--- a/source/blender/SConscript
+++ b/source/blender/SConscript
@@ -33,6 +33,7 @@ SConscript(['avi/SConscript',
             'blenkernel/SConscript',
             'blenlib/SConscript',
             'blenloader/SConscript',
+            'depsgraph/SConscript',
             'gpu/SConscript',
             'editors/SConscript',
             'imbuf/SConscript',
diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h
index f3a483f..862f91f 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/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 9c5261c..cc53f94 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -43,6 +43,7 @@ struct bArmature;
 struct Main;
 struct ModifierData;
 struct BMEditMesh;
+struct DepsNodeHandle;
 
 typedef enum {
 	/* Should not be used, only for None modifier type */
@@ -260,6 +261,17 @@ typedef struct ModifierTypeInfo {
 	                       struct Main *bmain, struct Scene *scene,
 	                       struct Object *ob, struct DagNode *obNode);
 
+	/* Add the appropriate relations to the dependency graph.
+	 *
+	 * This function is optional.
+	 */
+	/* TODO(sergey): Remove once we finalyl switched to the new depsgraph. */
+	void (*updateDepsgraph)(struct ModifierData *md,
+	                        struct Main *bmain,
+	                        struct Scene *scene,
+	                        struct Object *ob,
+	                        struct DepsNodeHandle *node);
+
 	/* Should return true if the modifier needs to be recalculated on time
 	 * changes.
 	 *
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index fe713e6..37e5b36 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
 	../blenfont
 	../blenlib
 	../blenloader
+	../depsgraph
 	../gpu
 	../ikplugin
 	../imbuf
@@ -482,4 +483,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 47bba5f..9d19e1c 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -58,6 +58,7 @@ incs = [
     '../blenlib',
     '../blenloader',
     '../bmesh',
+    '../depsgraph',
     '../gpu',
     '../ikplugin',
     '../imbuf',
@@ -175,6 +176,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/action.c b/source/blender/blenkernel/intern/action.c
index 708c64f..7e09ad3 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -54,6 +54,7 @@
 #include "BKE_animsys.h"
 #include "BKE_constraint.h"
 #include "BKE_deform.h"
+#include "BKE_depsgraph.h"
 #include "BKE_fcurve.h"
 #include "BKE_global.h"
 #include "BKE_idprop.h"
@@ -1318,9 +1319,13 @@ bool BKE_pose_copy_result(bPose *to, bPose *from)
 }
 
 /* Tag pose for recalc. Also tag all related data to be recalc. */
-void BKE_pose_tag_recalc(Main *UNUSED(bmain), bPose *pose)
+void BKE_pose_tag_recalc(Main *bmain, bPose *pose)
 {
 	pose->flag |= POSE_RECALC;
+	/* Depsgraph components depends on actual pose state,
+	 * if pose was changed depsgraph is to be updated as well.
+	 */
+	DAG_relations_tag_update(bmain);
 }
 
 /* For the calculation of the effects of an Action at the given frame on an object 
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 44ffb6a..aa36036 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -51,6 +51,8 @@
 #include "BKE_global.h"
 #include "BKE_main.h"
 
+#include "DEG_depsgraph.h"
+
 #ifdef WITH_LEGACY_DEPSGRAPH
 #  define DEBUG_PRINT if (!DEG_depsgraph_use_legacy() && G.debug & G_DEBUG_DEPSGRAPH) printf
 #else
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 869404a..9ee9f3d 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -88,16 +88,25 @@
 
 #include "depsgraph_private.h"
 
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_debug.h"
+#include "DEG_depsgraph_query.h"
+
+#ifdef WITH_LEGACY_DEPSGRAPH
+
 static SpinLock threaded_update_lock;
 
 void DAG_init(void)
 {
 	BLI_spin_init(&threaded_update_lock);
+	DEG_register_node_types();
 }
 
 void DAG_exit(void)
 {
 	BLI_spin_end(&threaded_update_lock);
+	DEG_free_node_types();
 }
 
 /* Queue and stack operations for dag traversal 
@@ -1329,8 +1338,14 @@ static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated) = NU
 
 void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated))
 {
-	EditorsUpdateIDCb = id_func;
-	EditorsUpdateSceneCb = scene_func;
+	if (DEG_depsgraph_use_legacy()) {
+		EditorsUpdateIDCb = id_func;
+		EditorsUpdateSceneCb = scene_func;
+	}
+	else {
+		/* New dependency graph. */
+		DEG_editors_set_update_cb(id_func, scene_func);
+	}
 }
 
 static void dag_editors_id_update(Main *bmain, ID *id)
@@ -1529,7 +1544,7 @@ static void dag_scene_build(Main *bmain, Scene *sce)
 	Base *base;
 
 	BLI_listbase_clear(&tempbase);
-	
+
 	build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA);
 	
 	dag_check_cycle(sce->theDag);
@@ -1621,32 +1636,65 @@ static void dag_scene_build(Main *bmain, Scene *sce)
 /* clear all dependency grap

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list