[Bf-blender-cvs] [00812008129] master: Functions: remove multi-function network

Jacques Lucke noreply at git.blender.org
Fri Aug 20 13:21:17 CEST 2021


Commit: 00812008129bdab48d328775b09332af12118867
Author: Jacques Lucke
Date:   Fri Aug 20 13:14:39 2021 +0200
Branches: master
https://developer.blender.org/rB00812008129bdab48d328775b09332af12118867

Functions: remove multi-function network

The multi-function network system was able to compose multiple
multi-functions into a new one and to evaluate that efficiently.
This functionality was heavily used by the particle nodes prototype
a year ago. However, since then we only used multi-functions
without the need to compose them in geometry nodes.

The upcoming "fields" in geometry nodes will need a way to
compose multi-functions again. Unfortunately, the code removed
in this commit was not ideal for this different kind of function
composition. I've been working on an alternative that will be added
separately when it becomes needed.

I've had to update all the function nodes, because their interface
depended on the multi-function network data structure a bit.
The actual multi-function implementations are still the same though.

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

M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/simulation.cc
M	source/blender/functions/CMakeLists.txt
M	source/blender/functions/FN_generic_virtual_array.hh
D	source/blender/functions/FN_multi_function_network.hh
D	source/blender/functions/FN_multi_function_network_evaluation.hh
D	source/blender/functions/FN_multi_function_network_optimization.hh
M	source/blender/functions/FN_multi_function_signature.hh
D	source/blender/functions/intern/multi_function_network.cc
D	source/blender/functions/intern/multi_function_network_evaluation.cc
D	source/blender/functions/intern/multi_function_network_optimization.cc
D	source/blender/functions/tests/FN_multi_function_network_test.cc
M	source/blender/functions/tests/FN_multi_function_test.cc
A	source/blender/functions/tests/FN_multi_function_test_common.hh
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
A	source/blender/nodes/NOD_multi_function.hh
D	source/blender/nodes/NOD_node_tree_multi_function.hh
M	source/blender/nodes/function/node_function_util.hh
M	source/blender/nodes/function/nodes/node_fn_boolean_math.cc
M	source/blender/nodes/function/nodes/node_fn_float_compare.cc
M	source/blender/nodes/function/nodes/node_fn_float_to_int.cc
M	source/blender/nodes/function/nodes/node_fn_input_string.cc
M	source/blender/nodes/function/nodes/node_fn_input_vector.cc
M	source/blender/nodes/function/nodes/node_fn_random_float.cc
M	source/blender/nodes/intern/node_geometry_exec.cc
R053	source/blender/nodes/NOD_type_callbacks.hh	source/blender/nodes/intern/node_multi_function.cc
M	source/blender/nodes/intern/node_socket.cc
D	source/blender/nodes/intern/node_tree_multi_function.cc
D	source/blender/nodes/intern/type_callbacks.cc
M	source/blender/nodes/shader/node_shader_util.h
M	source/blender/nodes/shader/nodes/node_shader_clamp.cc
M	source/blender/nodes/shader/nodes/node_shader_curves.cc
M	source/blender/nodes/shader/nodes/node_shader_map_range.cc
M	source/blender/nodes/shader/nodes/node_shader_math.cc
M	source/blender/nodes/shader/nodes/node_shader_mixRgb.cc
M	source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
M	source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
M	source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
M	source/blender/nodes/shader/nodes/node_shader_value.cc
M	source/blender/nodes/shader/nodes/node_shader_vector_math.cc
M	source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc

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

diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index caa7ab6de0a..c4393246926 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -111,8 +111,7 @@ typedef struct bNodeSocketTemplate {
 #ifdef __cplusplus
 namespace blender {
 namespace nodes {
-class SocketMFNetworkBuilder;
-class NodeMFNetworkBuilder;
+class NodeMultiFunctionBuilder;
 class GeoNodeExecParams;
 }  // namespace nodes
 namespace fn {
@@ -121,18 +120,16 @@ class MFDataType;
 }  // namespace fn
 }  // namespace blender
 
-using NodeExpandInMFNetworkFunction = void (*)(blender::nodes::NodeMFNetworkBuilder &builder);
+using NodeMultiFunctionBuildFunction = void (*)(blender::nodes::NodeMultiFunctionBuilder &builder);
 using NodeGeometryExecFunction = void (*)(blender::nodes::GeoNodeExecParams params);
 using SocketGetCPPTypeFunction = const blender::fn::CPPType *(*)();
 using SocketGetCPPValueFunction = void (*)(const struct bNodeSocket &socket, void *r_value);
 using SocketGetGeometryNodesCPPTypeFunction = const blender::fn::CPPType *(*)();
 using SocketGetGeometryNodesCPPValueFunction = void (*)(const struct bNodeSocket &socket,
                                                         void *r_value);
-using SocketExpandInMFNetworkFunction = void (*)(blender::nodes::SocketMFNetworkBuilder &builder);
 
 #else
-typedef void *NodeExpandInMFNetworkFunction;
-typedef void *SocketExpandInMFNetworkFunction;
+typedef void *NodeMultiFunctionBuildFunction;
 typedef void *NodeGeometryExecFunction;
 typedef void *SocketGetCPPTypeFunction;
 typedef void *SocketGetGeometryNodesCPPTypeFunction;
@@ -196,8 +193,6 @@ typedef struct bNodeSocketType {
   /* Callback to free the socket type. */
   void (*free_self)(struct bNodeSocketType *stype);
 
-  /* Expands the socket into a multi-function node that outputs the socket value. */
-  SocketExpandInMFNetworkFunction expand_in_mf_network;
   /* Return the CPPType of this socket. */
   SocketGetCPPTypeFunction get_base_cpp_type;
   /* Get the value of this socket in a generic way. */
@@ -332,8 +327,8 @@ typedef struct bNodeType {
   /* gpu */
   NodeGPUExecFunction gpu_fn;
 
-  /* Expands the bNode into nodes in a multi-function network, which will be evaluated later on. */
-  NodeExpandInMFNetworkFunction expand_in_mf_network;
+  /* Build a multi-function for this node. */
+  NodeMultiFunctionBuildFunction build_multi_function;
 
   /* Execute a geometry node. */
   NodeGeometryExecFunction geometry_node_execute;
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index 5aac29c19a7..4c97ccdf8b1 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -49,14 +49,10 @@
 #include "BKE_simulation.h"
 
 #include "NOD_geometry.h"
-#include "NOD_node_tree_multi_function.hh"
 
 #include "BLI_map.hh"
 #include "BLT_translation.h"
 
-#include "FN_multi_function_network_evaluation.hh"
-#include "FN_multi_function_network_optimization.hh"
-
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_query.h"
 
diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index 809294ad274..f8d2acc74a8 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -33,9 +33,6 @@ set(SRC
   intern/generic_virtual_vector_array.cc
   intern/multi_function.cc
   intern/multi_function_builder.cc
-  intern/multi_function_network.cc
-  intern/multi_function_network_evaluation.cc
-  intern/multi_function_network_optimization.cc
 
   FN_cpp_type.hh
   FN_cpp_type_make.hh
@@ -49,9 +46,6 @@ set(SRC
   FN_multi_function_builder.hh
   FN_multi_function_context.hh
   FN_multi_function_data_type.hh
-  FN_multi_function_network.hh
-  FN_multi_function_network_evaluation.hh
-  FN_multi_function_network_optimization.hh
   FN_multi_function_param_type.hh
   FN_multi_function_params.hh
   FN_multi_function_signature.hh
@@ -68,7 +62,6 @@ if(WITH_GTESTS)
     tests/FN_cpp_type_test.cc
     tests/FN_generic_span_test.cc
     tests/FN_generic_vector_array_test.cc
-    tests/FN_multi_function_network_test.cc
     tests/FN_multi_function_test.cc
   )
   set(TEST_LIB
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index c9398ceb547..f429243e2de 100644
--- a/source/blender/functions/FN_generic_virtual_array.hh
+++ b/source/blender/functions/FN_generic_virtual_array.hh
@@ -129,7 +129,7 @@ class GVArray {
   }
 
   /* Same as `get_internal_single`, but `r_value` points to initialized memory. */
-  void get_single_to_uninitialized(void *r_value) const
+  void get_internal_single_to_uninitialized(void *r_value) const
   {
     type_->default_construct(r_value);
     this->get_internal_single(r_value);
diff --git a/source/blender/functions/FN_multi_function_network.hh b/source/blender/functions/FN_multi_function_network.hh
deleted file mode 100644
index b303589106a..00000000000
--- a/source/blender/functions/FN_multi_function_network.hh
+++ /dev/null
@@ -1,536 +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
-
-/** \file
- * \ingroup fn
- *
- * A multi-function network (`MFNetwork`) allows you to connect multiple multi-functions. The
- * `MFNetworkEvaluator` is a multi-function that wraps an entire network into a new multi-function
- * (which can be used in another network and so on).
- *
- * A MFNetwork is a graph data structure with two kinds of nodes:
- * - MFFunctionNode: Represents a multi-function. Its input and output sockets correspond to
- *       parameters of the referenced multi-function.
- * - MFDummyNode: Does not reference a multi-function. Instead it just has sockets that can be
- *       used to represent node group inputs and outputs.
- *
- * Links represent data flow. Unlinked input sockets have no value. In order to execute a function
- * node, all its inputs have to be connected to something.
- *
- * Links are only allowed between sockets with the exact same MFDataType. There are no implicit
- * conversions.
- *
- * Every input and output parameter of a multi-function corresponds to exactly one input or output
- * socket respectively. A multiple parameter belongs to exactly one input AND one output socket.
- *
- * There is an .to_dot() method that generates a graph in dot format for debugging purposes.
- */
-
-#include "FN_multi_function.hh"
-
-#include "BLI_vector_set.hh"
-
-namespace blender::fn {
-
-class MFNode;
-class MFFunctionNode;
-class MFDummyNode;
-class MFSocket;
-class MFInputSocket;
-class MFOutputSocket;
-class MFNetwork;
-
-class MFNode : NonCopyable, NonMovable {
- protected:
-  MFNetwork *network_;
-  Span<MFInputSocket *> inputs_;
-  Span<MFOutputSocket *> outputs_;
-  bool is_dummy_;
-  int id_;
-
-  friend MFNetwork;
-
- public:
-  StringRefNull name() const;
-
-  int id() const;
-
-  MFNetwork &network();
-  const MFNetwork &network() const;
-
-  bool is_dummy() const;
-  bool is_function() const;
-
-  MFDummyNode &as_dummy();
-  const MFDummyNode &as_dummy() const;
-
-  MFFunctionNode &as_function();
-  const MFFunctionNode &as_function() const;
-
-  MFInputSocket &input(int index);
-  const MFInputSocket &input(int index) const;
-
-  MFOutputSocket &output(int index);
-  const MFOutputSocket &output(int index) const;
-
-  Span<MFInputSocket *> inputs();
-  Span<const MFInputSocket *> inputs() const;
-
-  Span<MFOutputSocket *> outputs();
-  Span<const MFOutputSocket *> outputs() const;
-
-  bool has_unlinked_inputs() const;
-
- private:
-  void destruct_sockets();
-};
-
-class MFFunctionNode : public MFNode {
- private:
-  const MultiFunction *function_;
-  Span<int> input_param_indices_;
-  Span<int> output_param_indices_;
-
-  friend MFNetwork;
-
- public:
-  StringRefNull name() const;
-
-  const MultiFunction &function() const;
-
-  const MFInputSocket &input_for_param(int param_index) const;
-  const MFOutputSocket &output_for_param(int param_index) const;
-};
-
-class MFDummyNode : public MFNode {
- protected:
-  StringRefNull name_;
-  MutableSpan<StringRefNull> input_names_;
-  MutableSpan<StringRefNull> output_names_;
-
-  friend MFNetwork;
-
- public:
-  StringRefNull name() const;
-
-  Span<StringRefNull> input_names() const;
-  Span<StringRefNull> output_names() const;
-};
-
-class MFSocket : NonCopyable, NonMovable {
- protected:
-  MFNode *node_;
-  bool is_output_;
-  int index_;
-  MFDataType data_type_;
-  int id_;
-  StringRefNull name_;
-
-  friend MFNetwork;
-
- public:
-  StringRefNull name() const;
-
-  int id() const;
-  int index() const;
-
-  const MFDataType &data_type() const;
-
-  MFNode &node();
-  const MFNode &node() const;
-
-  bool is_input() const;
-  bool is_output() const;
-
-  MFInputSocket &as_input();
-  const MFInputSocket &as_input() const;
-
-  MFOutputSocket &as_output();
-  const MFOutputSocket &as_output() const;
-};
-
-class MFInputSocket : public MFSocket {
- private:
-  MFOutputSocket *origin_;
-
-  friend MFNetwork;
-
- public:
-  MFOutputSocket *origin();
-  const MFOutputSocket *origin() const;
-};
-
-class MFOutputSocket : public MFSocket {
- private:
-  Vector<MFInputSocket *, 1> targets_;
-
-  friend MFNetwork;
-
- public:
-  Span<MFInputSocket *> targets();
-  Span<const MFInputSocket *> targets() const;
-};
-
-class MFNetwork : NonCopyable, NonMovable {
- private:
-  LinearAllocator<> allocator_;
-
-  VectorSet<MFFunctionNode *> function_nodes_;
-  VectorSet<MFDummy

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list