Blender V5.3
field_evaluation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_array_utils.hh"
10#include "BLI_map.hh"
12#include "BLI_set.hh"
13#include "BLI_stack.hh"
14#include "BLI_vector_set.hh"
15
17#include "FN_multi_function.hh"
23
24namespace blender::fn {
25
26/* -------------------------------------------------------------------- */
29
45
50{
52 FieldTreeInfo field_tree_info;
53
54 Stack<GFieldRef> fields_to_check;
55 Set<GFieldRef> handled_fields;
56
57 for (GFieldRef field : entry_fields) {
58 if (handled_fields.add(field)) {
59 fields_to_check.push(field);
60 }
61 }
62
63 while (!fields_to_check.is_empty()) {
64 const GFieldRef &field = fields_to_check.pop();
65 const GFieldRef::Variant &field_variant = field.variant();
66 const UniqueHash hash = field_tree_info.deep_hashes.ensure(field);
67 std::visit(
68 [&]<typename T>(const T &v) {
69 if constexpr (std::is_same_v<T, GFieldRef::Input>) {
70 if (field_tree_info.deduplicated_input_hashes.add(hash)) {
71 field_tree_info.deduplicated_inputs.append(field);
72 }
73 }
74 else if constexpr (std::is_same_v<T, GFieldRef::MultiFn>) {
75 for (const GField &input_field : v.node->inputs()) {
76 const UniqueHash input_hash = field_tree_info.deep_hashes.lookup(input_field);
77 field_tree_info.field_users.add(input_hash, hash);
78 if (handled_fields.add(input_field)) {
79 fields_to_check.push(input_field);
80 }
81 }
82 }
83 else if constexpr (std::is_same_v<T, GFieldRef::Value>) {
84 /* Nothing to do. */
85 }
86 else {
88 }
89 },
90 field_variant);
91 }
92 return field_tree_info;
93}
94
99 const IndexMask &mask,
100 const FieldContext &context,
101 const Span<GFieldRef> field_inputs)
102{
103 Vector<GVArray> field_context_inputs;
104 for (const GFieldRef &input_field : field_inputs) {
105 const FieldInput &field_input = *std::get<GFieldRef::Input>(input_field.variant()).node;
106 GVArray varray = context.get_varray_for_input(field_input, mask, scope);
107 if (!varray) {
108 const CPPType &type = field_input.cpp_type();
109 varray = GVArray::from_single_default(type, mask.min_array_size());
110 }
111 field_context_inputs.append(std::move(varray));
112 }
113 return field_context_inputs;
114}
115
121 const Span<GVArray> field_context_inputs)
122{
123 Set<UniqueHash> found_fields;
124 Stack<UniqueHash> fields_to_check;
125
126 /* The varying fields are the ones that depend on inputs that are not constant. Therefore we
127 * start the tree search at the non-constant input fields and traverse through all fields that
128 * depend on them. */
129 for (const int input_i : field_tree_info.deduplicated_inputs.index_range()) {
130 const GVArray &varray = field_context_inputs[input_i];
131 if (varray.is_single()) {
132 continue;
133 }
134 const UniqueHash &field = field_tree_info.deduplicated_input_hashes[input_i];
135 for (const UniqueHash &user : field_tree_info.field_users.lookup(field)) {
136 if (found_fields.add(user)) {
137 fields_to_check.push(user);
138 }
139 }
140 }
141 while (!fields_to_check.is_empty()) {
142 const UniqueHash &field = fields_to_check.pop();
143 for (const UniqueHash &user : field_tree_info.field_users.lookup(field)) {
144 if (found_fields.add(user)) {
145 fields_to_check.push(user);
146 }
147 }
148 }
149 return found_fields;
150}
151
155static void build_multi_function_procedure_for_fields(mf::Procedure &procedure,
156 ResourceScope &scope,
157 const FieldTreeInfo &field_tree_info,
158 Span<GFieldRef> output_fields)
159{
161 mf::ProcedureBuilder builder{procedure};
162 /* Every input, intermediate and output field corresponds to a variable in the procedure. */
163 Map<UniqueHash, mf::Variable *> variable_by_field;
164
165 /* Start by adding the field inputs as parameters to the procedure. */
166 for (const GFieldRef &input_field : field_tree_info.deduplicated_inputs) {
167 const UniqueHash input_hash = field_tree_info.deep_hashes.lookup(input_field);
168 const FieldInput &field_input = *std::get<GFieldRef::Input>(input_field.variant()).node;
169 mf::Variable &variable = builder.add_input_parameter(
170 mf::DataType::ForSingle(field_input.cpp_type()), field_input.debug_name());
171 variable_by_field.add_new(input_hash, &variable);
172 }
173
174 /* Utility struct that is used to do proper depth first search traversal of the tree below. */
175 struct FieldWithIndex {
176 GFieldRef field;
177 int current_input_index = 0;
178 };
179
180 for (GFieldRef field : output_fields) {
181 /* We start a new stack for each output field to make sure that a field pushed later to the
182 * stack never depends on a field that was pushed before. */
183 Stack<FieldWithIndex> fields_to_check;
184 fields_to_check.push({field, 0});
185 while (!fields_to_check.is_empty()) {
186 FieldWithIndex &field_with_index = fields_to_check.peek();
187 const GFieldRef &field = field_with_index.field;
188 const UniqueHash field_hash = field_tree_info.deep_hashes.lookup(field);
189 if (variable_by_field.contains(field_hash)) {
190 /* The field has been handled already. */
191 fields_to_check.pop();
192 continue;
193 }
194 const GFieldRef::Variant &field_variant = field.variant();
195 std::visit(
196 [&]<typename T>(const T &v) {
197 if constexpr (std::is_same_v<T, GFieldRef::Input>) {
198 /* Variables for inputs are added above. */
199 }
200 else if constexpr (std::is_same_v<T, GFieldRef::MultiFn>) {
201 const FieldOperation &field_multi_fn = *v.node;
202 const Span<GField> fn_inputs = field_multi_fn.inputs();
203
204 if (field_with_index.current_input_index < fn_inputs.size()) {
205 /* Not all inputs are handled yet. Push the next input field to the stack and
206 * increment the input index. */
207 fields_to_check.push({fn_inputs[field_with_index.current_input_index]});
208 field_with_index.current_input_index++;
209 }
210 else {
211 /* All inputs variables are ready, now gather all variables that are used by the
212 * function and call it. */
213 const mf::MultiFunction &multi_function = field_multi_fn.multi_function();
214 Array<mf::Variable *, 8> variables(multi_function.param_amount());
215
216 int param_input_index = 0;
217 int param_output_index = 0;
218 for (const int param_index : multi_function.param_indices()) {
219 const mf::ParamType param_type = multi_function.param_type(param_index);
220 const mf::ParamType::InterfaceType interface_type = param_type.interface_type();
221 if (interface_type == mf::ParamType::Input) {
222 const GField &input_field = fn_inputs[param_input_index];
223 const UniqueHash input_hash = field_tree_info.deep_hashes.lookup(input_field);
224 variables[param_index] = variable_by_field.lookup(input_hash);
225 param_input_index++;
226 }
227 else if (interface_type == mf::ParamType::Output) {
228 const GFieldRef output_field{field_multi_fn, param_output_index};
229 /* NOTE: This abuses the deep hash cache as a set of the fields in the tree. At
230 * the cost of either hashing this output field or building a separate set of
231 * visited GFieldRefs, we wouldn't have to use the cache in this way. */
232 if (!field_tree_info.deep_hashes.contains(output_field)) {
233 /* Ignored outputs don't need a variable. */
234 variables[param_index] = nullptr;
235 }
236 else {
237 /* Create a new variable for used outputs. */
238 mf::Variable &new_variable = procedure.new_variable(param_type.data_type());
239 variables[param_index] = &new_variable;
240 const UniqueHash output_hash = field_tree_info.deep_hashes.lookup(
241 output_field);
242 variable_by_field.add_new(output_hash, &new_variable);
243 }
244 param_output_index++;
245 }
246 else {
248 }
249 }
250 builder.add_call_with_all_variables(multi_function, variables);
251 }
252 }
253 else if constexpr (std::is_same_v<T, GFieldRef::Value>) {
254 const mf::MultiFunction &fn =
255 procedure.construct_function<mf::CustomMF_GenericConstant>(
256 *v.type, v.value, false);
257 mf::Variable &new_variable = *builder.add_call<1>(fn)[0];
258 variable_by_field.add_new(field_hash, &new_variable);
259 }
260 else {
262 }
263 },
264 field_variant);
265 }
266 }
267
268 /* Add output parameters to the procedure. */
269 Set<mf::Variable *> output_variables;
270 for (const GFieldRef &field : output_fields) {
271 const UniqueHash field_hash = field_tree_info.deep_hashes.lookup(field);
272 mf::Variable *variable = variable_by_field.lookup(field_hash);
273 if (!output_variables.add(variable)) {
274 /* One variable can be output at most once. To output the same value twice, we have to make
275 * a copy first. */
276 const mf::MultiFunction &copy_fn = scope.construct<mf::CustomMF_GenericCopy>(
277 variable->data_type());
278 variable = builder.add_call<1>(copy_fn, {variable})[0];
279 output_variables.add(variable);
280 }
281 builder.add_output_parameter(*variable);
282 }
283
284 for (mf::Variable *variable : procedure.variables()) {
285 if (!output_variables.contains(variable)) {
286 builder.add_destruct(*variable);
287 }
288 }
289
290 mf::ReturnInstruction &return_instr = builder.add_return();
291
292 mf::procedure_optimization::move_destructs_up(procedure, return_instr);
293
294 procedure.prepare_for_execution();
295
296 // std::cout << procedure.to_dot() << "\n";
297 BLI_assert(procedure.validate());
298}
299
301 Span<GFieldRef> fields_to_evaluate,
302 const IndexMask &mask,
303 const FieldContext &context,
304 Span<GVMutableArray> dst_varrays)
305{
307 Vector<GVArray> varrays(fields_to_evaluate.size());
308 Array<bool> is_output_written_to_dst(fields_to_evaluate.size(), false);
309 const int array_size = mask.min_array_size();
310
311 if (mask.is_empty()) {
312 for (const int i : fields_to_evaluate.index_range()) {
313 const CPPType &type = fields_to_evaluate[i].cpp_type();
314 varrays[i] = GVArray::from_empty(type);
315 }
316 return varrays;
317 }
318
319 /* Destination arrays are optional. Create a small utility method to access them. */
320 auto get_dst_varray = [&](int index) -> GVMutableArray {
321 if (dst_varrays.is_empty()) {
322 return {};
323 }
324 const GVMutableArray &varray = dst_varrays[index];
325 if (!varray) {
326 return {};
327 }
328 BLI_assert(varray.size() >= array_size);
329 return varray;
330 };
331
332 /* Traverse the field tree and prepare some data that is used in later steps. */
333 FieldTreeInfo field_tree_info = preprocess_field_tree(fields_to_evaluate);
334
335 /* Get inputs that will be passed into the field when evaluated. */
336 Vector<GVArray> field_context_inputs = get_field_context_inputs(
337 scope, mask, context, field_tree_info.deduplicated_inputs);
338
339 Set<UniqueHash> varying_fields = find_varying_fields(field_tree_info, field_context_inputs);
340
341 /* Process fields that can output a VArray directly, and separate the rest of the fields into
342 * two categories: those that are constant and need to be evaluated only once, and those that
343 * need to be evaluated for every index. */
344 Vector<GFieldRef> varying_fields_to_evaluate;
345 Vector<int> varying_field_indices;
346 Vector<GFieldRef> constant_fields_to_evaluate;
347 Vector<int> constant_field_indices;
348 for (const int out_index : fields_to_evaluate.index_range()) {
349 const GFieldRef &field = fields_to_evaluate[out_index];
350 const GFieldRef::Variant &field_variant = field.variant();
351 std::visit(
352 [&]<typename T>(const T &v) {
353 if constexpr (std::is_same_v<T, GFieldRef::Input>) {
354 const UniqueHash hash = field_tree_info.deep_hashes.lookup(field);
355 const int input_i = field_tree_info.deduplicated_input_hashes.index_of(hash);
356 const GVArray &varray = field_context_inputs[input_i];
357 varrays[out_index] = varray;
358 }
359 else if constexpr (std::is_same_v<T, GFieldRef::MultiFn>) {
360 const UniqueHash hash = field_tree_info.deep_hashes.lookup(field);
361 if (varying_fields.contains(hash)) {
362 varying_fields_to_evaluate.append(field);
363 varying_field_indices.append(out_index);
364 }
365 else {
366 constant_fields_to_evaluate.append(field);
367 constant_field_indices.append(out_index);
368 }
369 }
370 else if constexpr (std::is_same_v<T, GFieldRef::Value>) {
371 varrays[out_index] = GVArray::from_single_ref(*v.type, mask.min_array_size(), v.value);
372 }
373 else {
375 }
376 },
377 field_variant);
378 }
379
380 /* Evaluate varying fields if necessary. */
381 if (!varying_fields_to_evaluate.is_empty()) {
382 /* Build the procedure for those fields. */
383 mf::Procedure procedure;
385 procedure, scope, field_tree_info, varying_fields_to_evaluate);
386 mf::ProcedureExecutor procedure_executor{procedure};
387
388 mf::ParamsBuilder mf_params{procedure_executor, &mask};
389 mf::ContextBuilder mf_context;
390
391 /* Provide inputs to the procedure executor. */
392 for (const GVArray &varray : field_context_inputs) {
393 mf_params.add_readonly_single_input(varray);
394 }
395
396 for (const int i : varying_fields_to_evaluate.index_range()) {
397 const GFieldRef &field = varying_fields_to_evaluate[i];
398 const CPPType &type = field.cpp_type();
399 const int out_index = varying_field_indices[i];
400
401 /* Try to get an existing virtual array that the result should be written into. */
402 GVMutableArray dst_varray = get_dst_varray(out_index);
403 void *buffer;
404 if (!dst_varray || !dst_varray.is_span()) {
405 /* Allocate a new buffer for the computed result. */
406 buffer = scope.allocator().allocate_array(type, array_size);
407
408 if (!type.is_trivially_destructible) {
409 /* Destruct values in the end. */
410 scope.add_destruct_call(
411 [buffer, mask, &type]() { type.destruct_indices(buffer, mask); });
412 }
413
414 varrays[out_index] = GVArray::from_span({type, buffer, array_size});
415 }
416 else {
417 /* Write the result into the existing span. */
418 buffer = dst_varray.get_internal_span().data();
419
420 varrays[out_index] = dst_varray;
421 is_output_written_to_dst[out_index] = true;
422 }
423
424 /* Pass output buffer to the procedure executor. */
425 const GMutableSpan span{type, buffer, array_size};
426 mf_params.add_uninitialized_single_output(span);
427 }
428
429 procedure_executor.call_auto(mask, mf_params, mf_context);
430 }
431
432 /* Evaluate constant fields if necessary. */
433 if (!constant_fields_to_evaluate.is_empty()) {
434 /* Build the procedure for those fields. */
435 mf::Procedure procedure;
437 procedure, scope, field_tree_info, constant_fields_to_evaluate);
438 mf::ProcedureExecutor procedure_executor{procedure};
439 const IndexMask mask(1);
440 mf::ParamsBuilder mf_params{procedure_executor, &mask};
441 mf::ContextBuilder mf_context;
442
443 /* Provide inputs to the procedure executor. */
444 for (const GVArray &varray : field_context_inputs) {
445 mf_params.add_readonly_single_input(varray);
446 }
447
448 for (const int i : constant_fields_to_evaluate.index_range()) {
449 const GFieldRef &field = constant_fields_to_evaluate[i];
450 const CPPType &type = field.cpp_type();
451 /* Allocate memory where the computed value will be stored in. */
452 void *buffer = scope.allocate_owned(type);
453
454 /* Pass output buffer to the procedure executor. */
455 mf_params.add_uninitialized_single_output({type, buffer, 1});
456
457 /* Create virtual array that can be used after the procedure has been executed below. */
458 const int out_index = constant_field_indices[i];
459 varrays[out_index] = GVArray::from_single_ref(type, array_size, buffer);
460 }
461
462 procedure_executor.call(mask, mf_params, mf_context);
463 }
464
465 /* Copy data to supplied destination arrays if necessary. In some cases the evaluation above
466 * has written the computed data in the right place already. */
467 if (!dst_varrays.is_empty()) {
468 for (const int out_index : fields_to_evaluate.index_range()) {
469 GVMutableArray dst_varray = get_dst_varray(out_index);
470 if (!dst_varray) {
471 /* Caller did not provide a destination for this output. */
472 continue;
473 }
474 const GVArray &computed_varray = varrays[out_index];
475 BLI_assert(computed_varray.type() == dst_varray.type());
476 if (is_output_written_to_dst[out_index]) {
477 /* The result has been written into the destination provided by the caller already. */
478 continue;
479 }
480 /* Still have to copy over the data in the destination provided by the caller. */
481 if (dst_varray.is_span()) {
482 computed_varray.type().default_construct_indices(dst_varray.get_internal_span().data(),
483 mask);
484 array_utils::copy(computed_varray,
485 mask,
486 dst_varray.get_internal_span().take_front(mask.min_array_size()));
487 }
488 else {
489 /* Slower materialize into a different structure. */
490 const CPPType &type = computed_varray.type();
491 threading::parallel_for(mask.index_range(), 2048, [&](const IndexRange range) {
492 BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
493 mask.slice(range).foreach_segment([&](auto segment) {
494 for (const int i : segment) {
495 computed_varray.get_to_uninitialized(i, buffer);
496 dst_varray.set_by_relocate(i, buffer);
497 }
498 });
499 });
500 }
501 varrays[out_index] = dst_varray;
502 }
503 }
504 return varrays;
505}
506
507void evaluate_constant_field(const GField &field, void *r_value)
508{
509 if (field.depends_on_input()) {
510 const CPPType &type = field.cpp_type();
511 type.value_initialize(r_value);
512 return;
513 }
514
515 AlignedBuffer<512, 64> local_buffer;
516 ResourceScope scope(local_buffer);
517 FieldContext context;
518 Vector<GVArray> varrays = evaluate_fields(scope, {field}, IndexRange(1), context);
519 varrays[0].get_to_uninitialized(0, r_value);
520}
521
523{
524 if (field.depends_on_input()) {
525 return field;
526 }
527 const CPPType &type = field.cpp_type();
528 BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
529 evaluate_constant_field(field, buffer);
530 GField new_field = GField::from_constant(type, buffer);
531 type.destruct(buffer);
532 return new_field;
533}
534
536
537/* -------------------------------------------------------------------- */
540
542 const VArray<bool> &selection,
543 ResourceScope &scope)
544{
545 return IndexMask::from_bools(full_mask, selection, scope.allocator());
546}
547
549{
550 const int field_index = fields_to_evaluate_.append_and_get_index(std::move(field));
551 dst_varrays_.append(dst);
552 output_pointer_infos_.append({});
553 return field_index;
554}
555
557{
558 return this->add_with_destination(std::move(field), GVMutableArray::from_span(dst));
559}
560
561int FieldEvaluator::add(GField field, GVArray *varray_ptr)
562{
563 const int field_index = fields_to_evaluate_.append_and_get_index(std::move(field));
564 dst_varrays_.append(nullptr);
565 output_pointer_infos_.append(OutputPointerInfo{
566 varray_ptr, [](void *dst, const GVArray &varray, ResourceScope & /*scope*/) {
567 *static_cast<GVArray *>(dst) = varray;
568 }});
569 return field_index;
570}
571
573{
574 const int field_index = fields_to_evaluate_.append_and_get_index(std::move(field));
575 dst_varrays_.append(nullptr);
576 output_pointer_infos_.append({});
577 return field_index;
578}
579
580static IndexMask evaluate_selection(const Field<bool> &selection_field,
581 const FieldContext &context,
582 const IndexMask &full_mask,
583 ResourceScope &scope)
584{
585 VArray<bool> selection =
586 evaluate_fields(scope, {selection_field}, full_mask, context)[0].typed<bool>();
587 return index_mask_from_selection(full_mask, selection, scope);
588}
589
591{
592 BLI_assert_msg(!is_evaluated_, "Cannot evaluate fields twice.");
593
594 selection_mask_ = selection_field_ ?
595 evaluate_selection(*selection_field_, context_, mask_, scope_) :
596 mask_;
597
598 Vector<GFieldRef> fields;
599 fields.reserve(fields_to_evaluate_.size());
600 static constexpr bool true_value = true;
601 for (const int i : fields_to_evaluate_.index_range()) {
602 const GField &field = fields_to_evaluate_[i];
603 if (field == selection_field_) {
604 /* Avoid evaluating the selection field again. */
605 fields.append(GFieldRef::from_constant(CPPType::get<bool>(), &true_value));
606 }
607 else {
608 fields.append(field);
609 }
610 }
611 evaluated_varrays_ = evaluate_fields(scope_, fields, selection_mask_, context_, dst_varrays_);
612 BLI_assert(fields_to_evaluate_.size() == evaluated_varrays_.size());
613 for (const int i : fields_to_evaluate_.index_range()) {
614 OutputPointerInfo &info = output_pointer_infos_[i];
615 if (info.dst != nullptr) {
616 info.set(info.dst, evaluated_varrays_[i], scope_);
617 }
618 }
619 is_evaluated_ = true;
620}
621
623{
624 VArray<bool> varray = this->get_evaluated(field_index).typed<bool>();
625
626 if (varray.is_single()) {
627 if (varray.get_internal_single()) {
628 return IndexRange(varray.size());
629 }
630 return IndexRange(0);
631 }
632 return index_mask_from_selection(mask_, varray, scope_);
633}
634
636{
637 BLI_assert(is_evaluated_);
638 return selection_mask_;
639}
640
642
643} // namespace blender::fn
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
#define PRF_scope(category)
#define BLI_assert_unreachable()
#define BLI_assert_unreachable_static_t(T)
#define BLI_assert_msg(a, msg)
static const CPPType & get()
void destruct_indices(void *ptr, const IndexMask &mask) const
void destruct(void *ptr) const
void default_construct_indices(void *ptr, const IndexMask &mask) const
void value_initialize(void *ptr) const
GMutableSpan take_front(const int64_t n) const
static GVArray from_empty(const CPPType &type)
static GVArray from_single_default(const CPPType &type, int64_t size)
static GVArray from_span(GSpan span)
static GVArray from_single_ref(const CPPType &type, int64_t size, const void *value)
static GVMutableArray from_span(GMutableSpan span)
GMutableSpan get_internal_span() const
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
MutableSpan< T > allocate_array(int64_t size)
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
void add_new(const Key &key, const Value &value)
Definition BLI_map.hh:265
bool contains(const Key &key) const
Definition BLI_map.hh:353
T & construct(Args &&...args)
void add_destruct_call(Func func)
void * allocate_owned(const CPPType &type)
LinearAllocator & allocator()
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr bool is_empty() const
Definition BLI_span.hh:264
bool is_empty() const
Definition BLI_stack.hh:310
void push(const T &value)
Definition BLI_stack.hh:215
void append(const T &value)
bool is_empty() const
IndexRange index_range() const
void reserve(const int64_t min_capacity)
int add(GField field, GVArray *varray_ptr)
IndexMask get_evaluated_as_mask(int field_index)
IndexMask get_evaluated_selection_as_mask() const
int add_with_destination(GField field, GVMutableArray dst)
const GVArray & get_evaluated(const int field_index) const
StringRefNull debug_name() const
Definition FN_field.hh:569
const CPPType & cpp_type() const
Definition FN_field.hh:559
Span< GField > inputs() const
Definition FN_field.hh:654
const mf::MultiFunction & multi_function() const
Definition FN_field.hh:708
std::variant< Value, Input, MultiFn > Variant
Definition FN_field.hh:260
const CPPType & cpp_type() const
Definition FN_field.hh:683
const Variant & variant() const
Definition FN_field.hh:678
static GFieldRef from_constant(const CPPType &type, const void *value)
Definition FN_field.hh:668
bool depends_on_input() const
Definition FN_field.hh:614
static GField from_constant(const CPPType &type, const void *value)
Definition field.cc:24
const CPPType & cpp_type() const
Definition FN_field.hh:518
#define T
void copy(const GVArray &src, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
static Vector< GVArray > get_field_context_inputs(ResourceScope &scope, const IndexMask &mask, const FieldContext &context, const Span< GFieldRef > field_inputs)
static IndexMask index_mask_from_selection(const IndexMask full_mask, const VArray< bool > &selection, ResourceScope &scope)
static FieldTreeInfo preprocess_field_tree(Span< GFieldRef > entry_fields)
static void build_multi_function_procedure_for_fields(mf::Procedure &procedure, ResourceScope &scope, const FieldTreeInfo &field_tree_info, Span< GFieldRef > output_fields)
static IndexMask evaluate_selection(const Field< bool > &selection_field, const FieldContext &context, const IndexMask &full_mask, ResourceScope &scope)
Vector< GVArray > evaluate_fields(ResourceScope &scope, Span< GFieldRef > fields_to_evaluate, const IndexMask &mask, const FieldContext &context, Span< GVMutableArray > dst_varrays={})
static Set< UniqueHash > find_varying_fields(const FieldTreeInfo &field_tree_info, const Span< GVArray > field_context_inputs)
GField make_field_constant_if_possible(GField field)
void evaluate_constant_field(const GField &field, void *r_value)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ATTR_WARN_UNUSED_RESULT const BMVert * v
#define hash
Definition noise_c.cc:156
bool contains(const GFieldRef &field) const
Definition FN_field.hh:313
UniqueHash ensure(const GFieldRef &field)
Definition field.cc:113
UniqueHash lookup(const GFieldRef &field) const
Definition FN_field.hh:309
Vector< GFieldRef > deduplicated_inputs
VectorSet< UniqueHash > deduplicated_input_hashes
MultiValueMap< UniqueHash, UniqueHash > field_users