diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-10 16:07:39 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-12 12:05:18 +0300 |
commit | ca2484e09005207e7bad90f484de6cbba1013833 (patch) | |
tree | f0fb0556c6c88e99ec4c47b7622281f534bf33bf /source/blender/depsgraph/intern/builder | |
parent | c1680902ac9a0a6431a2ae5258b0806b60a95a75 (diff) |
Depsgraph: Remove function bindings with collections
Use single function to evaluate all the collections for the given view layer.
This way we avoid need to get scene ID sub-data. Similar to pchan index, this
allows us to avoid build-time scene expansion, which also simplifies update of
the scene datablock.
Well, sort of. There is still work to be done to get rid of build-time scene
datablock expansion, which includes:
- Need to pass view layer by index.
Annoying part would be to get actual view layer for that index. In practice
doing list lookup might not be such a bad idea, since such lookup will not
happen very often, and it is unlikely to have more than handful of view
layer anyway.
Other idea could be to use view layer from evaluation context.
Or maybe from depsgraph, which is supposed to be in the context. Can have
some assert statements to make sure everything is good.
- Need to get id of base binding for flags flush.
We can replace that with index-based lookup from an array created by view
layer evaluation.
Reviewers: dfelinto
Differential Revision: https://developer.blender.org/D3141
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
8 files changed, 9 insertions, 280 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index eff6b34fee6..338d1bc7572 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -414,7 +414,7 @@ void DepsgraphNodeBuilder::build_group(Group *group) function_bind(BKE_group_eval_view_layers, _1, group_cow), - DEG_OPCODE_VIEW_LAYER_DONE); + DEG_OPCODE_VIEW_LAYER_EVAL); } void DepsgraphNodeBuilder::build_object(Base *base, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index fd72ae527b8..8c2885614fb 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -214,17 +214,6 @@ struct DepsgraphNodeBuilder { void build_movieclip(MovieClip *clip); void build_lightprobe(Object *object); - struct LayerCollectionState { - int index; - LayerCollection *parent; - }; - void build_layer_collection(ID *owner_id, - LayerCollection *layer_collection, - LayerCollectionState *state); - void build_layer_collections(ID *owner_id, - ListBase *layer_collections, - LayerCollectionState *state); - void build_view_layer_collections(ID *owner_id, ViewLayer *view_layer); protected: struct SavedEntryTag { ID *id; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc deleted file mode 100644 index 2ee526b7128..00000000000 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Original Author: Joshua Leung - * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013) - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc - * \ingroup depsgraph - * - * Methods for constructing depsgraph's nodes - */ - -#include "intern/builder/deg_builder_nodes.h" - -#include <stdio.h> -#include <stdlib.h> - -#include "MEM_guardedalloc.h" - -extern "C" { -#include "BLI_utildefines.h" -#include "BLI_listbase.h" -#include "BLI_string.h" - -#include "BKE_layer.h" - -#include "DNA_scene_types.h" - -#include "DEG_depsgraph.h" -#include "DEG_depsgraph_build.h" -} /* extern "C" */ - -#include "intern/builder/deg_builder.h" -#include "intern/eval/deg_eval_copy_on_write.h" -#include "intern/nodes/deg_node.h" -#include "intern/nodes/deg_node_component.h" -#include "intern/nodes/deg_node_operation.h" -#include "intern/depsgraph_types.h" -#include "intern/depsgraph_intern.h" -#include "util/deg_util_foreach.h" - -namespace DEG { - -void DepsgraphNodeBuilder::build_layer_collection( - ID *owner_id, - LayerCollection *layer_collection, - LayerCollectionState *state) -{ - /* TODO(sergey): This will attempt to create component for each collection. - * Harmless but could be optimized. - */ - ComponentDepsNode *comp = add_component_node( - owner_id, - DEG_NODE_TYPE_LAYER_COLLECTIONS); - - add_operation_node(comp, - function_bind(BKE_layer_eval_layer_collection, - _1, - layer_collection, - state->parent), - DEG_OPCODE_VIEW_LAYER_EVAL, - layer_collection->scene_collection->name, - state->index); - ++state->index; - - /* Recurs into nested layer collections. */ - LayerCollection *parent = state->parent; - state->parent = layer_collection; - build_layer_collections(owner_id, &layer_collection->layer_collections, state); - state->parent = parent; -} - -void DepsgraphNodeBuilder::build_layer_collections(ID *owner_id, - ListBase *layer_collections, - LayerCollectionState *state) -{ - LISTBASE_FOREACH (LayerCollection *, layer_collection, layer_collections) { - build_layer_collection(owner_id, layer_collection, state); - } -} - -void DepsgraphNodeBuilder::build_view_layer_collections( - ID *owner_id, - ViewLayer *view_layer) -{ - LayerCollectionState state; - state.index = 0; - ComponentDepsNode *comp = add_component_node( - owner_id, - DEG_NODE_TYPE_LAYER_COLLECTIONS); - add_operation_node(comp, - function_bind(BKE_layer_eval_layer_collection_pre, - _1, - owner_id, - view_layer), - DEG_OPCODE_VIEW_LAYER_INIT); - add_operation_node(comp, - function_bind(BKE_layer_eval_layer_collection_post, - _1, - view_layer), - DEG_OPCODE_VIEW_LAYER_DONE); - state.parent = NULL; - build_layer_collections(owner_id, &view_layer->layer_collections, &state); -} - -} // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc index 859ad36d06d..77f5283e0f0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc @@ -157,7 +157,13 @@ void DepsgraphNodeBuilder::build_view_layer( build_movieclip(clip); } /* Collections. */ - build_view_layer_collections(&scene->id, view_layer_cow); + add_operation_node(&scene->id, + DEG_NODE_TYPE_LAYER_COLLECTIONS, + function_bind(BKE_layer_eval_view_layer, + _1, + &scene_cow->id, + view_layer_cow), + DEG_OPCODE_VIEW_LAYER_EVAL); /* Parameters evaluation for scene relations mainly. */ add_operation_node(&scene->id, DEG_NODE_TYPE_PARAMETERS, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 06d7f2cd880..ff1728eb89f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -505,7 +505,7 @@ void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object) } OperationKey view_layer_done_key(&scene_->id, DEG_NODE_TYPE_LAYER_COLLECTIONS, - DEG_OPCODE_VIEW_LAYER_DONE); + DEG_OPCODE_VIEW_LAYER_EVAL); OperationKey object_flags_key(&object->id, DEG_NODE_TYPE_LAYER_COLLECTIONS, DEG_OPCODE_OBJECT_BASE_FLAGS); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index d0b5b48fafe..df6fb100d22 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -264,20 +264,6 @@ struct DepsgraphRelationBuilder EffectorWeights *eff, bool add_absorption, const char *name); - struct LayerCollectionState { - int index; - OperationKey init_key; - OperationKey done_key; - OperationKey prev_key; - }; - void build_layer_collection(ID *owner_id, - LayerCollection *layer_collection, - LayerCollectionState *state); - void build_layer_collections(ID *owner_id, - ListBase *layer_collections, - LayerCollectionState *state); - void build_view_layer_collections(struct ID *owner_id, ViewLayer *view_layer); - void build_copy_on_write_relations(); void build_copy_on_write_relations(IDDepsNode *id_node); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_layer_collection.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_layer_collection.cc deleted file mode 100644 index e2154558ed7..00000000000 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_layer_collection.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Original Author: Joshua Leung - * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013) - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/depsgraph/intern/builder/deg_builder_relations_layer_collection.cc - * \ingroup depsgraph - * - * Methods for constructing depsgraph - */ - -#include "intern/builder/deg_builder_relations.h" - -#include <stdio.h> -#include <stdlib.h> -#include <cstring> /* required for STREQ later on. */ - -#include "MEM_guardedalloc.h" - -extern "C" { -#include "BLI_blenlib.h" -#include "BLI_utildefines.h" - -#include "DNA_node_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" - -#include "BKE_layer.h" -#include "BKE_main.h" -#include "BKE_node.h" - -#include "DEG_depsgraph.h" -#include "DEG_depsgraph_build.h" -} /* extern "C" */ - -#include "intern/builder/deg_builder.h" -#include "intern/builder/deg_builder_pchanmap.h" - -#include "intern/nodes/deg_node.h" -#include "intern/nodes/deg_node_component.h" -#include "intern/nodes/deg_node_operation.h" - -#include "intern/depsgraph_intern.h" -#include "intern/depsgraph_types.h" - -#include "util/deg_util_foreach.h" - -namespace DEG { - -void DepsgraphRelationBuilder::build_layer_collection( - ID *owner_id, - LayerCollection *layer_collection, - LayerCollectionState *state) -{ - OperationKey layer_key(owner_id, - DEG_NODE_TYPE_LAYER_COLLECTIONS, - DEG_OPCODE_VIEW_LAYER_EVAL, - layer_collection->scene_collection->name, - state->index); - add_relation(state->prev_key, layer_key, "Layer collection order"); - - ++state->index; - state->prev_key = layer_key; - - /* Recurs into nested layer collections. */ - build_layer_collections(owner_id, &layer_collection->layer_collections, state); -} - -void DepsgraphRelationBuilder::build_layer_collections( - ID *owner_id, - ListBase *layer_collections, - LayerCollectionState *state) -{ - LISTBASE_FOREACH (LayerCollection *, layer_collection, layer_collections) { - /* Recurs into the layer. */ - build_layer_collection(owner_id, layer_collection, state); - } -} - -void DepsgraphRelationBuilder::build_view_layer_collections( - ID *owner_id, - ViewLayer *view_layer) -{ - LayerCollectionState state; - state.index = 0; - - OperationKey init_key(owner_id, - DEG_NODE_TYPE_LAYER_COLLECTIONS, - DEG_OPCODE_VIEW_LAYER_INIT); - OperationKey done_key(owner_id, - DEG_NODE_TYPE_LAYER_COLLECTIONS, - DEG_OPCODE_VIEW_LAYER_DONE); - - state.init_key = init_key; - state.done_key = done_key; - state.prev_key = init_key; - - build_layer_collections(owner_id, &view_layer->layer_collections, &state); - - add_relation(state.prev_key, done_key, "Layer collection order"); -} - -} // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc index 074d20bb750..339046dfac0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc @@ -112,8 +112,6 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la LISTBASE_FOREACH (MovieClip *, clip, &bmain_->movieclip) { build_movieclip(clip); } - /* Collections. */ - build_view_layer_collections(&scene_->id, view_layer); /* TODO(sergey): Do this flush on CoW object? */ foreach (OperationDepsNode *node, graph_->operations) { IDDepsNode *id_node = node->owner->owner; |