

The change could also be done incrementally by falling back to a full copy.

In theory, BKE_gpencil_eval_geometry could also call BKE_gpencil_modifiers_calc and make sure the modifiers are evaluated. This does require some refactoring in all the operators etc. GP_LAYER_RECALC, GP_FRAME_RECALC and GP_STROKE_RECALC) that would be set before calling DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY) and be reset in BKE_gpencil_eval_geometry. We suggest to add a flag for the layers, frames and strokes (e.g. This function would iterate through the original data and check what needs to be updated (so loop over the layers, then frames, then strokes), and then copy the original to the evaluated data.

Instead of BKE_gpencil_frame_active_set(.) we would call a new BKE_gpencil_eval_geometry function. Next we modify the function that is called in blender/source/blender/depsgraph/intern/builder/deg_builder_ in build_object_data_geometry_datablock. Basically, it needs to return false in case we don't want to duplicate the whole object and do the update manually. In this approach, this is done by modifying how the Geometr圜omponentNode defines the bool need_tag_cow_before_update() for grease pencil objects. The first step is to avoid triggering the copy-on-write. We've experimented with a few approaches but the following seemed to be the least unstable and most promising. ApproachĪt a high level, the idea is simple: Don't update what doesn't need to be updated. In graph_id_tag_update(.), this will cause a call to depsgraph_id_tag_copy_on_write(.) triggering the copy-on-write on the next graph update. This node has a function bool need_tag_cow_before_update() which will always return true for grease pencil objects (more specifically for grease pencil id types ID_GD). This tag translates to a Geometr圜omponentNode in the dependency graph. This means that the entire object (including all layers, all frames, all the strokes and points) is duplicated, causing major performance issues on heavier scenes (see #91945).Īfter some operation has been done, the grease pencil data is tagged using DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY).

For a majority of operations (like deleting a frame, moving a single point or drawing a new stroke) the system triggers a copy-on-write update.
