diff options
author | Sergey Sharybin <sergey@blender.org> | 2022-08-30 17:54:17 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-08-31 16:11:18 +0300 |
commit | ac20970bc208aef6257b16e129f08dcbe892869d (patch) | |
tree | 467f47604378424240577b9af2f500075efc9abd | |
parent | 5a1b733a67e35c4a6d043197b3a88fa178225869 (diff) |
Depsgraph: optimize out evaluation of hidden objects
This change makes it so that objects which are temporary hidden from
the viewport (the icon toggle in outliner) do not affect on the
performance of the viewport.
The attached file demonstrates the issue. Before this change hiding
the object does not change FPS, after this change FPS goes high when
the object is hidden.
F13435936
Changing the object temporary visibility is already expected to tag
scene for bases updates, which flushes down the stream to the object
visibility update. So the only remaining topic was to ensure the
graph does a special round of visibility update on such changes.
Differential Revision: https://developer.blender.org/D15813
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_flush.cc | 4 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_visibility.cc | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 09981eb32c5..30ee626f0f8 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -371,6 +371,10 @@ 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 a056ba1dfa7..e35e992fc8b 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc @@ -34,10 +34,14 @@ void deg_evaluate_object_node_visibility(::Depsgraph *depsgraph, IDNode *id_node DEG_debug_print_eval(depsgraph, __func__, object->id.name, &object->id); - const int required_flags = (graph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT : - BASE_ENABLED_RENDER; - - const bool is_enabled = object->base_flag & required_flags; + bool is_enabled; + if (graph->mode == DAG_EVAL_VIEWPORT) { + is_enabled = (object->base_flag & BASE_ENABLED_VIEWPORT) && + ((object->base_flag & BASE_HIDDEN) == 0); + } + else { + is_enabled = (object->base_flag & BASE_ENABLED_RENDER); + }; if (id_node->is_enabled_on_eval != is_enabled) { id_node->is_enabled_on_eval = is_enabled; |