[Bf-blender-cvs] [73a199e96a6] master: Depsgraph: Pass bmain to depsgraph object creation

Sergey Sharybin noreply at git.blender.org
Wed Sep 11 10:59:11 CEST 2019


Commit: 73a199e96a68a5b9521ba7d3e8cca85697095c03
Author: Sergey Sharybin
Date:   Mon Sep 9 14:49:05 2019 +0200
Branches: master
https://developer.blender.org/rB73a199e96a68a5b9521ba7d3e8cca85697095c03

Depsgraph: Pass bmain to depsgraph object creation

Currently unused, but will allow to keep of an owner of the depsgraph.

Could also simplify other APIs in the future by avoiding to pass bmain
explicitly to relation update functions and things like that.

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

M	source/blender/alembic/intern/alembic_capi.cc
M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/intern/context.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/collada/BlenderContext.cpp
M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph.cc
M	source/blender/depsgraph/intern/depsgraph.h
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/draw/engines/eevee/eevee_lightcache.c
M	source/blender/draw/intern/draw_manager.c
M	source/blender/editors/object/object_bake_api.c
M	source/blender/editors/render/render_update.c
M	source/blender/editors/scene/scene_edit.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_info/info_stats.c
M	source/blender/editors/space_node/node_edit.c
M	source/blender/editors/transform/transform_convert_object.c
M	source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M	source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
M	source/blender/makesrna/intern/rna_layer.c
M	source/blender/makesrna/intern/rna_scene_api.c
M	source/blender/makesrna/intern/rna_space_api.c
M	source/blender/python/gpu/gpu_py_offscreen.c
M	source/blender/render/intern/source/external_engine.c
M	source/blender/render/intern/source/pipeline.c
M	source/blender/windowmanager/intern/wm_draw.c
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	tests/gtests/alembic/abc_export_test.cc

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

diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 13533ef9972..9ace0a8faa9 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -330,7 +330,7 @@ bool ABC_export(Scene *scene,
    * hardcore refactoring. */
   new (&job->settings) ExportSettings();
   job->settings.scene = scene;
-  job->settings.depsgraph = DEG_graph_new(scene, job->view_layer, DAG_EVAL_RENDER);
+  job->settings.depsgraph = DEG_graph_new(job->bmain, scene, job->view_layer, DAG_EVAL_RENDER);
 
   /* TODO(Sybren): for now we only export the active scene layer.
    * Later in the 2.8 development process this may be replaced by using
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index d25288fc240..846b8d21f28 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -220,7 +220,8 @@ void BKE_scene_allocate_depsgraph_hash(struct Scene *scene);
 void BKE_scene_ensure_depsgraph_hash(struct Scene *scene);
 void BKE_scene_free_depsgraph_hash(struct Scene *scene);
 
-struct Depsgraph *BKE_scene_get_depsgraph(struct Scene *scene,
+struct Depsgraph *BKE_scene_get_depsgraph(struct Main *bmain,
+                                          struct Scene *scene,
                                           struct ViewLayer *view_layer,
                                           bool allocate);
 
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index bcf6bb338ff..7f2f04d7eb5 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1351,9 +1351,10 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
 
 Depsgraph *CTX_data_depsgraph_pointer(const bContext *C)
 {
+  Main *bmain = CTX_data_main(C);
   Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
-  Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+  Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
   /* Dependency graph might have been just allocated, and hence it will not be marked.
    * This confuses redo system due to the lack of flushing changes back to the original data.
    * In the future we would need to check whether the CTX_wm_window(C)  is in editing mode (as an
@@ -1381,7 +1382,8 @@ Depsgraph *CTX_data_ensure_evaluated_depsgraph(const bContext *C)
 
 Depsgraph *CTX_data_depsgraph_on_load(const bContext *C)
 {
+  Main *bmain = CTX_data_main(C);
   Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
-  return BKE_scene_get_depsgraph(scene, view_layer, false);
+  return BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
 }
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index dbb39184b1e..aa812dff877 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1408,7 +1408,7 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
  */
 void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer)
 {
-  Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+  Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
   DEG_make_active(depsgraph);
   BKE_scene_graph_update_tagged(depsgraph, bmain);
 }
@@ -2040,7 +2040,7 @@ void BKE_scene_free_depsgraph_hash(Scene *scene)
 
 /* Query depsgraph for a specific contexts. */
 
