[Bf-blender-cvs] [60bf1c05e5d] blender2.8: Depsgraph: Fix/workaround crash when rendering from command line

Sergey Sharybin noreply at git.blender.org
Tue Nov 7 11:38:58 CET 2017


Commit: 60bf1c05e5d28634c1c1ae32ceaf66424bd24198
Author: Sergey Sharybin
Date:   Tue Nov 7 10:10:21 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB60bf1c05e5d28634c1c1ae32ceaf66424bd24198

Depsgraph: Fix/workaround crash when rendering from command line

Need to ensure Render has proper dependency graph.

While this is a subject of re-design (render pipeline should manage all
dependency graphs it needs, and not demand external users to provide
depsgraph), this is good to have something working, so we can run regression
tests and such.

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

M	source/creator/creator_args.c

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

diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 4ebc679cf0b..f16383f3a0a 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -90,6 +90,7 @@
 #endif
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
 
 #include "creator_intern.h"  /* own include */
 
@@ -426,6 +427,28 @@ static void arg_py_context_restore(
 
 /** \} */
 
+static void render_set_depgraph(bContext *C, Render *re)
+{
+	/* TODO(sergey): For until we make depsgraph to be created and
+	 * handled by render pipeline.
+	 */
+	Main *bmain = CTX_data_main(C);
+	Scene *scene = CTX_data_scene(C);
+	/* NOTE: This is STUPID to use first layer, but is ok for now
+	 * (at least for until depsgraph becomes per-layer).
+	 * Apparently, CTX_data_layer is crashing here (context's layer
+	 * is NULL for old files, and there is no workspace).
+	 */
+	SceneLayer *scene_layer = scene->render_layers.first;
+	Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer);
+	/* TODO(sergey): This is a temporary solution. */
+	if (depsgraph == NULL) {
+		scene->depsgraph_legacy = depsgraph = DEG_graph_new();
+		DEG_graph_build_from_scene(depsgraph, bmain, scene);
+		DEG_graph_on_visible_update(bmain, depsgraph);
+	}
+	RE_SetDepsgraph(re, depsgraph);
+}
 
 /* -------------------------------------------------------------------- */
 
@@ -1354,8 +1377,8 @@ static int arg_handle_render_frame(int argc, const char **argv, void *data)
 			re = RE_NewSceneRender(scene);
 			BLI_begin_threaded_malloc();
 			BKE_reports_init(&reports, RPT_STORE);
-
 			RE_SetReports(re, &reports);
+			render_set_depgraph(C, re);
 			for (int i = 0; i < frames_range_len; i++) {
 				/* We could pass in frame ranges,
 				 * but prefer having exact behavior as passing in multiple frames */
@@ -1398,6 +1421,7 @@ static int arg_handle_render_animation(int UNUSED(argc), const char **UNUSED(arg
 		BLI_begin_threaded_malloc();
 		BKE_reports_init(&reports, RPT_STORE);
 		RE_SetReports(re, &reports);
+		render_set_depgraph(C, re);
 		RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step);
 		RE_SetReports(re, NULL);
 		BKE_reports_clear(&reports);



More information about the Bf-blender-cvs mailing list