[Bf-blender-cvs] [0098cf57d01] temp-multi-function-eval-varray: add execute_SI_SI_SI_SI_SO

Jacques Lucke noreply at git.blender.org
Wed Apr 6 16:18:13 CEST 2022


Commit: 0098cf57d01af252fbd0badd25c8ee5a879ab7bb
Author: Jacques Lucke
Date:   Wed Apr 6 12:24:17 2022 +0200
Branches: temp-multi-function-eval-varray
https://developer.blender.org/rB0098cf57d01af252fbd0badd25c8ee5a879ab7bb

add execute_SI_SI_SI_SI_SO

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

M	source/blender/functions/FN_multi_function_builder.hh

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

diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index dfdd152e62a..b041e67390c 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -185,12 +185,27 @@ class CustomMF_SI_SI_SI_SO : public MultiFunction {
                MutableSpan<Out1> out1) {
       /* Virtual arrays are not devirtualized yet, to avoid generating lots of code without further
        * consideration. */
-      for (const int64_t i : mask) {
-        new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i], in2[i], in3[i]));
-      }
+      execute_SI_SI_SI_SO(element_fn, mask, in1, in2, in3, out1.data());
     };
   }
 
+  template<typename ElementFuncT,
+           typename MaskT,
+           typename In1Array,
+           typename In2Array,
+           typename In3Array>
+  BLI_NOINLINE static void execute_SI_SI_SI_SO(const ElementFuncT &element_fn,
+                                               MaskT mask,
+                                               const In1Array &in1,
+                                               const In2Array &in2,
+                                               const In3Array &in3,
+                                               Out1 *__restrict r_out)
+  {
+    for (const int64_t i : mask) {
+      new (r_out + i) Out1(element_fn(in1[i], in2[i], in3[i]));
+    }
+  }
+
   void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override
   {
     const VArray<In1> &in1 = params.readonly_single_input<In1>(0);
@@ -250,12 +265,29 @@ class CustomMF_SI_SI_SI_SI_SO : public MultiFunction {
                MutableSpan<Out1> out1) {
       /* Virtual arrays are not devirtualized yet, to avoid generating lots of code without further
        * consideration. */
-      for (const int64_t i : mask) {
-        new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i], in2[i], in3[i], in4[i]));
-      }
+      execute_SI_SI_SI_SI_SO(element_fn, mask, in1, in2, in3, in4, out1.data());
     };
   }
 
+  template<typename ElementFuncT,
+           typename MaskT,
+           typename In1Array,
+           typename In2Array,
+           typename In3Array,
+           typename In4Array>
+  BLI_NOINLINE static void execute_SI_SI_SI_SI_SO(const ElementFuncT &element_fn,
+                                                  MaskT mask,
+                                                  const In1Array &in1,
+                                                  const In2Array &in2,
+                                                  const In3Array &in3,
+                                                  const In4Array &in4,
+                                                  Out1 *__restrict r_out)
+  {
+    for (const int64_t i : mask) {
+      new (r_out + i) Out1(element_fn(in1[i], in2[i], in3[i], in4[i]));
+    }
+  }
+
   void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override
   {
     const VArray<In1> &in1 = params.readonly_single_input<In1>(0);



More information about the Bf-blender-cvs mailing list