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:
Diffstat (limited to 'source/blender/functions/FN_multi_function_builder.hh')
-rw-r--r--source/blender/functions/FN_multi_function_builder.hh14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index 389d0b14bb5..95a9f52e29e 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -61,8 +61,11 @@ template<typename In1, typename Out1> class CustomMF_SI_SO : public MultiFunctio
template<typename ElementFuncT> static FunctionT create_function(ElementFuncT element_fn)
{
return [=](IndexMask mask, const VArray<In1> &in1, MutableSpan<Out1> out1) {
- mask.foreach_index(
- [&](int i) { new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i])); });
+ /* Devirtualization results in a 2-3x speedup for some simple functions. */
+ devirtualize_varray(in1, [&](const auto &in1) {
+ mask.foreach_index(
+ [&](int i) { new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i])); });
+ });
};
}
@@ -111,8 +114,11 @@ class CustomMF_SI_SI_SO : public MultiFunction {
const VArray<In1> &in1,
const VArray<In2> &in2,
MutableSpan<Out1> out1) {
- mask.foreach_index(
- [&](int i) { new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i], in2[i])); });
+ /* Devirtualization results in a 2-3x speedup for some simple functions. */
+ devirtualize_varray2(in1, in2, [&](const auto &in1, const auto &in2) {
+ mask.foreach_index(
+ [&](int i) { new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i], in2[i])); });
+ });
};
}