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-04-15 12:21:35 +0300
committerJacques Lucke <jacques@blender.org>2021-04-15 12:21:48 +0300
commit05dbbd83f00d270c00cb1a0904c504c31e1812af (patch)
tree47ca07fd617f692518a254bbf01d2e76d45cc697 /source/blender/nodes/NOD_type_conversions.hh
parent2c3a9caffee61d52cc50a70ff9b2ec3984ee0fc5 (diff)
Geometry Nodes: refactor implicit conversions
This refactor simplifies having standalone function pointer that does a single conversion. It also speeds up implicit type conversion of attributes.
Diffstat (limited to 'source/blender/nodes/NOD_type_conversions.hh')
-rw-r--r--source/blender/nodes/NOD_type_conversions.hh43
1 files changed, 34 insertions, 9 deletions
diff --git a/source/blender/nodes/NOD_type_conversions.hh b/source/blender/nodes/NOD_type_conversions.hh
index e23fddab58b..34225208fe6 100644
--- a/source/blender/nodes/NOD_type_conversions.hh
+++ b/source/blender/nodes/NOD_type_conversions.hh
@@ -21,20 +21,45 @@
namespace blender::nodes {
using fn::CPPType;
+using fn::GVArray;
+
+struct ConversionFunctions {
+ const fn::MultiFunction *multi_function;
+ void (*convert_single_to_initialized)(const void *src, void *dst);
+ void (*convert_single_to_uninitialized)(const void *src, void *dst);
+};
class DataTypeConversions {
private:
- Map<std::pair<fn::MFDataType, fn::MFDataType>, const fn::MultiFunction *> conversions_;
+ Map<std::pair<fn::MFDataType, fn::MFDataType>, ConversionFunctions> conversions_;
public:
- void add(fn::MFDataType from_type, fn::MFDataType to_type, const fn::MultiFunction &fn)
+ void add(fn::MFDataType from_type,
+ fn::MFDataType to_type,
+ const fn::MultiFunction &fn,
+ void (*convert_single_to_initialized)(const void *src, void *dst),
+ void (*convert_single_to_uninitialized)(const void *src, void *dst))
+ {
+ conversions_.add_new({from_type, to_type},
+ {&fn, convert_single_to_initialized, convert_single_to_uninitialized});
+ }
+
+ const ConversionFunctions *get_conversion_functions(fn::MFDataType from, fn::MFDataType to) const
+ {
+ return conversions_.lookup_ptr({from, to});
+ }
+
+ const ConversionFunctions *get_conversion_functions(const CPPType &from, const CPPType &to) const
{
- conversions_.add_new({from_type, to_type}, &fn);
+ return this->get_conversion_functions(fn::MFDataType::ForSingle(from),
+ fn::MFDataType::ForSingle(to));
}
- const fn::MultiFunction *get_conversion(fn::MFDataType from, fn::MFDataType to) const
+ const fn::MultiFunction *get_conversion_multi_function(fn::MFDataType from,
+ fn::MFDataType to) const
{
- return conversions_.lookup_default({from, to}, nullptr);
+ const ConversionFunctions *functions = this->get_conversion_functions(from, to);
+ return functions ? functions->multi_function : nullptr;
}
bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
@@ -43,10 +68,10 @@ class DataTypeConversions {
{fn::MFDataType::ForSingle(from_type), fn::MFDataType::ForSingle(to_type)});
}
- void convert(const CPPType &from_type,
- const CPPType &to_type,
- const void *from_value,
- void *to_value) const;
+ void convert_to_uninitialized(const CPPType &from_type,
+ const CPPType &to_type,
+ const void *from_value,
+ void *to_value) const;
};
const DataTypeConversions &get_implicit_type_conversions();