Blender V5.3
lazy_function_graph_executor.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
10
11/* The entire executor is included here. Otherwise an additional indirection using forward
12 * declarations of #GenericGraphExecutor would be needed. However, there isn't really a point in
13 * having that because it's tightly coupled to #GraphExecutor anyway. It's only defined in a
14 * separate file for code organization purposes. */
16
18
20 const Logger *logger,
21 const SideEffectProvider *side_effect_provider,
22 const NodeExecuteWrapper *node_execute_wrapper)
23 : GraphExecutor(graph,
24 Vector<const GraphInputSocket *>(graph.graph_inputs()),
25 Vector<const GraphOutputSocket *>(graph.graph_outputs()),
26 logger,
27 side_effect_provider,
28 node_execute_wrapper)
29{
30}
31
35 const Logger *logger,
36 const SideEffectProvider *side_effect_provider,
37 const NodeExecuteWrapper *node_execute_wrapper)
38 : graph_(graph),
39 graph_inputs_(std::move(graph_inputs)),
40 graph_outputs_(std::move(graph_outputs)),
41 graph_input_index_by_socket_index_(graph.graph_inputs().size(), -1),
42 graph_output_index_by_socket_index_(graph.graph_outputs().size(), -1),
43 logger_(logger),
44 side_effect_provider_(side_effect_provider),
45 node_execute_wrapper_(node_execute_wrapper)
46{
47 debug_name_ = graph.name().c_str();
48
49 /* The graph executor can handle partial execution when there are still missing inputs. */
51
52 for (const int i : graph_inputs_.index_range()) {
53 const OutputSocket &socket = *graph_inputs_[i];
54 BLI_assert(socket.node().is_interface());
55 inputs_.append({"In", socket.type(), ValueUsage::Maybe});
56 graph_input_index_by_socket_index_[socket.index()] = i;
57 }
58 for (const int i : graph_outputs_.index_range()) {
59 const InputSocket &socket = *graph_outputs_[i];
60 BLI_assert(socket.node().is_interface());
61 outputs_.append({"Out", socket.type()});
62 graph_output_index_by_socket_index_[socket.index()] = i;
63 }
64
65 GenericExecutor::preprocess_graph(*this);
66}
67
68void GraphExecutor::execute_impl(Params &params, const Context &context) const
69{
70 GenericExecutor &executor = *static_cast<GenericExecutor *>(context.storage);
71 executor.execute(params, context);
72}
73
75{
76 GenericExecutor &executor = *allocator.construct<GenericExecutor>(*this).release();
77 return &executor;
78}
79
81{
82 std::destroy_at(static_cast<GenericExecutor *>(storage));
83}
84
85std::string GraphExecutor::input_name(const int index) const
86{
87 const lf::OutputSocket &socket = *graph_inputs_[index];
88 return socket.name();
89}
90
91std::string GraphExecutor::output_name(const int index) const
92{
93 const lf::InputSocket &socket = *graph_outputs_[index];
94 return socket.name();
95}
96
102
104 const GPointer value,
105 const Context &context) const
106{
107 UNUSED_VARS(socket, value, context);
108}
109
111 const Params &params,
112 const Context &context) const
113{
114 UNUSED_VARS(node, params, context);
115}
116
118 const Params &params,
119 const Context &context) const
120{
121 UNUSED_VARS(node, params, context);
122}
123
130
132 Span<const OutputSocket *> missing_sockets,
133 const Context &context) const
134{
135 UNUSED_VARS(node, missing_sockets, context);
136}
137
139 const OutputSocket &from_socket,
140 const Context &context) const
141{
142 UNUSED_VARS(target_socket, from_socket, context);
143}
144
145} // namespace blender::fn::lazy_function
#define UNUSED_VARS(...)
destruct_ptr< T > construct(Args &&...args)
virtual void log_before_node_execute(const FunctionNode &node, const Params &params, const Context &context) const
virtual void dump_when_outputs_are_missing(const FunctionNode &node, Span< const OutputSocket * > missing_sockets, const Context &context) const
virtual void log_after_node_execute(const FunctionNode &node, const Params &params, const Context &context) const
virtual void log_socket_value(const Socket &socket, GPointer value, const Context &context) const
virtual LoggingEnabledState get_logging_enabled_state(const Context &context) const
virtual void dump_when_input_is_set_twice(const InputSocket &target_socket, const OutputSocket &from_socket, const Context &context) const
virtual Vector< const FunctionNode * > get_nodes_with_side_effects(const Context &context) const
void * init_storage(LinearAllocator<> &allocator) const override
std::string output_name(int index) const override
std::string input_name(int index) const override
GraphExecutor(const Graph &graph, const Logger *logger, const SideEffectProvider *side_effect_provider, const NodeExecuteWrapper *node_execute_wrapper)
generic_graph_executor::GenericGraphExecutor GenericExecutor
void destruct_storage(void *storage) const override
#define storage(slot, qualifiers)