[Bf-blender-cvs] [c9aef27326d] blender2.8: Depsgraph: Begin work on making depsgraph per-scene-layer

Sergey Sharybin noreply at git.blender.org
Thu Jul 13 15:54:57 CEST 2017


Commit: c9aef27326d54ed053edb37d27fe5571805139b9
Author: Sergey Sharybin
Date:   Thu Jul 13 15:43:36 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBc9aef27326d54ed053edb37d27fe5571805139b9

Depsgraph: Begin work on making depsgraph per-scene-layer

This is a first step towards proper depsgraph "ownership", where
we would allow scene to be in multiple states dependent on active
workspace or scene layer.

This commit introduces a basic API to get proper dependency graph
for a given scene layer. It also renames scene->depsgraph to
depsgraph_legacy, so it's easier to search0-n-replace in the future.

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

M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/context.c
M	source/blender/blenkernel/intern/displist.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_debug.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/modifiers/intern/MOD_subsurf.c
M	source/blender/python/intern/gpu_offscreen.c
M	source/blender/render/intern/source/pipeline.c

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

diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 5047070012c..6ca79d8c7cd 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -39,12 +39,14 @@ extern "C" {
 
 struct AviCodecData;
 struct BaseLegacy;
+struct Depsgraph;
 struct EvaluationContext;
 struct Main;
 struct Object;
 struct Base;
 struct QuicktimeCodecData;
 struct RenderData;
+struct SceneLayer;
 struct SceneRenderLayer;
 struct Scene;
 struct SceneCollection;
@@ -184,6 +186,9 @@ void        BKE_scene_multiview_view_prefix_get(struct Scene *scene, const char
 void        BKE_scene_multiview_videos_dimensions_get(const struct RenderData *rd, const size_t width, const size_t height, size_t *r_width, size_t *r_height);
 int         BKE_scene_multiview_num_videos_get(const struct RenderData *rd);
 
+/* depsgraph */
+struct Depsgraph* BKE_scene_get_depsgraph(struct Scene *scene, struct SceneLayer *scene_layer);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index aea2ad0cd9e..49a219691bc 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2605,7 +2605,8 @@ static bool calc_modifiers_skip_orco(Scene *scene,
 		else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
 			return false;
 		}
-		else if ((DEG_get_eval_flags_for_id(scene->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
+		/* TODO(sergey): How do we get depsgraph here? */
+		else if ((DEG_get_eval_flags_for_id(scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
 			return false;
 		}
 		SubsurfModifierData *smd = (SubsurfModifierData *)last_md;
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 0ad853b016a..ffccc59171c 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -52,6 +52,7 @@
 #include "BKE_context.h"
 #include "BKE_layer.h"
 #include "BKE_main.h"
+#include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_sound.h"
 #include "BKE_workspace.h"
@@ -1225,5 +1226,6 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
 Depsgraph *CTX_data_depsgraph(const bContext *C)
 {
 	Scene *scene = CTX_data_scene(C);
-	return scene->depsgraph;
+	SceneLayer *scene_layer = CTX_data_scene_layer(C);
+	return BKE_scene_get_depsgraph(scene, scene_layer);
 }
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 44f284d043e..25f50056c42 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1740,8 +1740,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
 		}
 
 		if (!for_orco) {
+			/* TODO(sergey): How do we get depsgraph here? */
 			if ((cu->flag & CU_PATH) ||
-			    DEG_get_eval_flags_for_id(scene->depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
+			    DEG_get_eval_flags_for_id(scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
 			{
 				calc_curvepath(ob, &nubase);
 			}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 3b2287a7921..7b103a3c56e 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -255,7 +255,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
 
 		scen->ed = NULL;
 		scen->theDag = NULL;
-		scen->depsgraph = NULL;
+		scen->depsgraph_legacy = NULL;
 		scen->obedit = NULL;
 		scen->fps_info = NULL;
 
@@ -583,8 +583,8 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
 	}
 	
 	DEG_scene_graph_free(sce);
-	if (sce->depsgraph)
-		DEG_graph_free(sce->depsgraph);
+	if (sce->depsgraph_legacy)
+		DEG_graph_free(sce->depsgraph_legacy);
 
 	MEM_SAFE_FREE(sce->fps_info);
 
@@ -1542,7 +1542,7 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
 	 *
 	 * in the future this should handle updates for all datablocks, not
 	 * only objects and scenes. - brecht */
-	DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph, scene);
+	DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph_legacy, scene);
 	/* TODO(sergey): This is to beocme a node in new depsgraph. */
 	BKE_mask_update_scene(bmain, scene);
 
@@ -1604,7 +1604,7 @@ void BKE_scene_update_for_newframe(EvaluationContext *eval_ctx, Main *bmain, Sce
 	BKE_main_id_tag_idcode(bmain, ID_LA, LIB_TAG_DOIT, false);
 
 	/* BKE_object_handle_update() on all objects, groups and sets */
-	DEG_evaluate_on_framechange(eval_ctx, bmain, sce->depsgraph, ctime);
+	DEG_evaluate_on_framechange(eval_ctx, bmain, sce->depsgraph_legacy, ctime);
 
 	/* update sound system animation (TODO, move to depsgraph) */
 	BKE_sound_update_scene(bmain, sce);
@@ -2250,3 +2250,9 @@ int BKE_scene_multiview_num_videos_get(const RenderData *rd)
 		return BKE_scene_multiview_num_views_get(rd);
 	}
 }
+
+Depsgraph* BKE_scene_get_depsgraph(Scene *scene, SceneLayer *scene_layer)
+{
+	(void) scene_layer;
+	return scene->depsgraph_legacy;
+}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 61fb616013c..7f92cc9e8bb 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6093,7 +6093,7 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
 	SceneRenderLayer *srl;
 	
 	sce->theDag = NULL;
-	sce->depsgraph = NULL;
+	sce->depsgraph_legacy = NULL;
 	sce->obedit = NULL;
 	sce->fps_info = NULL;
 	sce->customdata_mask_modal = 0;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 88ff1ac0a9c..41934e3e4e6 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -261,8 +261,8 @@ void DEG_relations_tag_update(Main *bmain)
 	     scene != NULL;
 	     scene = (Scene *)scene->id.next)
 	{
-		if (scene->depsgraph != NULL) {
-			DEG_graph_tag_relations_update(scene->depsgraph);
+		if (scene->depsgraph_legacy != NULL) {
+			DEG_graph_tag_relations_update(scene->depsgraph_legacy);
 		}
 	}
 }
@@ -272,14 +272,14 @@ void DEG_relations_tag_update(Main *bmain)
  */
 void DEG_scene_relations_update(Main *bmain, Scene *scene)
 {
-	if (scene->depsgraph == NULL) {
+	if (scene->depsgraph_legacy == NULL) {
 		/* Rebuild graph from scratch and exit. */
-		scene->depsgraph = DEG_graph_new();
-		DEG_graph_build_from_scene(scene->depsgraph, bmain, scene);
+		scene->depsgraph_legacy = DEG_graph_new();
+		DEG_graph_build_from_scene(scene->depsgraph_legacy, bmain, scene);
 		return;
 	}
 
-	DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph);
+	DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph_legacy);
 	if (!graph->need_update) {
 		/* Graph is up to date, nothing to do. */
 		return;
@@ -301,17 +301,17 @@ void DEG_scene_relations_update(Main *bmain, Scene *scene)
 /* Rebuild dependency graph only for a given scene. */
 void DEG_scene_relations_rebuild(Main *bmain, Scene *scene)
 {
-	if (scene->depsgraph != NULL) {
-		DEG_graph_tag_relations_update(scene->depsgraph);
+	if (scene->depsgraph_legacy != NULL) {
+		DEG_graph_tag_relations_update(scene->depsgraph_legacy);
 	}
 	DEG_scene_relations_update(bmain, scene);
 }
 
 void DEG_scene_graph_free(Scene *scene)
 {
-	if (scene->depsgraph) {
-		DEG_graph_free(scene->depsgraph);
-		scene->depsgraph = NULL;
+	if (scene->depsgraph_legacy) {
+		DEG_graph_free(scene->depsgraph_legacy);
+		scene->depsgraph_legacy = NULL;
 	}
 }
 
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index 388b692d742..453bd2aa75f 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -91,7 +91,7 @@ bool DEG_debug_scene_relations_validate(Main *bmain,
 	Depsgraph *depsgraph = DEG_graph_new();
 	bool valid = true;
 	DEG_graph_build_from_scene(depsgraph, bmain, scene);
-	if (!DEG_debug_compare(depsgraph, scene->depsgraph)) {
+	if (!DEG_debug_compare(depsgraph, scene->depsgraph_legacy)) {
 		fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n");
 		BLI_assert(!"This should not happen!");
 		valid = false;
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 5b7294d92f9..abf4cba2617 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -230,8 +230,8 @@ void DEG_id_tag_update_ex(Main *bmain, ID *id, int flag)
 	     scene != NULL;
 	     scene = (Scene *)scene->id.next)
 	{
-		if (scene->depsgraph) {
-			Depsgraph *graph = scene->depsgraph;
+		if (scene->depsgraph_legacy) {
+			Depsgraph *graph = scene->depsgraph_legacy;
 			if (flag == 0) {
 				/* TODO(sergey): Currently blender is still tagging IDs
 				 * for recalc just using flag=0. This isn't totally correct
@@ -294,10 +294,10 @@ void DEG_id_type_tag(Main *bmain, short idtype)
 void DEG_ids_flush_tagged(Main *bmain, Scene *scene)
 {
 	/* TODO(sergey): Only visible scenes? */
-	if (scene->depsgraph != NULL) {
+	if (scene->depsgraph_legacy != NULL) {
 		DEG::deg_graph_flush_updates(
 		        bmain,
-		        reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph));
+		        reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph_legacy));
 	}
 }
 
@@ -305,7 +305,7 @@ void DEG_ids_flush_tagged(Main *bmain, Scene *scene)
 void DEG_graph_on_visible_update(Main *bmain, Scene *scene)
 {
 	(void) bmain;
-	DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph);
+	DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph_legacy);
 	GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash)
 	{
 		id_node->tag_update(graph);
@@ -319,7 +319,7 @@ void DEG_on_visible_update(Main *bmain, const bool UNUSED(do_time))
 	     scene != NULL;
 	     scene = (Scene *)scene->id.next)
 	{
-		if (scene->depsgraph != NULL) {
+	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list