Blender  V3.3
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
blender::fn Namespace Reference

Namespaces

 CustomMF_presets
 
 detail
 
 materialize_detail
 
 multi_function_procedure_types
 
 multi_function_types
 
 procedure_optimization
 
 tests
 

Classes

class  FieldNode
 
class  GFieldBase
 
class  GField
 
class  GFieldRef
 
class  Field
 
class  FieldOperation
 
class  FieldInput
 
class  FieldConstant
 
struct  FieldInputs
 
class  FieldContext
 
class  FieldEvaluator
 
class  IndexFieldInput
 
struct  ValueOrField
 
struct  FieldCPPTypeParam
 
class  FieldCPPType
 
class  ValueOrFieldCPPType
 
class  MultiFunction
 
class  CustomMF
 
class  CustomMF_SI_SO
 
class  CustomMF_SI_SI_SO
 
class  CustomMF_SI_SI_SI_SO
 
class  CustomMF_SI_SI_SI_SI_SO
 
class  CustomMF_SM
 
class  CustomMF_GenericConstant
 
class  CustomMF_GenericConstantArray
 
class  CustomMF_Constant
 
class  CustomMF_DefaultOutput
 
class  CustomMF_GenericCopy
 
class  MFContextBuilder
 
class  MFContext
 
class  MFDataType
 
struct  MFParamTag
 
class  MFParamType
 
class  MFParamsBuilder
 
class  MFParams
 
class  MFInstructionCursor
 
class  MFVariable
 
class  MFInstruction
 
class  MFCallInstruction
 
class  MFBranchInstruction
 
class  MFDestructInstruction
 
class  MFDummyInstruction
 
class  MFReturnInstruction
 
struct  MFParameter
 
struct  ConstMFParameter
 
class  MFProcedure
 
class  MFProcedureBuilder
 
class  MFProcedureExecutor
 
struct  MFSignature
 
class  MFSignatureBuilder
 
struct  FieldTreeInfo
 
class  MFProcedureDotExport
 
struct  VariableValue
 
struct  VariableValue_GVArray
 
struct  VariableValue_Span
 
struct  VariableValue_GVVectorArray
 
struct  VariableValue_GVectorArray
 
struct  VariableValue_OneSingle
 
struct  VariableValue_OneVector
 
class  ValueAllocator
 
class  VariableState
 
class  VariableStates
 
struct  InstructionIndices
 
struct  NextInstructionInfo
 
class  InstructionScheduler
 

Typedefs

using ExecutionHints = MultiFunction::ExecutionHints
 
using IndicesSplitVectors = std::array< Vector< int64_t >, 2 >
 

Enumerations

enum class  FieldNodeType { Input , Operation , Constant }
 
enum class  MFParamCategory {
  SingleInput , VectorInput , SingleOutput , VectorOutput ,
  SingleMutable , VectorMutable
}
 
enum class  MFInstructionType {
  Call , Branch , Destruct , Dummy ,
  Return
}
 

Functions

Vector< GVArrayevaluate_fields (ResourceScope &scope, Span< GFieldRef > fields_to_evaluate, IndexMask mask, const FieldContext &context, Span< GVMutableArray > dst_varrays={})
 
bool operator== (const MFDataType &a, const MFDataType &b)
 
bool operator!= (const MFDataType &a, const MFDataType &b)
 
bool operator== (const MFParamType &a, const MFParamType &b)
 
bool operator!= (const MFParamType &a, const MFParamType &b)
 
static FieldTreeInfo preprocess_field_tree (Span< GFieldRef > entry_fields)
 
static Vector< GVArrayget_field_context_inputs (ResourceScope &scope, const IndexMask mask, const FieldContext &context, const Span< std::reference_wrapper< const FieldInput >> field_inputs)
 
static Set< GFieldReffind_varying_fields (const FieldTreeInfo &field_tree_info, Span< GVArray > field_context_inputs)
 
static void build_multi_function_procedure_for_fields (MFProcedure &procedure, ResourceScope &scope, const FieldTreeInfo &field_tree_info, Span< GFieldRef > output_fields)
 
static std::shared_ptr< const FieldInputscombine_field_inputs (Span< GField > fields)
 
static IndexMask index_mask_from_selection (const IndexMask full_mask, const VArray< bool > &selection, ResourceScope &scope)
 
static IndexMask evaluate_selection (const Field< bool > &selection_field, const FieldContext &context, IndexMask full_mask, ResourceScope &scope)
 
