Commit: a17de773fd86320c33668cd6d22e9d31954d2b34
Author: Sergey Sharybin
Date:   Thu Feb 22 11:20:28 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBa17de773fd86320c33668cd6d22e9d31954d2b34

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/depsgraph/CMakeLists.txt
index c42d06bd0a2,50c0910ef02..c2f69343456
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@@ -42,10 -42,10 +42,11 @@@ set(INC_SY
  set(SRC
        intern/builder/deg_builder.cc
        intern/builder/deg_builder_cycle.cc
+       intern/builder/deg_builder_map.cc
        intern/builder/deg_builder_nodes.cc
 +      intern/builder/deg_builder_nodes_layer_collection.cc
        intern/builder/deg_builder_nodes_rig.cc
 -      intern/builder/deg_builder_nodes_scene.cc
 +      intern/builder/deg_builder_nodes_view_layer.cc
        intern/builder/deg_builder_pchanmap.cc
        intern/builder/deg_builder_relations.cc
        intern/builder/deg_builder_relations_keys.cc
diff --cc source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index b65c16591dc,7572ee90c0b..d115111b7e8
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@@ -174,44 -161,11 +174,44 @@@ DepsgraphNodeBuilder::DepsgraphNodeBuil
  
  DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
  {
 +      if (cow_id_hash_ != NULL) {
 +              BLI_ghash_free(cow_id_hash_, NULL, 
free_copy_on_write_datablock);
 +      }
  }
  
- IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id, bool do_tag)
+ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
  {
 -      return graph_->add_id_node(id, id->name);
 +      if (!DEG_depsgraph_use_copy_on_write()) {
-               return graph_->add_id_node(id, do_tag);
++              return graph_->add_id_node(id);
 +      }
 +      IDDepsNode *id_node = NULL;
 +      ID *id_cow = (ID *)BLI_ghash_lookup(cow_id_hash_, id);
 +      if (id_cow != NULL) {
 +              /* TODO(sergey): Is it possible to lookup and pop element from 
GHash
 +               * at the same time?
 +               */
 +              BLI_ghash_remove(cow_id_hash_, id, NULL, NULL);
 +      }
-       id_node = graph_->add_id_node(id, do_tag, id_cow);
++      id_node = graph_->add_id_node(id, id_cow);
 +      /* Currently all ID nodes are supposed to have copy-on-write logic.
 +       *
 +       * NOTE: Zero number of components indicates that ID node was just 
created.
 +       */
 +      if (BLI_ghash_len(id_node->components) == 0) {
 +              ComponentDepsNode *comp_cow =
 +                      id_node->add_component(DEG_NODE_TYPE_COPY_ON_WRITE);
 +              OperationDepsNode *op_cow = comp_cow->add_operation(
 +                      function_bind(deg_evaluate_copy_on_write, _1, graph_, 
id_node),
 +                      DEG_OPCODE_COPY_ON_WRITE,
 +                      "", -1);
 +              graph_->operations.push_back(op_cow);
 +      }
 +      return id_node;
 +}
 +
 +IDDepsNode *DepsgraphNodeBuilder::find_id_node(ID *id)
 +{
 +      return graph_->find_id_node(id);
  }
  
  TimeSourceDepsNode *DepsgraphNodeBuilder::add_time_source()
@@@ -322,156 -276,46 +322,137 @@@ OperationDepsNode *DepsgraphNodeBuilder
        return find_operation_node(id, comp_type, "", opcode, name, name_tag);
  }
  
 +ID *DepsgraphNodeBuilder::get_cow_id(const ID *id_orig) const
 +{
 +      return graph_->get_cow_id(id_orig);
 +}
 +
 +ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig)
 +{
 +      if (id_orig->tag & LIB_TAG_COPY_ON_WRITE) {
 +              /* ID is already remapped to copy-on-write. */
 +              return id_orig;
 +      }
-       IDDepsNode *id_node = add_id_node(id_orig, false);
++      IDDepsNode *id_node = add_id_node(id_orig);
 +      return id_node->id_cow;
 +}
 +
 +ID *DepsgraphNodeBuilder::expand_cow_id(IDDepsNode *id_node)
 +{
 +      return deg_expand_copy_on_write_datablock(graph_, id_node, this, true);
 +}
 +
 +ID *DepsgraphNodeBuilder::expand_cow_id(ID *id_orig)
 +{
 +      IDDepsNode *id_node = add_id_node(id_orig);
 +      return expand_cow_id(id_node);
 +}
 +
  /* **** Build functions for entity nodes **** */
  
  void DepsgraphNodeBuilder::begin_build() {
-       /* LIB_TAG_DOIT is used to indicate whether node for given ID was 
already
-        * created or not. This flag is being set in add_id_node(), so functions
-        * shouldn't bother with setting it, they only might query this flag 
when
-        * needed.
-        */
-       BKE_main_id_tag_all(bmain_, LIB_TAG_DOIT, false);
-       /* XXX nested node trees are not included in tag-clearing above,
-        * so we need to do this manually.
-        */
-       FOREACH_NODETREE(bmain_, nodetree, id)
-       {
-               if (id != (ID *)nodetree) {
-                       nodetree->id.tag &= ~LIB_TAG_DOIT;
-               }
-       }
-       FOREACH_NODETREE_END;
- 
 +      if (DEG_depsgraph_use_copy_on_write()) {
 +              /* Store existing copy-on-write versions of datablock, so we 
can re-use
 +               * them for new ID nodes.
 +               */
 +              cow_id_hash_ = BLI_ghash_ptr_new("Depsgraph id hash");
 +              foreach (IDDepsNode *id_node, graph_->id_nodes) {
 +                      if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
 +                              BLI_ghash_insert(cow_id_hash_,
 +                                               id_node->id_orig,
 +                                               id_node->id_cow);
 +                              id_node->id_cow = NULL;
 +                      }
 +              }
 +      }
 +
 +      GSET_FOREACH_BEGIN(OperationDepsNode *, op_node, graph_->entry_tags)
 +      {
 +              ComponentDepsNode *comp_node = op_node->owner;
 +              IDDepsNode *id_node = comp_node->owner;
 +
 +              SavedEntryTag entry_tag;
 +              entry_tag.id = id_node->id_orig;
 +              entry_tag.component_type = comp_node->type;
 +              entry_tag.opcode = op_node->opcode;
 +              saved_entry_tags_.push_back(entry_tag);
 +      };
 +      GSET_FOREACH_END();
 +
 +      /* Make sure graph has no nodes left from previous state. */
 +      graph_->clear_all_nodes();
 +      graph_->operations.clear();
 +      BLI_gset_clear(graph_->entry_tags, NULL);
 +}
 +
 +void DepsgraphNodeBuilder::end_build()
 +{
 +      foreach (const SavedEntryTag& entry_tag, saved_entry_tags_) {
 +              IDDepsNode *id_node = find_id_node(entry_tag.id);
 +              if (id_node == NULL) {
 +                      continue;
 +              }
 +              ComponentDepsNode *comp_node =
 +                      id_node->find_component(entry_tag.component_type);
 +              if (comp_node == NULL) {
 +                      continue;
 +              }
 +              OperationDepsNode *op_node = 
comp_node->find_operation(entry_tag.opcode);
 +              if (op_node == NULL) {
 +                      continue;
 +              }
 +              op_node->tag_update(graph_);
 +      }
  }
  
 -void DepsgraphNodeBuilder::build_group(Base *base, Group *group)
 +void DepsgraphNodeBuilder::build_group(Group *group)
  {
-       ID *group_id = &group->id;
-       if (group_id->tag & LIB_TAG_DOIT) {
+       if (built_map_.checkIsBuiltAndTag(group)) {
                return;
        }
-       group_id->tag |= LIB_TAG_DOIT;
 -      LISTBASE_FOREACH (GroupObject *, go, &group->gobject) {
 -              build_object(base, go->ob);
 +      /* Build group objects. */
 +      LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) {
 +              build_object(NULL, base->object, DEG_ID_LINKED_INDIRECTLY);
        }
 +      /* Operation to evaluate the whole view layer.
 +       *
 +       * NOTE: We re-use DONE opcode even though the function does everything.
 +       * This way we wouldn't need to worry about possible relations from 
DONE,
 +       * regardless whether it's a group or scene or something else.
 +       */
-       add_id_node(group_id);
++      add_id_node(&group->id);
 +      Group *group_cow = get_cow_datablock(group);
-       add_operation_node(group_id,
++      add_operation_node(&group->id,
 +                         DEG_NODE_TYPE_LAYER_COLLECTIONS,
 +                         function_bind(BKE_group_eval_view_layers,
 +                                       _1,
 +                                       group_cow),
 +                         DEG_OPCODE_VIEW_LAYER_DONE);
  }
  
 -void DepsgraphNodeBuilder::build_object(Base *base, Object *object)
 +void DepsgraphNodeBuilder::build_object(Base *base,
 +                                        Object *object,
 +                                        eDepsNode_LinkedState_Type 
linked_state)
  {
+       const bool has_object = built_map_.checkIsBuiltAndTag(object);
 -      IDDepsNode *id_node = (has_object)
 -              ? graph_->find_id_node(&object->id)
 -              : add_id_node(&object->id);
 -      /* Update node layers.
 -       * Do it for both new and existing ID nodes. This is so because several
 -       * bases might be sharing same object.
 -       */
 -      if (base != NULL) {
 -              id_node->layers |= base->lay;
 -      }
 -      if (object->type == OB_CAMERA) {
 -              /* Camera should always be updated, it used directly by 
viewport.
 -               *
 -               * TODO(sergey): Make it only for active scene camera.
 -               */
 -              id_node->layers |= (unsigned int)(-1);
 -      }
        /* Skip rest of components if the ID node was already there. */
-       if (object->id.tag & LIB_TAG_DOIT) {
+       if (has_object) {
 +              IDDepsNode *id_node = find_id_node(&object->id);
 +              /* We need to build some extra stuff if object becomes linked
 +               * directly.
 +               */
 +              if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) {
 +                      build_object_flags(base, object, linked_state);
 +              }
 +              id_node->linked_state = max(id_node->linked_state, 
linked_state);
                return;
        }
-       object->id.tag |= LIB_TAG_DOIT;
 +      /* Create ID node for object and begin init. */
 +      IDDepsNode *id_node = add_id_node(&object->id);
 +      id_node->linked_state = linked_state;
        object->customdata_mask = 0;
 +      /* Various flags, flushing from bases/collections. */
 +      build_object_flags(base, object, linked_state);
        /* Transform. */
        build_object_transform(object);
        /* Parent. */
@@@ -748,19 -545,16 +729,18 @@@ OperationDepsNode *DepsgraphNodeBuilder
  /* Recursively build graph for world */
  void DepsgraphNodeBuilder::build_world(World *world)
  {
-       ID *world_id = &world->id;
-       if (world_id->tag & LIB_TAG_DOIT) {
+       if (built_map_.checkIsBuiltAndTag(world)) {
                return;
        }
 -      ID *world_id = &world->id;
 -      build_animdata(world_id);
 +      /* Animation. */
-       build_animdata(world_id);
++      build_animdata(&world->id);
        /* world itself */
--      add_operation_node(world_id,
 -                         DEG_NODE_TYPE_PARAMETERS,
 -                         NULL,
 -                         DEG_OPCODE_PARAMETERS_EVAL);
++      add_operation_node(&world->id,
 +                         DEG_NODE_TYPE_SHADING,
 +                         function_bind(BKE_world_eval,
 +                                       _1,
 +                                       get_cow_datablock(world)),
 +                         DEG_OPCODE_WORLD_UPDATE);
        /* textures */
        build_texture_stack(world->mtex);
        /* world's nodetree */
@@@ -905,35 -673,8 +885,33 @@@ void DepsgraphNodeBuilder::build_partic
                }
        }
  
 -      /* pointcache */
 -      // TODO...
 +      /* TODO(sergey): Do we need a point cache operations here? */
 +      add_operation_node(&object->id,
 +                         DEG_NODE_TYPE_CACHE,
 +                         function_bind(BKE_ptcache_object_reset,
 +                                       scene_cow,
 +                                       ob_cow,
 +           

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to