Fix: Missing compositor texture node updates

The output of the Texture node in the compositor does not update when
the texture settings or the texture type is adjusted. That's because
texture evaluations are cached, and the cache is not invalidated when
needed.

This happens because we rely on the depsgraph to tag changes to textures
so that the cache is invalidated. The tagging doesn't happen because the
texture ID is actually not part of the depsgraph in some cases. This is
so because the Texture ID property in the node does not update depsgraph
relations when it changed, so the depsgraph is out of sync with the node
tree.

This patch fixes that by invoking a depsgraph relations updates when
ever an ID property used by the compositor is changed.

Pull Request: https://projects.blender.org/blender/blender/pulls/124050
This commit is contained in:
Omar Emara 2024-07-02 17:11:29 +02:00 committed by Omar Emara
parent 9691ff004a
commit 5a56a56435

@ -3041,7 +3041,7 @@ static const EnumPropertyItem *rna_Node_view_layer_itemf(bContext * /*C*/,
static void rna_Node_view_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
rna_Node_update(bmain, scene, ptr);
rna_Node_update_relations(bmain, scene, ptr);
if (scene != nullptr && scene->nodetree != nullptr) {
ntreeCompositUpdateRLayers(scene->nodetree);
}
@ -3129,7 +3129,7 @@ static void rna_Image_Node_update_id(Main *bmain, Scene *scene, PointerRNA *ptr)
bNode *node = static_cast<bNode *>(ptr->data);
blender::bke::nodeTagUpdateID(node);
rna_Node_update(bmain, scene, ptr);
rna_Node_update_relations(bmain, scene, ptr);
}
static void rna_NodeOutputFile_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@ -4512,7 +4512,7 @@ static void def_texture(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Texture", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
prop = RNA_def_property(srna, "node_output", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, nullptr, "custom1");
@ -7089,7 +7089,7 @@ static void def_cmp_defocus(StructRNA *srna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(
prop, "Scene", "Scene from which to select the active camera (render scene if undefined)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
RNA_def_struct_sdna_from(srna, "NodeDefocus", "storage");
@ -7693,7 +7693,7 @@ static void def_cmp_movieclip(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Movie Clip", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
RNA_def_struct_sdna_from(srna, "MovieClipUser", "storage");
}
@ -7708,7 +7708,7 @@ static void def_cmp_stabilize2d(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Movie Clip", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "custom1");
@ -7739,7 +7739,7 @@ static void def_cmp_moviedistortion(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Movie Clip", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
prop = RNA_def_property(srna, "distortion_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "custom1");
@ -7769,6 +7769,7 @@ static void def_cmp_mask(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Mask", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
prop = RNA_def_property(srna, "use_feather", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, nullptr, "custom1", CMP_NODE_MASK_FLAG_NO_FEATHER);
@ -8233,7 +8234,7 @@ static void def_cmp_keyingscreen(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Movie Clip", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
RNA_def_struct_sdna_from(srna, "NodeKeyingScreenData", "storage");
@ -8382,7 +8383,7 @@ static void def_cmp_trackpos(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Movie Clip", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
prop = RNA_def_property(srna, "position", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "custom1");
@ -8476,7 +8477,7 @@ static void def_cmp_planetrackdeform(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Movie Clip", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
RNA_def_struct_sdna_from(srna, "NodePlaneTrackDeformData", "storage");
@ -8618,7 +8619,7 @@ static void def_cmp_cryptomatte(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Scene", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(prop,