Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-11-07 19:01:14 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-11-08 17:02:19 +0300
commit20988ed5dcec977c641a29f2cc948d4bdb6f86cd (patch)
tree55615ab40db56e1ba5a5a55f7f78de540ee84926 /source/blender/blenkernel/intern/scene.c
parent3750dfaa0a23130f1fc5200b67443ce68fa4d930 (diff)
Depsgraph: Move storage from single per-scene depsgraph to a hash storage
Depsgraph itself is still created fer the whole scene rather than for a single layer, this is to be addressed next. The storage for those dependency graphs is in scene, but now it is a hash indexed by layer. In the future we can extend hash key to include extra information (workspace? window?).
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r--source/blender/blenkernel/intern/scene.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index f5aa6223d5d..dfa9227b679 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1587,6 +1587,9 @@ static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene)
}
}
+/* TODO(sergey): This actually should become scene_layer_graph or so.
+ * Same applies to update_for_newframe.
+ */
void BKE_scene_graph_update_tagged(EvaluationContext *eval_ctx,
Depsgraph *depsgraph,
Main *bmain,
@@ -2436,10 +2439,37 @@ Depsgraph *BKE_scene_get_depsgraph(Scene *scene,
SceneLayer *scene_layer,
bool allocate)
{
- (void) scene_layer;
- Depsgraph *depsgraph = scene->depsgraph_legacy;
- if (depsgraph == NULL && allocate) {
- scene->depsgraph_legacy = depsgraph = DEG_graph_new();
+ BLI_assert(scene != NULL);
+ BLI_assert(scene_layer != NULL);
+ /* Make sure hash itself exists. */
+ if (allocate) {
+ BKE_scene_ensure_depsgraph_hash(scene);
+ }
+ if (scene->depsgraph_hash == NULL) {
+ return NULL;
+ }
+ /* Either ensure item is in the hash or simply return NULL if it's not,
+ * depending on whether caller wants us to create depsgraph or not.
+ */
+ DepsgraphKey key;
+ key.scene_layer = scene_layer;
+ Depsgraph *depsgraph;
+ if (allocate) {
+ DepsgraphKey **key_ptr;
+ Depsgraph **depsgraph_ptr;
+ if (!BLI_ghash_ensure_p_ex(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();
+ }
+ depsgraph = *depsgraph_ptr;
+ }
+ else {
+ depsgraph = BLI_ghash_lookup(scene->depsgraph_hash, &key);
}
return depsgraph;
}