Changeset View
Changeset View
Standalone View
Standalone View
source/blender/functions/intern/multi_function_builder.cc
| Show All 26 Lines | |||||
| { | { | ||||
| if (make_value_copy) { | if (make_value_copy) { | ||||
| void *copied_value = MEM_mallocN_aligned(type.size(), type.alignment(), __func__); | void *copied_value = MEM_mallocN_aligned(type.size(), type.alignment(), __func__); | ||||
| type.copy_construct(value, copied_value); | type.copy_construct(value, copied_value); | ||||
| value = copied_value; | value = copied_value; | ||||
| } | } | ||||
| value_ = value; | value_ = value; | ||||
| MFSignatureBuilder signature{"Constant " + type.name()}; | MFSignatureBuilder signature{"Constant"}; | ||||
| std::stringstream ss; | signature.single_output("Value", type); | ||||
| type.print_or_default(value, ss, type.name()); | |||||
| signature.single_output(ss.str(), type); | |||||
| signature_ = signature.build(); | signature_ = signature.build(); | ||||
| this->set_signature(&signature_); | this->set_signature(&signature_); | ||||
| } | } | ||||
| CustomMF_GenericConstant::~CustomMF_GenericConstant() | CustomMF_GenericConstant::~CustomMF_GenericConstant() | ||||
| { | { | ||||
| if (owns_value_) { | if (owns_value_) { | ||||
| signature_.param_types[0].data_type().single_type().destruct((void *)value_); | signature_.param_types[0].data_type().single_type().destruct((void *)value_); | ||||
| Show All 21 Lines | if (_other == nullptr) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (type_ != _other->type_) { | if (type_ != _other->type_) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return type_.is_equal(value_, _other->value_); | return type_.is_equal(value_, _other->value_); | ||||
| } | } | ||||
| static std::string gspan_to_string(GSpan array) | |||||
| { | |||||
| const CPPType &type = array.type(); | |||||
| std::stringstream ss; | |||||
| ss << "["; | |||||
| const int64_t max_amount = 5; | |||||
| for (int64_t i : IndexRange(std::min(max_amount, array.size()))) { | |||||
| type.print_or_default(array[i], ss, type.name()); | |||||
| ss << ", "; | |||||
| } | |||||
| if (max_amount < array.size()) { | |||||
| ss << "..."; | |||||
| } | |||||
| ss << "]"; | |||||
| return ss.str(); | |||||
| } | |||||
| CustomMF_GenericConstantArray::CustomMF_GenericConstantArray(GSpan array) : array_(array) | CustomMF_GenericConstantArray::CustomMF_GenericConstantArray(GSpan array) : array_(array) | ||||
| { | { | ||||
| const CPPType &type = array.type(); | const CPPType &type = array.type(); | ||||
| MFSignatureBuilder signature{"Constant " + type.name() + " Vector"}; | MFSignatureBuilder signature{"Constant Vector"}; | ||||
| signature.vector_output(gspan_to_string(array), type); | signature.vector_output("Value", type); | ||||
| signature_ = signature.build(); | signature_ = signature.build(); | ||||
| this->set_signature(&signature_); | this->set_signature(&signature_); | ||||
| } | } | ||||
| void CustomMF_GenericConstantArray::call(IndexMask mask, | void CustomMF_GenericConstantArray::call(IndexMask mask, | ||||
| MFParams params, | MFParams params, | ||||
| MFContext UNUSED(context)) const | MFContext UNUSED(context)) const | ||||
| { | { | ||||
| GVectorArray &vectors = params.vector_output(0); | GVectorArray &vectors = params.vector_output(0); | ||||
| for (int64_t i : mask) { | for (int64_t i : mask) { | ||||
| vectors.extend(i, array_); | vectors.extend(i, array_); | ||||
| } | } | ||||
| } | } | ||||
| CustomMF_DefaultOutput::CustomMF_DefaultOutput(StringRef name, | CustomMF_DefaultOutput::CustomMF_DefaultOutput(Span<MFDataType> input_types, | ||||
| Span<MFDataType> input_types, | |||||
| Span<MFDataType> output_types) | Span<MFDataType> output_types) | ||||
| : output_amount_(output_types.size()) | : output_amount_(output_types.size()) | ||||
| { | { | ||||
| MFSignatureBuilder signature{name}; | MFSignatureBuilder signature{"Default Output"}; | ||||
| for (MFDataType data_type : input_types) { | for (MFDataType data_type : input_types) { | ||||
| signature.input("Input", data_type); | signature.input("Input", data_type); | ||||
| } | } | ||||
| for (MFDataType data_type : output_types) { | for (MFDataType data_type : output_types) { | ||||
| signature.output("Output", data_type); | signature.output("Output", data_type); | ||||
| } | } | ||||
| signature_ = signature.build(); | signature_ = signature.build(); | ||||
| this->set_signature(&signature_); | this->set_signature(&signature_); | ||||
| Show All 9 Lines | for (int param_index : this->param_indices()) { | ||||
| if (param_type.data_type().is_single()) { | if (param_type.data_type().is_single()) { | ||||
| GMutableSpan span = params.uninitialized_single_output(param_index); | GMutableSpan span = params.uninitialized_single_output(param_index); | ||||
| const CPPType &type = span.type(); | const CPPType &type = span.type(); | ||||
| type.fill_construct_indices(type.default_value(), span.data(), mask); | type.fill_construct_indices(type.default_value(), span.data(), mask); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| CustomMF_GenericCopy::CustomMF_GenericCopy(StringRef name, MFDataType data_type) | CustomMF_GenericCopy::CustomMF_GenericCopy(MFDataType data_type) | ||||
| { | { | ||||
| MFSignatureBuilder signature{name}; | MFSignatureBuilder signature{"Copy"}; | ||||
| signature.input("Input", data_type); | signature.input("Input", data_type); | ||||
| signature.output("Output", data_type); | signature.output("Output", data_type); | ||||
| signature_ = signature.build(); | signature_ = signature.build(); | ||||
| this->set_signature(&signature_); | this->set_signature(&signature_); | ||||
| } | } | ||||
| void CustomMF_GenericCopy::call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const | void CustomMF_GenericCopy::call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const | ||||
| { | { | ||||
| Show All 18 Lines | |||||