[Bf-blender-cvs] [109cc14dba9] master: Revert hidden object optimization in depsgraph

Sergey Sharybin noreply at git.blender.org
Tue Sep 13 16:05:27 CEST 2022


Commit: 109cc14dba98db2b10688da8737b528877464d2c
Author: Sergey Sharybin
Date:   Tue Sep 13 15:56:54 2022 +0200
Branches: master
https://developer.blender.org/rB109cc14dba98db2b10688da8737b528877464d2c

Revert hidden object optimization in depsgraph

The internal state tracking is not fully suited for such kind
of optimization yet.

It is probably not that much work to make them work, but the
issue caused by the changes is serious enough for the studio
so it feels better to revert changes for now and have a closer
look into remaining issues without pressure.

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

M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/eval/deg_eval_flush.cc
M	source/blender/depsgraph/intern/eval/deg_eval_visibility.cc
M	source/blender/depsgraph/intern/node/deg_node_id.cc
M	source/blender/depsgraph/intern/node/deg_node_id.h

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 324197118d2..dcefb5528b2 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -155,14 +155,12 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
   IDComponentsMask previously_visible_components_mask = 0;
   uint32_t previous_eval_flags = 0;
   DEGCustomDataMeshMasks previous_customdata_masks;
-  int id_invisible_recalc = 0;
   IDInfo *id_info = id_info_hash_.lookup_default(id->session_uuid, nullptr);
   if (id_info != nullptr) {
     id_cow = id_info->id_cow;
     previously_visible_components_mask = id_info->previously_visible_components_mask;
     previous_eval_flags = id_info->previous_eval_flags;
     previous_customdata_masks = id_info->previous_customdata_masks;
-    id_invisible_recalc = id_info->id_invisible_recalc;
     /* Tag ID info to not free the CoW ID pointer. */
     id_info->id_cow = nullptr;
   }
@@ -170,7 +168,6 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
   id_node->previously_visible_components_mask = previously_visible_components_mask;
   id_node->previous_eval_flags = previous_eval_flags;
   id_node->previous_customdata_masks = previous_customdata_masks;
-  id_node->id_invisible_recalc = id_invisible_recalc;
 
   /* NOTE: Zero number of components indicates that ID node was just created. */
   const bool is_newly_created = id_node->components.is_empty();
@@ -369,7 +366,6 @@ void DepsgraphNodeBuilder::begin_build()
     id_info->previously_visible_components_mask = id_node->visible_components_mask;
     id_info->previous_eval_flags = id_node->eval_flags;
     id_info->previous_customdata_masks = id_node->customdata_masks;
-    id_info->id_invisible_recalc = id_node->id_invisible_recalc;
     BLI_assert(!id_info_hash_.contains(id_node->id_orig_session_uuid));
     id_info_hash_.add_new(id_node->id_orig_session_uuid, id_info);
     id_node->id_cow = nullptr;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 29cca0a8ddd..d5ac601ebff 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -250,8 +250,6 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
     IDComponentsMask previously_visible_components_mask;
     /* Special evaluation flag mask from the previous depsgraph. */
     uint32_t previous_eval_flags;
-    /* Recalculation flags which were not evaluated for the ID in the previous depsgraph. */
-    int id_invisible_recalc;
     /* Mesh CustomData mask from the previous depsgraph. */
     DEGCustomDataMeshMasks previous_customdata_masks;
   };
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index a8c8b4a6538..cc742b98866 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -890,13 +890,6 @@ void DEG_ids_clear_recalc(Depsgraph *depsgraph, const bool backup)
   }
   /* Go over all ID nodes, clearing tags. */
   for (deg::IDNode *id_node : deg_graph->id_nodes) {
-    if (!id_node->is_enabled_on_eval) {
-      id_node->id_invisible_recalc |= id_node->id_cow->recalc;
-    }
-    else {
-      id_node->id_invisible_recalc = 0;
-    }
-
     if (backup) {
       id_node->id_cow_recalc_backup |= id_node->id_cow->recalc;
     }
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 3f42d1a80c1..09981eb32c5 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -31,7 +31,6 @@
 #include "intern/debug/deg_debug.h"
 #include "intern/depsgraph.h"
 #include "intern/depsgraph_relation.h"
-#include "intern/depsgraph_tag.h"
 #include "intern/depsgraph_type.h"
 #include "intern/depsgraph_update.h"
 #include "intern/node/deg_node.h"
@@ -100,18 +99,6 @@ inline void flush_prepare(Depsgraph *graph)
 
 inline void flush_schedule_entrypoints(Depsgraph *graph, FlushQueue *queue)
 {
-  /* Something changed in the scene, so re-tag IDs with flags which were previously ignored due to
-   * ID being hidden. This will ensure the ID is properly evaluated when it becomes visible. */
-  for (IDNode *node : graph->id_nodes) {
-    if (node->id_invisible_recalc) {
-      graph_id_tag_update(graph->bmain,
-                          graph,
-                          node->id_orig,
-                          node->id_invisible_recalc,
-                          DEG_UPDATE_SOURCE_VISIBILITY);
-    }
-  }
-
   for (OperationNode *op_node : graph->entry_tags) {
     queue->push_back(op_node);
     op_node->scheduled = true;
@@ -384,10 +371,6 @@ void deg_graph_flush_updates(Depsgraph *graph)
     while (op_node != nullptr) {
       /* Tag operation as required for update. */
       op_node->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
-      /* Tag depsgraph visibility update when visibility operation is tagged for an update. */
-      if (op_node->opcode == OperationCode::VISIBILITY) {
-        graph->need_update_nodes_visibility = true;
-      }
       /* Inform corresponding ID and component nodes about the change. */
       ComponentNode *comp_node = op_node->owner;
       IDNode *id_node = comp_node->owner;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc b/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc
index 515c9a197d7..a056ba1dfa7 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc
@@ -34,13 +34,10 @@ void deg_evaluate_object_node_visibility(::Depsgraph *depsgraph, IDNode *id_node
 
   DEG_debug_print_eval(depsgraph, __func__, object->id.name, &object->id);
 
-  bool is_enabled;
-  if (graph->mode == DAG_EVAL_VIEWPORT) {
-    is_enabled = (object->base_flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT);
-  }
-  else {
-    is_enabled = (object->base_flag & BASE_ENABLED_RENDER);
-  };
+  const int required_flags = (graph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
+                                                                  BASE_ENABLED_RENDER;
+
+  const bool is_enabled = object->base_flag & required_flags;
 
   if (id_node->is_enabled_on_eval != is_enabled) {
     id_node->is_enabled_on_eval = is_enabled;
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index 9a7d27808be..735d606ac9e 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -75,7 +75,6 @@ void IDNode::init(const ID *id, const char *UNUSED(subdata))
   has_base = false;
   is_user_modified = false;
   id_cow_recalc_backup = 0;
-  id_invisible_recalc = 0;
 
   visible_components_mask = 0;
   previously_visible_components_mask = 0;
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h
index e9bbc816907..7f0a656cb8d 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.h
+++ b/source/blender/depsgraph/intern/node/deg_node_id.h
@@ -123,9 +123,6 @@ struct IDNode : public Node {
   /* Accumulate recalc flags from multiple update passes. */
   int id_cow_recalc_backup;
 
-  /* Flags which components were not evaluated due to ID being invisible. */
-  int id_invisible_recalc;
-
   IDComponentsMask visible_components_mask;
   IDComponentsMask previously_visible_components_mask;



More information about the Bf-blender-cvs mailing list