[Bf-blender-cvs] [0153e99780a] master: Geometry Nodes: refactor logging during geometry nodes evaluation

Jacques Lucke noreply at git.blender.org
Wed Jul 7 11:21:09 CEST 2021


Commit: 0153e99780aef64913dfd4c323984874bf688249
Author: Jacques Lucke
Date:   Wed Jul 7 11:20:19 2021 +0200
Branches: master
https://developer.blender.org/rB0153e99780aef64913dfd4c323984874bf688249

Geometry Nodes: refactor logging during geometry nodes evaluation

Many ui features for geometry nodes need access to information generated
during evaluation:
* Node warnings.
* Attribute search.
* Viewer node.
* Socket inspection (not in master yet).

The way we logged the required information before had some disadvantages:
* Viewer node used a completely separate system from node warnings and
  attribute search.
* Most of the context of logged information is lost when e.g. the same node
  group is used multiple times.
* A global lock was needed every time something is logged.

This new implementation solves these problems:
* All four mentioned ui features use the same underlying logging system.
* All context information for logged values is kept intact.
* Every thread has its own local logger. The logged informatiton is combined
  in the end.

Differential Revision: https://developer.blender.org/D11785

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

D	source/blender/blenkernel/BKE_node_ui_storage.hh
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/node.cc
D	source/blender/blenkernel/intern/node_ui_storage.cc
M	source/blender/blenkernel/intern/object.c
M	source/blender/editors/space_node/CMakeLists.txt
M	source/blender/editors/space_node/node_draw.cc
M	source/blender/editors/space_node/node_geometry_attribute_search.cc
M	source/blender/editors/space_spreadsheet/CMakeLists.txt
M	source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/modifiers/intern/MOD_nodes.cc
M	source/blender/modifiers/intern/MOD_nodes_evaluator.cc
M	source/blender/modifiers/intern/MOD_nodes_evaluator.hh
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_geometry_exec.hh
A	source/blender/nodes/NOD_geometry_nodes_eval_log.hh
A	source/blender/nodes/intern/geometry_nodes_eval_log.cc
M	source/blender/nodes/intern/node_geometry_exec.cc

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

diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh b/source/blender/blenkernel/BKE_node_ui_storage.hh
deleted file mode 100644
index 4ec165aad8c..00000000000
--- a/source/blender/blenkernel/BKE_node_ui_storage.hh
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#include <mutex>
-
-#include "BLI_hash.hh"
-#include "BLI_map.hh"
-#include "BLI_session_uuid.h"
-#include "BLI_set.hh"
-
-#include "DNA_ID.h"
-#include "DNA_customdata_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_session_uuid_types.h"
-
-#include "BKE_attribute.h"
-
-struct ModifierData;
-struct Object;
-struct bNode;
-struct bNodeTree;
-struct bContext;
-
-/**
- * Contains the context necessary to determine when to display settings for a certain node tree
- * that may be used for multiple modifiers and objects. The object name and modifier session UUID
- * are used instead of pointers because they are re-allocated between evaluations.
- *
- * \note This does not yet handle the context of nested node trees.
- */
-class NodeTreeEvaluationContext {
- private:
-  std::string object_name_;
-  SessionUUID modifier_session_uuid_;
-
- public:
-  NodeTreeEvaluationContext(const Object &object, const ModifierData &modifier)
-  {
-    object_name_ = reinterpret_cast<const ID &>(object).name;
-    modifier_session_uuid_ = modifier.session_uuid;
-  }
-
-  uint64_t hash() const
-  {
-    return blender::get_default_hash_2(object_name_, modifier_session_uuid_);
-  }
-
-  friend bool operator==(const NodeTreeEvaluationContext &a, const NodeTreeEvaluationContext &b)
-  {
-    return a.object_name_ == b.object_name_ &&
-           BLI_session_uuid_is_equal(&a.modifier_session_uuid_, &b.modifier_session_uuid_);
-  }
-};
-
-enum class NodeWarningType {
-  Error,
-  Warning,
-  Info,
-};
-
-struct NodeWarning {
-  NodeWarningType type;
-  std::string message;
-};
-
-struct AvailableAttributeInfo {
-  std::string name;
-  AttributeDomain domain;
-  CustomDataType data_type;
-
-  uint64_t hash() const
-  {
-    return blender::get_default_hash(name);
-  }
-
-  friend bool operator==(const AvailableAttributeInfo &a, const AvailableAttributeInfo &b)
-  {
-    return a.name == b.name;
-  }
-};
-
-struct NodeUIStorage {
-  blender::Vector<NodeWarning> warnings;
-  blender::Set<AvailableAttributeInfo> attribute_hints;
-};
-
-struct NodeTreeUIStorage {
-  std::mutex mutex;
-  blender::Map<NodeTreeEvaluationContext, blender::Map<std::string, NodeUIStorage>> context_map;
-
-  /**
-   * Attribute search uses this to store the fake info for the string typed into a node, in order
-   * to pass the info to the execute callback that sets node socket values. This is mutable since
-   * we can count on only one attribute search being open at a time, and there is no real data
-   * stored here.
-   */
-  mutable AvailableAttributeInfo dummy_info_for_search;
-};
-
-const NodeUIStorage *BKE_node_tree_ui_storage_get_from_context(const bContext *C,
-                                                               const bNodeTree &ntree,
-                                                               const bNode &node);
-
-void BKE_nodetree_ui_storage_free_for_context(bNodeTree &ntree,
-                                              const NodeTreeEvaluationContext &context);
-
-void BKE_nodetree_error_message_add(bNodeTree &ntree,
-                                    const NodeTreeEvaluationContext &context,
-                                    const bNode &node,
-                                    const NodeWarningType type,
-                                    std::string message);
-
-void BKE_nodetree_attribute_hint_add(bNodeTree &ntree,
-                                     const NodeTreeEvaluationContext &context,
-                                     const bNode &node,
-                                     const blender::StringRef attribute_name,
-                                     const AttributeDomain domain,
-                                     const CustomDataType data_type);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index cd66f026828..4724e6dfab6 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -70,10 +70,6 @@ void BKE_object_free_curve_cache(struct Object *ob);
 void BKE_object_free_derived_caches(struct Object *ob);
 void BKE_object_free_caches(struct Object *object);
 