static bool supports_threading_by_slicing_params (const MultiFunction &fn)
 
static int64_t compute_grain_size (const ExecutionHints &hints, const IndexMask mask)
 
static bool evaluate_as_one (const MultiFunction &fn, Span< VariableState * > param_variable_states, const IndexMask &mask, const IndexMask &full_mask)
 
static void gather_parameter_variable_states (const MultiFunction &fn, const MFCallInstruction &instruction, VariableStates &variable_states, MutableSpan< VariableState * > r_param_variable_states)
 
static void fill_params__one (const MultiFunction &fn, const IndexMask mask, MFParamsBuilder &params, VariableStates &variable_states, const Span< VariableState * > param_variable_states)
 
static void fill_params (const MultiFunction &fn, const IndexMask mask, MFParamsBuilder &params, VariableStates &variable_states, const Span< VariableState * > param_variable_states)
 
static void execute_call_instruction (const MFCallInstruction &instruction, const IndexMask mask, VariableStates &variable_states, const MFContext &context)
 
Utility functions for simple field creation and evaluation
void evaluate_constant_field (const GField &field, void *r_value)
 
template<typename T >
T evaluate_constant_field (const Field< T > &field)
 
Field< boolinvert_boolean_field (const Field< bool > &field)
 
GField make_constant_field (const CPPType &type, const void *value)
 
template<typename T >
Field< Tmake_constant_field (T value)
 
GField make_field_constant_if_possible (GField field)
 
#FieldNode Inline Methods
bool operator== (const FieldNode &a, const FieldNode &b)
 
bool operator!= (const FieldNode &a, const FieldNode &b)
 

Variables

template<typename T >
static constexpr bool is_field_v
 

Typedef Documentation

◆ ExecutionHints

Definition at line 10 of file multi_function.cc.

◆ IndicesSplitVectors

using blender::fn::IndicesSplitVectors = typedef std::array<Vector<int64_t>, 2>

Definition at line 21 of file multi_function_procedure_executor.cc.

Enumeration Type Documentation

◆ FieldNodeType

Have a fixed set of base node types, because all code that works with field nodes has to understand those.

Enumerator
Input 
Operation 
Constant 

Definition at line 52 of file FN_field.hh.

◆ MFInstructionType

Every instruction has exactly one of these types.

Enumerator
Call 
Branch 
Destruct 
Dummy 
Return 

Definition at line 23 of file FN_multi_function_procedure.hh.

◆ MFParamCategory

Enumerator
SingleInput 
VectorInput 
SingleOutput 
VectorOutput 
SingleMutable 
VectorMutable 

Definition at line 25 of file FN_multi_function_param_type.hh.

Function Documentation

◆ build_multi_function_procedure_for_fields()

static void blender::fn::build_multi_function_procedure_for_fields ( MFProcedure procedure,
ResourceScope scope,
const FieldTreeInfo field_tree_info,
Span< GFieldRef output_fields 
)
static

Builds the #procedure so that it computes the fields.

Definition at line 144 of file field.cc.

