Blender V4.3
NOD_geometry_nodes_lazy_function.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
23#include <variant>
24
27
29#include "NOD_multi_function.hh"
30
33
34#include "BKE_bake_items.hh"
36
37struct Object;
38struct Depsgraph;
39struct Scene;
40
41namespace blender::nodes {
42
43using lf::LazyFunction;
44using mf::MultiFunction;
45
47namespace sim_input {
48
53struct PassThrough {};
54
62
72
73using Behavior = std::variant<PassThrough, OutputCopy, OutputMove>;
74
75} // namespace sim_input
76
78namespace sim_output {
79
84struct PassThrough {};
85
91 std::function<void(bke::bake::BakeState state)> store_fn;
92};
93
100
110
114struct ReadError {
115 std::string message;
116};
117
118using Behavior = std::variant<PassThrough, StoreNewState, ReadSingle, ReadInterpolated, ReadError>;
119
120} // namespace sim_output
121
128
130 public:
136 virtual SimulationZoneBehavior *get(const int zone_id) const = 0;
137};
138
144
146 public:
147 virtual BakeNodeBehavior *get(const int id) const = 0;
148};
149
158
164 const Object *self_object = nullptr;
166 Depsgraph *depsgraph = nullptr;
167};
168
171 const Depsgraph *active = nullptr;
176 Depsgraph *extra = nullptr;
177
179
186 const ID *get_evaluated_id(const ID &id_orig) const;
187};
188
209
257
278
280 private:
285 mutable std::optional<geo_eval_log::GeoTreeLogger *> tree_logger_;
286
287 public:
289
295 {
296 if (!tree_logger_.has_value()) {
297 this->ensure_tree_logger(user_data);
298 }
299 return *tree_logger_;
300 }
301
302 private:
303 void ensure_tree_logger(const GeoNodesLFUserData &user_data) const;
304};
305
315 Never,
320};
321
327
357
403
428
429std::unique_ptr<LazyFunction> get_simulation_output_lazy_function(
430 const bNode &node, GeometryNodesLazyFunctionGraphInfo &own_lf_graph_info);
431std::unique_ptr<LazyFunction> get_simulation_input_lazy_function(
432 const bNodeTree &node_tree,
433 const bNode &node,
434 GeometryNodesLazyFunctionGraphInfo &own_lf_graph_info);
435std::unique_ptr<LazyFunction> get_switch_node_lazy_function(const bNode &node);
436std::unique_ptr<LazyFunction> get_index_switch_node_lazy_function(
437 const bNode &node, GeometryNodesLazyFunctionGraphInfo &lf_graph_info);
438std::unique_ptr<LazyFunction> get_bake_lazy_function(
439 const bNode &node, GeometryNodesLazyFunctionGraphInfo &own_lf_graph_info);
440std::unique_ptr<LazyFunction> get_menu_switch_node_lazy_function(
441 const bNode &node, GeometryNodesLazyFunctionGraphInfo &lf_graph_info);
442std::unique_ptr<LazyFunction> get_menu_switch_node_socket_usage_lazy_function(const bNode &node);
443std::unique_ptr<LazyFunction> get_warning_node_lazy_function(const bNode &node);
444
452
455 StringRef socket_name);
456
458 int id;
459 bool is_in_simulation = false;
460 bool is_in_loop = false;
461};
462
463std::optional<FoundNestedNodeID> find_nested_node_id(const GeoNodesLFUserData &user_data,
464 const int node_id);
465
472 const bNodeTree &btree);
473
479 private:
480 lf::Context &context_;
482
483 public:
484 ScopedComputeContextTimer(lf::Context &entered_context) : context_(entered_context)
485 {
486 start_ = geo_eval_log::Clock::now();
487 }
488
490 {
491 const geo_eval_log::TimePoint end = geo_eval_log::Clock::now();
492 auto &user_data = static_cast<GeoNodesLFUserData &>(*context_.user_data);
493 auto &local_user_data = static_cast<GeoNodesLFLocalUserData &>(*context_.local_user_data);
494 if (geo_eval_log::GeoTreeLogger *tree_logger = local_user_data.try_get_tree_logger(user_data))
495 {
496 tree_logger->execution_time += (end - start_);
497 }
498 }
499};
500
505 private:
506 const lf::Context &context_;
507 const bNode &node_;
509
510 public:
511 ScopedNodeTimer(const lf::Context &context, const bNode &node) : context_(context), node_(node)
512 {
513 start_ = geo_eval_log::Clock::now();
514 }
515
517 {
518 const geo_eval_log::TimePoint end = geo_eval_log::Clock::now();
519 auto &user_data = static_cast<GeoNodesLFUserData &>(*context_.user_data);
520 auto &local_user_data = static_cast<GeoNodesLFLocalUserData &>(*context_.local_user_data);
521 if (geo_eval_log::GeoTreeLogger *tree_logger = local_user_data.try_get_tree_logger(user_data))
522 {
523 tree_logger->node_execution_times.append(*tree_logger->allocator,
524 {node_.identifier, start_, end});
525 }
526 }
527};
528
529} // namespace blender::nodes
eObjectMode
virtual BakeNodeBehavior * get(const int id) const =0
virtual SimulationZoneBehavior * get(const int zone_id) const =0
ScopedNodeTimer(const lf::Context &context, const bNode &node)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
static ulong state[N]
std::variant< PassThrough, OutputCopy, OutputMove > Behavior
std::variant< PassThrough, StoreNewState, ReadSingle, ReadInterpolated, ReadError > Behavior
std::unique_ptr< LazyFunction > get_simulation_output_lazy_function(const bNode &node, GeometryNodesLazyFunctionGraphInfo &own_lf_graph_info)
std::unique_ptr< LazyFunction > get_index_switch_node_lazy_function(const bNode &node, GeometryNodesLazyFunctionGraphInfo &lf_graph_info)
std::unique_ptr< LazyFunction > get_warning_node_lazy_function(const bNode &node)
std::unique_ptr< LazyFunction > get_menu_switch_node_socket_usage_lazy_function(const bNode &node)
std::unique_ptr< LazyFunction > get_simulation_input_lazy_function(const bNodeTree &node_tree, const bNode &node, GeometryNodesLazyFunctionGraphInfo &own_lf_graph_info)
std::unique_ptr< LazyFunction > get_switch_node_lazy_function(const bNode &node)
std::string make_anonymous_attribute_socket_inspection_string(const bNodeSocket &socket)
std::unique_ptr< LazyFunction > get_bake_lazy_function(const bNode &node, GeometryNodesLazyFunctionGraphInfo &lf_graph_info)
const GeometryNodesLazyFunctionGraphInfo * ensure_geometry_nodes_lazy_function_graph(const bNodeTree &btree)
void set_default_remaining_node_outputs(lf::Params &params, const bNode &node)
std::optional< FoundNestedNodeID > find_nested_node_id(const GeoNodesLFUserData &user_data, const int node_id)
std::unique_ptr< LazyFunction > get_menu_switch_node_lazy_function(const bNode &node, GeometryNodesLazyFunctionGraphInfo &lf_graph_info)
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr
Definition DNA_ID.h:413
int32_t identifier
const Set< ComputeContextHash > * socket_log_contexts
const GeoNodesSideEffectNodes * side_effect_nodes
geo_eval_log::GeoTreeLogger * try_get_tree_logger(const GeoNodesLFUserData &user_data) const
destruct_ptr< lf::LocalUserData > get_local(LinearAllocator<> &allocator) override
MultiValueMap< std::pair< ComputeContextHash, int32_t >, int > iterations_by_iteration_zone
MultiValueMap< ComputeContextHash, const lf::FunctionNode * > nodes_by_context
Map< const bke::bNodeTreeZone *, const lf::FunctionNode * > zone_node_map
MultiValueMap< const lf::Socket *, const bNodeSocket * > bsockets_by_lf_socket_map
Map< const bNode *, const lf::FunctionNode * > possible_side_effect_node_map
Map< const bNode *, const lf::FunctionNode * > group_node_map
struct blender::nodes::GeometryNodesGroupFunction::@1338 outputs
struct blender::nodes::GeometryNodesGroupFunction::@1337::@1339 attributes_to_propagate
struct blender::nodes::GeometryNodesGroupFunction::@1337 inputs
std::function< void(bke::bake::BakeState state)> store_fn