diff options
author | Jacques Lucke <jacques@blender.org> | 2022-04-07 12:51:31 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-04-07 12:51:47 +0300 |
commit | e5c7f3722370f3cd70a7a00079820332c5b92de4 (patch) | |
tree | 28cbe799074e989a4f207c5e73ae202c18fb2f1f /source/blender/functions | |
parent | 6d1fbd249b7114c21926e630a1d8fcf8966c8379 (diff) |
Cleanup: make CustomMF_* implementations more similar
Diffstat (limited to 'source/blender/functions')
-rw-r--r-- | source/blender/functions/FN_multi_function_builder.hh | 44 |
1 files changed, 38 insertions, 6 deletions
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); |