[Bf-blender-cvs] [fc461c1c257] temp-T96710-pbvh-pixels: Cleanup: make CustomMF_* implementations more similar

Jacques Lucke noreply at git.blender.org
Fri Apr 8 11:07:48 CEST 2022


Commit: fc461c1c2579d92abf32cdfad781ea4d5f01f03e
Author: Jacques Lucke
Date:   Thu Apr 7 11:51:31 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rBfc461c1c2579d92abf32cdfad781ea4d5f01f03e

Cleanup: make CustomMF_* implementations more similar

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

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