[Bf-blender-cvs] [51568030e9c] master: Depsgraph: remove redundant mesh data duplication in edit-mode

Campbell Barton noreply at git.blender.org
Thu Jun 24 12:25:13 CEST 2021


Commit: 51568030e9c833da867c8d80c72b2eca2f591477
Author: Campbell Barton
Date:   Thu Jun 24 19:18:53 2021 +1000
Branches: master
https://developer.blender.org/rB51568030e9c833da867c8d80c72b2eca2f591477

Depsgraph: remove redundant mesh data duplication in edit-mode

This resolves a bottleneck where every update while transforming
copied the entire mesh data-block, which isn't needed as the edit-mesh
is the source of the data being edited.

Testing shows a significant overall speedup when transforming:

- ~1.5x with a subdivided cube 1.5 million vertices.
- ~3.0x with the spring mesh (edit-mode with modifiers disabled,
  duplicated 10x to drop performance).

Reviewed By: sergey

Ref D11337

===================================================================

M	source/blender/depsgraph/intern/node/deg_node_component.h

===================================================================

diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h
index a7c69b27654..965022823d3 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.h
+++ b/source/blender/depsgraph/intern/node/deg_node_component.h
@@ -31,6 +31,10 @@
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
 
+#include "BKE_object.h"
+
+#include "DNA_object_types.h"
+
 struct ID;
 struct bPoseChannel;
 
@@ -158,6 +162,23 @@ struct ComponentNode : public Node {
     DEG_COMPONENT_NODE_DECLARE; \
   }
 
+/* When updating object data in edit-mode, don't request COW update since this will duplicate
+ * all object data which is unnecessary when the edit-mode data is used for calculating modifiers.
+ *
+ * TODO: Investigate modes besides edit-mode. */
+#define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_OBDATA_IN_EDIT_MODE(name) \
+  struct name##ComponentNode : public ComponentNode { \
+    DEG_COMPONENT_NODE_DECLARE; \
+    virtual bool need_tag_cow_before_update() override \
+    { \
+      if (OB_DATA_SUPPORT_EDITMODE(owner->id_type) && \
+          BKE_object_data_is_in_editmode(owner->id_orig)) { \
+        return false; \
+      } \
+      return true; \
+    } \
+  }
+
 #define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \
   struct name##ComponentNode : public ComponentNode { \
     DEG_COMPONENT_NODE_DECLARE; \
@@ -171,7 +192,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation);
 DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Cache);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(CopyOnWrite);
-DEG_COMPONENT_NODE_DECLARE_GENERIC(Geometry);
+DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_OBDATA_IN_EDIT_MODE(Geometry);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(ImageAnimation);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(LayerCollections);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles);



More information about the Bf-blender-cvs mailing list