-Depsgraph *BKE_scene_get_depsgraph(Scene *scene, ViewLayer *view_layer, bool allocate)
+Depsgraph *BKE_scene_get_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, bool allocate)
 {
   BLI_assert(scene != NULL);
   BLI_assert(view_layer != NULL);
@@ -2064,7 +2064,7 @@ Depsgraph *BKE_scene_get_depsgraph(Scene *scene, ViewLayer *view_layer, bool all
             scene->depsgraph_hash, &key, (void ***)&key_ptr, (void ***)&depsgraph_ptr)) {
       *key_ptr = MEM_mallocN(sizeof(DepsgraphKey), __func__);
       **key_ptr = key;
-      *depsgraph_ptr = DEG_graph_new(scene, view_layer, DAG_EVAL_VIEWPORT);
+      *depsgraph_ptr = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_VIEWPORT);
       /* TODO(sergey): Would be cool to avoid string format print,
        * but is a bit tricky because we can't know in advance  whether
        * we will ever enable debug messages for this depsgraph.
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index b29e07bb56d..dca6f05e0de 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -3534,7 +3534,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
     }
 
     /* opengl offscreen render */
-    depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+    depsgraph = BKE_scene_get_depsgraph(context->bmain, scene, view_layer, true);
     BKE_scene_graph_update_for_newframe(depsgraph, context->bmain);
     ibuf = sequencer_view3d_cb(
         /* set for OpenGL render (NULL when scrubbing) */
diff --git a/source/blender/collada/BlenderContext.cpp b/source/blender/collada/BlenderContext.cpp
index 709f84c3f77..8735d71ec40 100644
--- a/source/blender/collada/BlenderContext.cpp
+++ b/source/blender/collada/BlenderContext.cpp
@@ -121,7 +121,7 @@ bContext *BlenderContext::get_context()
 Depsgraph *BlenderContext::get_depsgraph()
 {
   if (!depsgraph) {
-    depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+    depsgraph = BKE_scene_get_depsgraph(main, scene, view_layer, true);
   }
   return depsgraph;
 }
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index d4518729d99..e44dddbcf54 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -87,7 +87,10 @@ extern "C" {
 
 /* Create new Depsgraph instance */
 // TODO: what args are needed here? What's the building-graph entry point?
-Depsgraph *DEG_graph_new(struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode);
+Depsgraph *DEG_graph_new(struct Main *bmain,
+                         struct Scene *scene,
+                         struct ViewLayer *view_layer,
+                         eEvaluationMode mode);
 
 /* Free Depsgraph itself and all its data */
 void DEG_graph_free(Depsgraph *graph);
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 6d3aed65a14..6e98907597b 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -65,10 +65,11 @@ template<typename T> static void remove_from_vector(vector<T> *vector, const T &
   vector->erase(std::remove(vector->begin(), vector->end(), value), vector->end());
 }
 
-Depsgraph::Depsgraph(Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
+Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
     : time_source(NULL),
       need_update(true),
       need_update_time(false),
+      bmain(bmain),
       scene(scene),
       view_layer(view_layer),
       mode(mode),
@@ -313,9 +314,10 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const
 /* Public Graph API */
 
 /* Initialize a new Depsgraph */
-Depsgraph *DEG_graph_new(Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
+Depsgraph *DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
 {
-  DEG::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW(DEG::Depsgraph, scene, view_layer, mode);
+  DEG::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW(
+      DEG::Depsgraph, bmain, scene, view_layer, mode);
   return reinterpret_cast<Depsgraph *>(deg_depsgraph);
 }
 
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 96b1a2a1f8a..30ae4edde34 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -100,7 +100,7 @@ struct Depsgraph {
   typedef vector<OperationNode *> OperationNodes;
   typedef vector<IDNode *> IDDepsNodes;
 
-  Depsgraph(Scene *scene, ViewLayer *view_layer, eEvaluationMode mode);
+  Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode);
   ~Depsgraph();
 
   TimeSourceNode *add_time_source();
@@ -172,7 +172,8 @@ struct Depsgraph {
    * Mainly used by graph evaluation. */
   SpinLock lock;
 
-  /* Scene, layer, mode this dependency graph is built for. */
+  /* Main, scene, layer, mode this dependency graph is built for. */
+  Main *bmain;
   Scene *scene;
   ViewLayer *view_layer;
   eEvaluationMode mode;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index dd2d7f70ed5..968ed8ef403 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -358,7 +358,7 @@ void DEG_relations_tag_update(Main *bmain)
   DEG_GLOBAL_DEBUG_PRINTF(TAG, "%s: Tagging relations for update.\n", __func__);
   LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
     LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
-      Depsgraph *depsgraph = (Depsgraph *)BKE_scene_get_depsgraph(scene, view_layer, false);
+      Depsgraph *depsgraph = (Depsgraph *)BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
       if (depsgraph != NULL) {
         DEG_graph_tag_relations_update(depsgraph);
       }
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index c5a756102ca..d079c958e04 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -91,7 +91,7 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph,
                                         Scene *scene,
                                         ViewLayer *view_layer)
 {
-  Depsgraph *temp_depsgraph = DEG_graph_new(scene, view_layer, DEG_get_mode(graph));
+  Depsgraph *temp_depsgraph = DEG_graph_new(bmain, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list