Fix: DEG: Image updates are flushed for initial evaluation #115240

Closed
Omar Emara wants to merge 1 commits from OmarEmaraDev:fix-depsgraph-flush-editors into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 17 additions and 10 deletions

View File

@ -40,8 +40,14 @@ static void deg_flush_updates_and_refresh(deg::Depsgraph *deg_graph)
BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->frame);
}
/* This is needed to identify if flushing updates to editors is necessary, since flushing updates
* to editors needn't happen for the initial evaluation when the data-blocks first become
* visible. Store here and pass to deg_graph_flush_updates because the value will get reset in
* graph_tag_ids_for_visible_update. */
const bool is_visibility_update = deg_graph->need_tag_id_on_graph_visibility_update;
deg::graph_tag_ids_for_visible_update(deg_graph);
deg::deg_graph_flush_updates(deg_graph);
deg::deg_graph_flush_updates(deg_graph, is_visibility_update);
deg::deg_evaluate_on_refresh(deg_graph);
}

View File

@ -214,7 +214,9 @@ void flush_engine_data_update(ID *id)
}
/* NOTE: It will also accumulate flags from changed components. */
void flush_editors_id_update(Depsgraph *graph, const DEGEditorUpdateContext *update_ctx)
static void flush_editors_id_update(Depsgraph *graph,
const DEGEditorUpdateContext *update_ctx,
bool is_visibility_update)
{
for (IDNode *id_node : graph->id_nodes) {
if (id_node->custom_flags != ID_STATE_MODIFIED) {
@ -241,11 +243,8 @@ void flush_editors_id_update(Depsgraph *graph, const DEGEditorUpdateContext *upd
/* Inform editors. Only if the data-block is being evaluated a second
* time, to distinguish between user edits and initial evaluation when
* the data-block becomes visible.
*
* TODO: image data-blocks do not use COW, so might not be detected
* correctly. */
if (deg_copy_on_write_is_expanded(id_cow)) {
* the data-block becomes visible. */
if (!is_visibility_update) {
if (graph->is_active && id_node->is_user_modified) {
deg_editors_id_update(update_ctx, id_orig);
@ -343,7 +342,7 @@ void invalidate_tagged_evaluated_data(Depsgraph *graph)
} // namespace
void deg_graph_flush_updates(Depsgraph *graph)
void deg_graph_flush_updates(Depsgraph *graph, bool is_visibility_update)
{
/* Sanity checks. */
BLI_assert(graph != nullptr);
@ -383,7 +382,7 @@ void deg_graph_flush_updates(Depsgraph *graph)
}
}
/* Inform editors about all changes. */
flush_editors_id_update(graph, &update_ctx);
flush_editors_id_update(graph, &update_ctx, is_visibility_update);
/* Reset evaluation result tagged which is tagged for update to some state
* which is obvious to catch. */
invalidate_tagged_evaluated_data(graph);

View File

@ -16,8 +16,10 @@ struct Depsgraph;
/**
* Flush updates from tagged nodes outwards until all affected nodes are tagged.
* The is_visibility_update argument should be true iff the updates are part of the initial
* evaluation when data-blocks becomes visible.
*/
void deg_graph_flush_updates(struct Depsgraph *graph);
void deg_graph_flush_updates(struct Depsgraph *graph, bool is_visibility_update);
/**
* Clear tags from all operation nodes.