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>2021-08-20 14:14:39 +0300
committerJacques Lucke <jacques@blender.org>2021-08-20 14:14:39 +0300
commit00812008129bdab48d328775b09332af12118867 (patch)
tree344723847c164ce75f9f4cff22991ce69678b57c /source/blender/functions/tests/FN_multi_function_test.cc
parent7d8c71e8003ecb4d3a7fe2483a328d3f2d184faa (diff)
Functions: remove multi-function network
The multi-function network system was able to compose multiple multi-functions into a new one and to evaluate that efficiently. This functionality was heavily used by the particle nodes prototype a year ago. However, since then we only used multi-functions without the need to compose them in geometry nodes. The upcoming "fields" in geometry nodes will need a way to compose multi-functions again. Unfortunately, the code removed in this commit was not ideal for this different kind of function composition. I've been working on an alternative that will be added separately when it becomes needed. I've had to update all the function nodes, because their interface depended on the multi-function network data structure a bit. The actual multi-function implementations are still the same though.
Diffstat (limited to 'source/blender/functions/tests/FN_multi_function_test.cc')
-rw-r--r--source/blender/functions/tests/FN_multi_function_test.cc92
1 files changed, 4 insertions, 88 deletions
diff --git a/source/blender/functions/tests/FN_multi_function_test.cc b/source/blender/functions/tests/FN_multi_function_test.cc
index 3d73e020eb2..91c72a51dd6 100644
--- a/source/blender/functions/tests/FN_multi_function_test.cc
+++ b/source/blender/functions/tests/FN_multi_function_test.cc
@@ -4,6 +4,7 @@
#include "FN_multi_function.hh"
#include "FN_multi_function_builder.hh"
+#include "FN_multi_function_test_common.hh"
namespace blender::fn::tests {
namespace {
@@ -59,33 +60,6 @@ TEST(multi_function, AddFunction)
EXPECT_EQ(output[2], 36);
}
-class AddPrefixFunction : public MultiFunction {
- public:
- AddPrefixFunction()
- {
- static MFSignature signature = create_signature();
- this->set_signature(&signature);
- }
-
- static MFSignature create_signature()
- {
- MFSignatureBuilder signature{"Add Prefix"};
- signature.single_input<std::string>("Prefix");
- signature.single_mutable<std::string>("Strings");
- return signature.build();
- }
-
- void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override
- {
- const VArray<std::string> &prefixes = params.readonly_single_input<std::string>(0, "Prefix");
- MutableSpan<std::string> strings = params.single_mutable<std::string>(1, "Strings");
-
- for (int64_t i : mask) {
- strings[i] = prefixes[i] + strings[i];
- }
- }
-};
-
TEST(multi_function, AddPrefixFunction)
{
AddPrefixFunction fn;
@@ -113,43 +87,13 @@ TEST(multi_function, AddPrefixFunction)
EXPECT_EQ(strings[3], "ABAnother much longer string to trigger an allocation");
}
-class CreateRangeFunction : public MultiFunction {
- public:
- CreateRangeFunction()
- {
- static MFSignature signature = create_signature();
- this->set_signature(&signature);
- }
-
- static MFSignature create_signature()
- {
- MFSignatureBuilder signature{"Create Range"};
- signature.single_input<uint>("Size");
- signature.vector_output<uint>("Range");
- return signature.build();
- }
-
- void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override
- {
- const VArray<uint> &sizes = params.readonly_single_input<uint>(0, "Size");
- GVectorArray &ranges = params.vector_output(1, "Range");
-
- for (int64_t i : mask) {
- uint size = sizes[i];
- for (uint j : IndexRange(size)) {
- ranges.append(i, &j);
- }
- }
- }
-};
-
TEST(multi_function, CreateRangeFunction)
{
CreateRangeFunction fn;
- GVectorArray ranges(CPPType::get<uint>(), 5);
- GVectorArray_TypedMutableRef<uint> ranges_ref{ranges};
- Array<uint> sizes = {3, 0, 6, 1, 4};
+ GVectorArray ranges(CPPType::get<int>(), 5);
+ GVectorArray_TypedMutableRef<int> ranges_ref{ranges};
+ Array<int> sizes = {3, 0, 6, 1, 4};
MFParamsBuilder params(fn, ranges.size());
params.add_readonly_single_input(sizes.as_span());
@@ -172,34 +116,6 @@ TEST(multi_function, CreateRangeFunction)
EXPECT_EQ(ranges_ref[2][1], 1);
}
-class GenericAppendFunction : public MultiFunction {
- private:
- MFSignature signature_;
-
- public:
- GenericAppendFunction(const CPPType &type)
- {
- MFSignatureBuilder signature{"Append"};
- signature.vector_mutable("Vector", type);
- signature.single_input("Value", type);
- signature_ = signature.build();
- this->set_signature(&signature_);
- }
-
- void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override
- {
- GVectorArray &vectors = params.vector_mutable(0, "Vector");
- const GVArray &values = params.readonly_single_input(1, "Value");
-
- for (int64_t i : mask) {
- BUFFER_FOR_CPP_TYPE_VALUE(values.type(), buffer);
- values.get(i, buffer);
- vectors.append(i, buffer);
- values.type().destruct(buffer);
- }
- }
-};
-
TEST(multi_function, GenericAppendFunction)
{
GenericAppendFunction fn(CPPType::get<int32_t>());