From f3428ed9af0e35b8ead593ab1a1f01ebc108149e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 20 Jun 2025 16:01:13 +0200 Subject: [PATCH] Anim: avoid 'unshare' node for custom properties and shapekey values When creating depsgraph relationships for drivers, avoid creating the 'unshare' depsgraph node for drivers on custom properties and on shapekey `value` properties. This should fix a significant part of the performance regression mentioned in #140706. Pull Request: https://projects.blender.org/blender/blender/pulls/140724 --- .../builder/deg_builder_relations_drivers.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc index 6aff7c1bfd2..95f6e3da410 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc @@ -245,12 +245,26 @@ bool data_path_maybe_shared(const ID &id, const StringRef data_path) /* As it is hard to generally detect implicit sharing, this is implemented as * a 'known to not share' list. */ + /* Allow concurrent writes to custom properties. #140706 shows that this + * shouldn't be a problem in practice. */ + if (data_path.startswith("[\"") && data_path.endswith("\"]")) { + return false; + } + if (GS(id.name) == ID_OB) { const Object &ob = *reinterpret_cast(&id); const bool is_thread_safe = (ob.type == OB_ARMATURE && data_path.startswith("pose.bones[")); return !is_thread_safe; } + /* Allow concurrent writes to shapekey values. #140706 shows that this + * shouldn't be a problem in practice. */ + if (GS(id.name) == ID_KE) { + const bool is_thread_safe = data_path.startswith("key_blocks[") && + data_path.endswith("].value"); + return !is_thread_safe; + } + return true; }