References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), BLI_assert, BLI_assert_unreachable, Constant, blender::ResourceScope::construct(), blender::fn::MFProcedure::construct_function(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), blender::Span< T >::contains(), blender::fn::FieldInput::cpp_type(), blender::fn::MFParamType::data_type(), blender::fn::MFVariable::data_type(), blender::fn::FieldInput::debug_name(), blender::fn::FieldTreeInfo::deduplicated_field_inputs, blender::fn::FieldTreeInfo::field_users, blender::fn::MFDataType::ForSingle(), blender::GPointer::get(), Input, blender::fn::MFParamType::Input, blender::fn::FieldOperation::inputs(), blender::fn::MFParamType::interface_type(), blender::Stack< T, InlineBufferCapacity, Allocator >::is_empty(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup(), blender::fn::procedure_optimization::move_destructs_up(), blender::fn::FieldOperation::multi_function(), blender::fn::MFProcedure::new_variable(), blender::fn::GFieldBase< NodePtr >::node(), blender::fn::FieldNode::node_type(), Operation, blender::fn::MFParamType::Output, blender::fn::MultiFunction::param_amount(), blender::fn::MultiFunction::param_indices(), blender::fn::MultiFunction::param_type(), blender::Stack< T, InlineBufferCapacity, Allocator >::peek(), blender::Stack< T, InlineBufferCapacity, Allocator >::pop(), blender::Stack< T, InlineBufferCapacity, Allocator >::push(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::remove(), blender::Span< T >::size(), blender::fn::FieldConstant::type(), blender::fn::MFProcedure::validate(), blender::fn::FieldConstant::value(), and blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::values().

Referenced by evaluate_fields().

◆ combine_field_inputs()

static std::shared_ptr<const FieldInputs> blender::fn::combine_field_inputs ( Span< GField fields)
static

Returns the field inputs used by all the provided fields. This tries to reuse an existing #FieldInputs whenever possible to avoid copying it.

Definition at line 599 of file field.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), and blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty().

Referenced by blender::fn::FieldOperation::FieldOperation().

◆ compute_grain_size()

static int64_t blender::fn::compute_grain_size ( const ExecutionHints hints,
const IndexMask  mask 
)
static

◆ evaluate_as_one()

static bool blender::fn::evaluate_as_one ( const MultiFunction fn,
Span< VariableState * >  param_variable_states,
const IndexMask mask,
const IndexMask full_mask 
)
static

◆ evaluate_constant_field() [1/2]

template<typename T >
T blender::fn::evaluate_constant_field ( const Field< T > &  field)

Definition at line 482 of file FN_field.hh.

References evaluate_constant_field(), and T.

◆ evaluate_constant_field() [2/2]

void blender::fn::evaluate_constant_field ( const GField field,
void r_value 
)

◆ evaluate_fields()

Vector< GVArray > blender::fn::evaluate_fields ( ResourceScope scope,
Span< GFieldRef fields_to_evaluate,
IndexMask  mask,
const FieldContext context,
Span< GVMutableArray dst_varrays = {} 
)

Evaluate fields in the given context. If possible, multiple fields should be evaluated together, because that can be more efficient when they share common sub-fields.

Parameters
scopeThe resource scope that owns data that makes up the output virtual arrays. Make sure the scope is not destructed when the output virtual arrays are still used.
fields_to_evaluateThe fields that should be evaluated together.
maskDetermines which indices are computed. The mask may be referenced by the returned virtual arrays. So the underlying indices (if applicable) should live longer then #scope.
contextThe context that the field is evaluated in. Used to retrieve data from each #FieldInput in the field network.
dst_varraysIf provided, the computed data will be written into those virtual arrays instead of into newly created ones. That allows making the computed data live longer than #scope and is more efficient when the data will be written into those virtual arrays later anyway.
Returns
The computed virtual arrays for each provided field. If #dst_varrays is passed, the provided virtual arrays are returned.

Definition at line 278 of file field.cc.

References blender::ResourceScope::add_destruct_call(), blender::LinearAllocator< Allocator >::allocate(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BLI_assert, buffer, build_multi_function_procedure_for_fields(), Constant, blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), blender::compositor::context, blender::fn::GFieldBase< NodePtr >::cpp_type(), blender::GMutableSpan::data(), blender::fn::FieldTreeInfo::deduplicated_field_inputs, find_varying_fields(), blender::GVArray::ForEmpty(), blender::GVArray::ForSingleRef(), blender::GVArray::ForSpan(), blender::GPointer::get(), get_field_context_inputs(), blender::GVMutableArray::get_internal_span(), blender::Span< T >::index_range(), blender::Vector< T, InlineBufferCapacity, Allocator >::index_range(), Input, blender::Span< T >::is_empty(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::GVArrayCommon::is_span(), blender::ResourceScope::linear_allocator(), mask(), blender::fn::GFieldBase< NodePtr >::node(), blender::fn::FieldNode::node_type(), Operation, blender::threading::parallel_for(), preprocess_field_tree(), blender::GVArrayCommon::size(), blender::Span< T >::size(), blender::GVArrayCommon::type(), blender::fn::FieldConstant::type(), type, and blender::fn::FieldConstant::value().

Referenced by blender::fn::FieldEvaluator::evaluate(), evaluate_constant_field(), evaluate_selection(), and blender::fn::tests::TEST().

◆ evaluate_selection()

static IndexMask blender::fn::evaluate_selection ( const Field< bool > &  selection_field,
const FieldContext context,
IndexMask  full_mask,
ResourceScope scope 
)
static

◆ execute_call_instruction()

static void blender::fn::execute_call_instruction ( const MFCallInstruction instruction,
const IndexMask  mask,
VariableStates variable_states,
const MFContext context 
)
static

◆ fill_params()

static void blender::fn::fill_params ( const MultiFunction fn,
const IndexMask  mask,
MFParamsBuilder params,
VariableStates variable_states,
const Span< VariableState * >  param_variable_states 
)
static

◆ fill_params__one()

static void blender::fn::fill_params__one ( const MultiFunction fn,
const IndexMask  mask,
MFParamsBuilder params,
VariableStates variable_states,
const Span< VariableState * >  param_variable_states 
)
static

◆ find_varying_fields()

static Set<GFieldRef> blender::fn::find_varying_fields ( const FieldTreeInfo field_tree_info,
Span< GVArray field_context_inputs 
)
static

◆ gather_parameter_variable_states()

static void blender::fn::gather_parameter_variable_states ( const MultiFunction fn,
const MFCallInstruction instruction,
VariableStates variable_states,
MutableSpan< VariableState * >  r_param_variable_states 
)
static

◆ get_field_context_inputs()

static Vector<GVArray> blender::fn::get_field_context_inputs ( ResourceScope scope,
const IndexMask  mask,
const FieldContext context,
const Span< std::reference_wrapper< const FieldInput >>  field_inputs 
)
static

Retrieves the data from the context that is passed as input into the field.

Definition at line 84 of file field.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::compositor::context, blender::GVArray::ForSingleDefault(), mask(), and type.

Referenced by evaluate_fields().

◆ index_mask_from_selection()

static IndexMask blender::fn::index_mask_from_selection ( const IndexMask  full_mask,
const VArray< bool > &  selection,
ResourceScope scope 
)
static

◆ invert_boolean_field()

Field< bool > blender::fn::invert_boolean_field ( const Field< bool > &  field)

◆ make_constant_field() [1/2]

GField blender::fn::make_constant_field ( const CPPType type,
const void value 
)

◆ make_constant_field() [2/2]

template<typename T >
Field<T> blender::fn::make_constant_field ( T  value)

Definition at line 494 of file FN_field.hh.

References make_constant_field().

◆ make_field_constant_if_possible()

GField blender::fn::make_field_constant_if_possible ( GField  field)

If the field depends on some input, the same field is returned. Otherwise the field is evaluated and a new field is created that just computes this constant.

Making the field constant has two benefits:

  • The field-tree becomes a single node, which is more efficient when the field is evaluated many times.
  • Memory of the input fields may be freed.

Definition at line 508 of file field.cc.

References buffer, BUFFER_FOR_CPP_TYPE_VALUE, blender::fn::GFieldBase< NodePtr >::cpp_type(), blender::fn::FieldNode::depends_on_input(), evaluate_constant_field(), make_constant_field(), blender::fn::GFieldBase< NodePtr >::node(), and type.

◆ operator!=() [1/3]

bool blender::fn::operator!= ( const FieldNode a,
const FieldNode b 
)
inline

Definition at line 610 of file FN_field.hh.

References Freestyle::a, and usdtokens::b().

◆ operator!=() [2/3]

bool blender::fn::operator!= ( const MFDataType a,
const MFDataType b 
)
inline

Definition at line 108 of file FN_multi_function_data_type.hh.

◆ operator!=() [3/3]

bool blender::fn::operator!= ( const MFParamType a,
const MFParamType b 
)
inline

Definition at line 154 of file FN_multi_function_param_type.hh.

◆ operator==() [1/3]

bool blender::fn::operator== ( const FieldNode a,
const FieldNode b 
)
inline

Definition at line 605 of file FN_field.hh.

References Freestyle::a, and usdtokens::b().

◆ operator==() [2/3]

bool blender::fn::operator== ( const MFDataType a,
const MFDataType b 
)
inline

Definition at line 103 of file FN_multi_function_data_type.hh.

◆ operator==() [3/3]

bool blender::fn::operator== ( const MFParamType a,
const MFParamType b 
)
inline

Definition at line 149 of file FN_multi_function_param_type.hh.

◆ preprocess_field_tree()

static FieldTreeInfo blender::fn::preprocess_field_tree ( Span< GFieldRef entry_fields)
static

◆ supports_threading_by_slicing_params()

static bool blender::fn::supports_threading_by_slicing_params ( const MultiFunction fn)
static

Variable Documentation

◆ is_field_v

template<typename T >
constexpr bool blender::fn::is_field_v
staticconstexpr
Initial value:
= std::is_base_of_v<detail::TypedFieldBase, T> &&
!std::is_same_v<detail::TypedFieldBase, T>

True when T is any Field<...> type.

Definition at line 198 of file FN_field.hh.