[Bf-blender-cvs] [98577ce2b29] functions-experimental-refactor: initial non recursive multi-function evaluator

Jacques Lucke noreply at git.blender.org
Wed Oct 30 14:01:10 CET 2019


Commit: 98577ce2b29fcc9887d4e37c4359ea6e56c6c8aa
Author: Jacques Lucke
Date:   Wed Oct 30 14:01:00 2019 +0100
Branches: functions-experimental-refactor
https://developer.blender.org/rB98577ce2b29fcc9887d4e37c4359ea6e56c6c8aa

initial non recursive multi-function evaluator

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

M	source/blender/blenkernel/BKE_generic_array_ref.h
M	source/blender/blenkernel/BKE_generic_vector_array.h
M	source/blender/blenkernel/BKE_generic_virtual_list_list_ref.h
M	source/blender/blenkernel/BKE_generic_virtual_list_ref.h
M	source/blender/blenkernel/BKE_multi_function.h
M	source/blender/blenkernel/BKE_multi_function_network.h
M	source/blender/blenkernel/intern/multi_function_network.cc
M	source/blender/modifiers/intern/MOD_functiondeform_cxx.cc

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

diff --git a/source/blender/blenkernel/BKE_generic_array_ref.h b/source/blender/blenkernel/BKE_generic_array_ref.h
index 8d4372bf56e..408f05738a3 100644
--- a/source/blender/blenkernel/BKE_generic_array_ref.h
+++ b/source/blender/blenkernel/BKE_generic_array_ref.h
@@ -64,22 +64,26 @@ class GenericMutableArrayRef {
   uint m_size;
 
  public:
-  GenericMutableArrayRef(const CPPType *type) : GenericMutableArrayRef(type, nullptr, 0)
+  GenericMutableArrayRef(const CPPType &type) : GenericMutableArrayRef(type, nullptr, 0)
   {
   }
 
-  GenericMutableArrayRef(const CPPType *type, void *buffer, uint size)
-      : m_type(type), m_buffer(buffer), m_size(size)
+  GenericMutableArrayRef(const CPPType &type, void *buffer, uint size)
+      : m_type(&type), m_buffer(buffer), m_size(size)
   {
-    BLI_assert(type != nullptr);
     BLI_assert(buffer != nullptr || size == 0);
-    BLI_assert(type->pointer_has_valid_alignment(buffer));
+    BLI_assert(type.pointer_has_valid_alignment(buffer));
   }
 
   template<typename T>
   GenericMutableArrayRef(ArrayRef<T> array)
-      : GenericMutableArrayRef(&GET_TYPE<T>(), (void *)array.begin(), array.size())
+      : GenericMutableArrayRef(GET_TYPE<T>(), (void *)array.begin(), array.size())
+  {
+  }
+
+  operator GenericArrayRef() const
   {
+    return GenericArrayRef(*m_type, m_buffer, m_size);
   }
 
   void destruct_all()
diff --git a/source/blender/blenkernel/BKE_generic_vector_array.h b/source/blender/blenkernel/BKE_generic_vector_array.h
index 4c4a07ad584..5a8d6ed2249 100644
--- a/source/blender/blenkernel/BKE_generic_vector_array.h
+++ b/source/blender/blenkernel/BKE_generic_vector_array.h
@@ -55,6 +55,11 @@ class GenericVectorArray : BLI::NonCopyable, BLI::NonMovable {
     m_slices_allocator.deallocate((void *)m_capacities);
   }
 
+  operator GenericVirtualListListRef() const
+  {
+    return GenericVirtualListListRef::FromFullArrayList(m_type, m_starts, m_lengths, m_array_size);
+  }
+
   uint size() const
   {
     return m_array_size;
@@ -93,6 +98,12 @@ class GenericVectorArray : BLI::NonCopyable, BLI::NonMovable {
     }
   }
 
+  GenericArrayRef operator[](uint index) const
+  {
+    BLI_assert(index < m_array_size);
+    return GenericArrayRef(m_type, m_starts[index], m_lengths[index]);
+  }
+
   template<typename T> class TypedRef {
    private:
     const GenericVectorArray *m_data;
diff --git a/source/blender/blenkernel/BKE_generic_virtual_list_list_ref.h b/source/blender/blenkernel/BKE_generic_virtual_list_list_ref.h
index abe5483afc2..c000be2f9d3 100644
--- a/source/blender/blenkernel/BKE_generic_virtual_list_list_ref.h
+++ b/source/blender/blenkernel/BKE_generic_virtual_list_list_ref.h
@@ -71,6 +71,11 @@ class GenericVirtualListListRef {
         type, starts.begin(), array_sizes.begin(), starts.size());
   }
 
+  uint size() const
+  {
+    return m_virtual_list_size;
+  }
+
   GenericVirtualListRef operator[](uint index) const
   {
     BLI_assert(index < m_virtual_list_size);
diff --git a/source/blender/blenkernel/BKE_generic_virtual_list_ref.h b/source/blender/blenkernel/BKE_generic_virtual_list_ref.h
index 0acd74e0462..b9b5b2cdced 100644
--- a/source/blender/blenkernel/BKE_generic_virtual_list_ref.h
+++ b/source/blender/blenkernel/BKE_generic_virtual_list_ref.h
@@ -2,6 +2,7 @@
 #define __BKE_GENERIC_VIRTUAL_LIST_REF_H__
 
 #include "BKE_cpp_types.h"
+#include "BKE_generic_array_ref.h"
 
 #include "BLI_virtual_list_ref.h"
 
@@ -46,6 +47,19 @@ class GenericVirtualListRef {
     m_data.full_array.data = nullptr;
   }
 
+  GenericVirtualListRef(GenericArrayRef array)
+  {
+    m_virtual_size = array.size();
+    m_type = &array.type();
+    m_category = FullArray;
+    m_data.full_array.data = array.buffer();
+  }
+
+  GenericVirtualListRef(GenericMutableArrayRef array)
+      : GenericVirtualListRef(GenericArrayRef(array))
+  {
+  }
+
   static GenericVirtualListRef FromSingle(const CPPType &type,
                                           const void *buffer,
                                           uint virtual_size)
diff --git a/source/blender/blenkernel/BKE_multi_function.h b/source/blender/blenkernel/BKE_multi_function.h
index a3898ef782a..5184d75b35a 100644
--- a/source/blender/blenkernel/BKE_multi_function.h
+++ b/source/blender/blenkernel/BKE_multi_function.h
@@ -110,6 +110,11 @@ struct MFParamType {
     return m_category == ReadonlyVectorInput;
   }
 
+  bool is_mutable_vector() const
+  {
+    return m_category == MutableVector;
+  }
+
   bool is_single_output() const
   {
     return m_category == SingleOutput;
@@ -484,52 +489,52 @@ class MFParamsBuilder {
     m_vector_arrays.clear();
   }
 
-  template<typename T> void add_readonly_array_ref(ArrayRef<T> array)
+  template<typename T> void add_readonly_single_input(ArrayRef<T> array)
   {
     BLI_assert(array.size() >= m_min_array_size);
     m_virtual_list_refs.append(GenericVirtualListRef::FromFullArray<T>(array));
   }
 
-  template<typename T> void add_readonly_single_ref(const T *value)
+  template<typename T> void add_readonly_single_input(const T *value)
   {
     m_virtual_list_refs.append(
         GenericVirtualListRef::FromSingle(GET_TYPE<T>(), (void *)value, m_min_array_size));
   }
 
-  void add_readonly_array_ref(GenericMutableArrayRef array)
+  void add_readonly_single_input(GenericVirtualListRef list)
   {
-    BLI_assert(array.size() >= m_min_array_size);
-    m_virtual_list_refs.append(
-        GenericVirtualListRef::FromFullArray(array.type(), array.buffer(), array.size()));
+    BLI_assert(list.size() >= m_min_array_size);
+    m_virtual_list_refs.append(list);
   }
 
-  void add_readonly_single_ref(TupleRef tuple, uint index)
+  void add_readonly_vector_input(GenericVirtualListListRef list)
   {
-    m_virtual_list_refs.append(GenericVirtualListRef::FromSingle(
-        tuple.info().type_at_index(index), tuple.element_ptr(index), m_min_array_size));
+    BLI_assert(list.size() >= m_min_array_size);
+    m_virtual_list_list_refs.append(list);
   }
 
-  void add_readonly_vector_array_ref(const GenericVectorArray &vector_array)
+  void add_single_output(GenericMutableArrayRef array)
   {
-    m_virtual_list_list_refs.append(GenericVirtualListListRef::FromFullArrayList(
-        vector_array.type(), vector_array.starts(), vector_array.lengths(), vector_array.size()));
+    BLI_assert(array.size() >= m_min_array_size);
+    m_mutable_array_refs.append(array);
   }
 
-  void add_vector_array(GenericVectorArray &vector_array)
+  void add_vector_output(GenericVectorArray &vector_array)
   {
+    BLI_assert(vector_array.size() >= m_min_array_size);
     m_vector_arrays.append(&vector_array);
   }
 
-  template<typename T> void add_mutable_array_ref(ArrayRef<T> array)
+  template<typename T> void add_single_output(ArrayRef<T> array)
   {
     BLI_assert(array.size() >= m_min_array_size);
     m_mutable_array_refs.append(GenericMutableArrayRef(array));
   }
 
-  void add_mutable_array_ref(GenericMutableArrayRef array)
+  void add_mutable_vector(GenericVectorArray &vector_array)
   {
-    BLI_assert(array.size() >= m_min_array_size);
-    m_mutable_array_refs.append(array);
+    BLI_assert(vector_array.size() >= m_min_array_size);
+    m_vector_arrays.append(&vector_array);
   }
 
   MFParams &build()
diff --git a/source/blender/blenkernel/BKE_multi_function_network.h b/source/blender/blenkernel/BKE_multi_function_network.h
index 1dbb3cab1b6..5dd5a272f2d 100644
--- a/source/blender/blenkernel/BKE_multi_function_network.h
+++ b/source/blender/blenkernel/BKE_multi_function_network.h
@@ -211,8 +211,8 @@ class MFFunctionNode : public MFNode {
  public:
   const MultiFunction &function() const;
 
-  uint input_param_index(uint input_socket_index) const;
-  uint output_param_index(uint output_socket_index) const;
+  ArrayRef<uint> input_param_indices() const;
+  ArrayRef<uint> output_param_indices() const;
 };
 
 class MFPlaceholderNode : public MFNode {
@@ -441,14 +441,14 @@ inline const MultiFunction &MFFunctionNode::function() const
   return *m_function;
 }
 
-inline uint MFFunctionNode::input_param_index(uint input_socket_index) const
+inline ArrayRef<uint> MFFunctionNode::input_param_indices() const
 {
-  return m_input_param_indices[input_socket_index];
+  return m_input_param_indices;
 }
 
-inline uint MFFunctionNode::output_param_index(uint output_socket_index) const
+inline ArrayRef<uint> MFFunctionNode::output_param_indices() const
 {
-  return m_output_param_indices[output_socket_index];
+  return m_output_param_indices;
 }
 
 inline const MFNode &MFSocket::node() const
diff --git a/source/blender/blenkernel/intern/multi_function_network.cc b/source/blender/blenkernel/intern/multi_function_network.cc
index 391e5562a8b..d97badf2073 100644
--- a/source/blender/blenkernel/intern/multi_function_network.cc
+++ b/source/blender/blenkernel/intern/multi_function_network.cc
@@ -176,7 +176,7 @@ MFNetwork::MFNetwork(std::unique_ptr<MFNetworkBuilder> builder)
 
     node->m_id = builder_node->id();
     node->m_network = this;
-    node->m_is_placeholder = false;
+    node->m_is_placeholder = true;
 
     for (MFBuilderInputSocket *builder_socket : builder_node->inputs()) {
       MFInputSocket *socket = new MFInputSocket();
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
index 288cb24186d..4064bef5375 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
@@ -8,10 +8,16 @@
 #include "BLI_math_cxx.h"
 #include "BLI_string_map.h"
 #include "BLI_owned_resources.h"
+#include "BLI_stack_cxx.h"
 
 #include "DEG_depsgraph_query.h"
 
 using BKE::CPPType;
+using BKE::GenericArrayRef;
+using BKE::GenericMutableArrayRef;
+using BKE::GenericVectorArray;
+using BKE::GenericVirtualListListRef;
+using BKE::GenericVirtualListRef;
 using BKE::MFBuilderFunctionNode;
 using BKE::MFBuilderInputSocket;
 using BKE::MFBuilderNode;
@@ -20,6 +26,7 @@ using BKE::MFBuilderPlaceholderNode;
 using BKE::MFBuilderSocket;
 using BKE::MFContext;
 using BKE::MFDataType;
+using BKE::MFFunctionNode;
 using BKE::MFInputSocket;
 using BKE::MFNetwork;
 using BKE::MFNetworkBuilder;
@@ -27,6 +34,8 @

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list