-void BKE_object_preview_geometry_set_add(struct Object *ob,
-                                         const uint64_t key,
-                                         struct GeometrySet *geometry_set);
-
 void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd);
 void BKE_object_modifier_gpencil_hook_reset(struct Object *ob,
                                             struct HookGpencilModifierData *hmd);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 1db23002c1e..f14396f152e 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -215,7 +215,6 @@ set(SRC
   intern/multires_versioning.c
   intern/nla.c
   intern/node.cc
-  intern/node_ui_storage.cc
   intern/object.c
   intern/object_deform.c
   intern/object_dupli.cc
@@ -399,7 +398,6 @@ set(SRC
   BKE_multires.h
   BKE_nla.h
   BKE_node.h
-  BKE_node_ui_storage.hh
   BKE_object.h
   BKE_object_deform.h
   BKE_object_facemap.h
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 66ddfcf6127..5bed5b1aaad 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -69,7 +69,6 @@
 #include "BKE_lib_query.h"
 #include "BKE_main.h"
 #include "BKE_node.h"
-#include "BKE_node_ui_storage.hh"
 
 #include "BLI_ghash.h"
 #include "BLI_threads.h"
@@ -220,10 +219,6 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
 
   /* node tree will generate its own interface type */
   ntree_dst->interface_type = nullptr;
-
-  /* Don't copy error messages in the runtime struct.
-   * They should be filled during execution anyway. */
-  ntree_dst->ui_storage = nullptr;
 }
 
 static void ntree_free_data(ID *id)
@@ -277,8 +272,6 @@ static void ntree_free_data(ID *id)
   if (ntree->id.tag & LIB_TAG_LOCALIZED) {
     BKE_libblock_free_data(&ntree->id, true);
   }
-
-  delete ntree->ui_storage;
 }
 
 static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket *sock)
@@ -621,7 +614,6 @@ static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_addres
     ntree->interface_type = nullptr;
     ntree->progress = nullptr;
     ntree->execdata = nullptr;
-    ntree->ui_storage = nullptr;
 
     BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id);
 
@@ -653,7 +645,6 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
 
   ntree->progress = nullptr;
   ntree->execdata = nullptr;
-  ntree->ui_storage = nullptr;
 
   BLO_read_data_address(reader, &ntree->adt);
   BKE_animdata_blend_read_data(reader, ntree->adt);
diff --git a/source/blender/blenkernel/intern/node_ui_storage.cc b/source/blender/blenkernel/intern/node_ui_storage.cc
deleted file mode 100644
index e5e9f00c7c3..00000000000
--- a/source/blender/blenkernel/intern/node_ui_storage.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "CLG_log.h"
-
-#include <mutex>
-
-#include "BLI_map.hh"
-#include "BLI_string_ref.hh"
-#include "BLI_vector.hh"
-
-#include "DNA_node_types.h"
-#include "DNA_object_types.h"
-
-#include "BKE_context.h"
-#include "BKE_node_ui_storage.hh"
-#include "BKE_object.h"
-
-static CLG_LogRef LOG = {"bke.node_ui_storage"};
-
-using blender::Map;
-using blender::StringRef;
-using blender::Vector;
-
-/* Use a global mutex because otherwise it would have to be stored directly in the
- * bNodeTree struct in DNA. This could change if the node tree had a runtime struct. */
-static std::mutex global_ui_storage_mutex;
-
-static NodeTreeUIStorage &ui_storage_ensure(bNodeTree &ntree)
-{
-  /* As an optimization, only acquire a lock if the UI storage doesn't exist,
-   * because it only needs to be allocated once for every node tree. */
-  if (ntree.ui_storage == nullptr) {
-    std::lock_guard<std::mutex> lock(global_ui_storage_mutex);
-    /* Check again-- another thread may have allocated the storage while this one waited. */
-    if (ntree.ui_storage == nullptr) {
-      ntree.ui_storage = new NodeTreeUIStorage();
-    }
-  }
-  return *ntree.ui_storage;
-}
-
-const NodeUIStorage *BKE_node_tree_ui_storage_get_from_context(const bContext *C,
-                                                               const bNodeTree &ntree,
-                                                       

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list