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.
This commit is contained in:
Sergey Sharybin 2022-09-13 15:56:54 +02:00
parent 8442b0ffc1
commit 109cc14dba
7 changed files with 4 additions and 41 deletions

View File

@ -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;

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;