Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-04-10 16:57:40 +0300
committerJacques Lucke <jacques@blender.org>2022-04-10 16:57:40 +0300
commitba41c84d0821c3f0063998be7f0a01f7f060cc59 (patch)
treeff5b16188e82f014b99fc3e44efe87a33a0240a3
parent99ccdcf75fb4dcad433b358d414a1dd7af25fd5e (diff)
use in CustomMF_SI_SI_SI_SOdevirtualizer
-rw-r--r--source/blender/functions/FN_multi_function_builder.hh43
1 files changed, 23 insertions, 20 deletions
diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index 20d62b3bb1e..5096f0d6536 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -183,27 +183,30 @@ class CustomMF_SI_SI_SI_SO : public MultiFunction {
const VArray<In2> &in2,
const VArray<In3> &in3,
MutableSpan<Out1> out1) {
- /* Virtual arrays are not devirtualized yet, to avoid generating lots of code without further
- * consideration. */
- execute_SI_SI_SI_SO(element_fn, mask, in1, in2, in3, out1.data());
- };
- }
+ auto fn = [&](auto in_indices,
+ auto out_indices,
+ auto in1,
+ auto in2,
+ auto in3,
+ Out1 *__restrict out1) {
+ BLI_assert(in_indices.size() == out_indices.size());
+ for (const int64_t i : IndexRange(in_indices.size())) {
+ const int64_t in_index = in_indices[i];
+ const int64_t out_index = out_indices[i];
+ new (out1 + out_index) Out1(element_fn(in1[in_index], in2[in_index], in3[in_index]));
+ }
+ };
- 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]));
- }
+ ArrayDevirtualizer<decltype(fn),
+ SingleInputTag<In1>,
+ SingleInputTag<In2>,
+ SingleInputTag<In3>,
+ SingleOutputTag<Out1>>
+ devirtualizer{fn, &mask, &in1, &in2, &in3, &out1};
+ if (!devirtualizer.try_execute_devirtualized()) {
+ devirtualizer.execute_materialized();
+ }
+ };
}
void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override