|
Blender V4.3
|
Classes | |
| struct | NodeInContextDownstreamComparator |
| struct | NodeInContextUpstreamComparator |
| struct | UpstreamEvalTargets |
Functions | |
| bool | is_supported_value_node (const bNode &node) |
| static Vector< int > | get_global_node_sort_vector_right_to_left (const ComputeContext *initial_context, const bNode &initial_node) |
| static Vector< int > | get_global_node_sort_vector_left_to_right (const ComputeContext *initial_context, const bNode &initial_node) |
| void | eval_downstream (const Span< SocketInContext > initial_sockets, ResourceScope &scope, FunctionRef< void(const NodeInContext &ctx_node, Vector< const bNodeSocket * > &r_outputs_to_propagate)> evaluate_node_fn, FunctionRef< bool(const SocketInContext &ctx_from, const SocketInContext &ctx_to)> propagate_value_fn) |
| UpstreamEvalTargets | eval_upstream (const Span< SocketInContext > initial_sockets, ResourceScope &scope, FunctionRef< void(const NodeInContext &ctx_node, Vector< const bNodeSocket * > &r_modified_inputs)> evaluate_node_fn, FunctionRef< bool(const SocketInContext &ctx_from, const SocketInContext &ctx_to)> propagate_value_fn, FunctionRef< void(const NodeInContext &ctx_node, Vector< const bNodeSocket * > &r_sockets)> get_inputs_to_propagate_fn) |
This header provides functionality that makes it relatively straight forward to evaluate parts of a node tree. The evaluator is designed to be flexible and simple to use in different contexts. It's not designed to be highly efficient and parallel. However, it has a lower start-up cost compared to e.g. the lazy-function evaluation for geometry nodes, which needs to convert the entire node graph into a lazy-function graph first. So it can be more efficient when only very few nodes of a larger graph have to be evaluated and those nodes are cheap.
The evaluator does not use recursion, so it can be used on node graphs of every size and depth.
| void blender::nodes::partial_eval::eval_downstream | ( | const Span< SocketInContext > | initial_sockets, |
| ResourceScope & | scope, | ||
| FunctionRef< void(const NodeInContext &ctx_node, Vector< const bNodeSocket * > &r_outputs_to_propagate)> | evaluate_node_fn, | ||
| FunctionRef< bool(const SocketInContext &ctx_from, const SocketInContext &ctx_to)> | propagate_value_fn ) |
Evaluating part of a node tree from left-to-right. The part that's evaluated starts at the given sockets and is propagated downstream step-by-step. The caller is responsible for storing the socket values (a value per #SocketInContext).
| initial_sockets | Sockets where the evaluation should start. |
| scope | Is used to construct compute contexts which the caller may want to outlive the entire evaluation. |
| evaluate_node_fn | Is called when all (relevant) upstream nodes are already evaluated and evaluates the given node. This should updated the values the caller stores for the output sockets. |
| propagate_value_fn | Should copy the value stored for one socket to the other socket. This may have to do type conversions. The return value indicates success. False indicates that the value was not propagated and as such the target node also shouldn't be evaluated (unless there are other reasons to evaluate it). |
Definition at line 106 of file partial_eval.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), BLI_assert, blender::Vector< T, InlineBufferCapacity, Allocator >::clear(), blender::ResourceScope::construct(), blender::nodes::NodeInContext::context, blender::nodes::NodeInContext::node, and node.
Referenced by blender::nodes::inverse_eval::foreach_element_on_inverse_eval_path().
| UpstreamEvalTargets blender::nodes::partial_eval::eval_upstream | ( | const Span< SocketInContext > | initial_sockets, |
| ResourceScope & | scope, | ||
| FunctionRef< void(const NodeInContext &ctx_node, Vector< const bNodeSocket * > &r_modified_inputs)> | evaluate_node_fn, | ||
| FunctionRef< bool(const SocketInContext &ctx_from, const SocketInContext &ctx_to)> | propagate_value_fn, | ||
| FunctionRef< void(const NodeInContext &ctx_node, Vector< const bNodeSocket * > &r_sockets)> | get_inputs_to_propagate_fn ) |
Evaluates part of a node tree from right-to-left (inverse direction). The caller is responsible for storing the socket values (a value per #SocketInContext). Evaluation in the upstream direction is not always well defined, because output sockets may be linked to multiple inputs and nodes may not always have an inverse evaluation function. The caller is responsible for handling these cases gracefully in the given callbacks.
| initial_sockets | Sockets where the evaluation should start. |
| scope | Is used to construct compute contexts which the caller may want to outlive the entire evaluation. |
| evaluate_node_fn | Called to evaluate the node in reverse, i.e. it's outputs are computed first, and the node evaluation computes the inputs. |
| propagate_value_fn | Should copy the value from one socket to another, while optionally doing type conversions. This has to handle the case when multiple values are propagated to the same socket. Returning false indicates that no value was propagated. |
| get_inputs_to_propagate_fn | Gathers a list of input sockets that should be propagated further. |
Definition at line 248 of file partial_eval.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Vector< T, InlineBufferCapacity, Allocator >::clear(), blender::ResourceScope::construct(), blender::nodes::NodeInContext::context, blender::nodes::partial_eval::UpstreamEvalTargets::group_inputs, bNode::id, is_supported_value_node(), blender::nodes::NodeInContext::node, blender::ComputeContext::parent(), blender::nodes::partial_eval::UpstreamEvalTargets::sockets, and blender::nodes::partial_eval::UpstreamEvalTargets::value_nodes.
Referenced by blender::nodes::inverse_eval::backpropagate_socket_values(), blender::nodes::inverse_eval::find_local_inverse_eval_targets(), and blender::nodes::inverse_eval::foreach_element_on_inverse_eval_path().
|
static |
Same as above but for the case when evaluating nodes in the opposite order.
Definition at line 46 of file partial_eval.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::begin(), BLI_assert, blender::Vector< T, InlineBufferCapacity, Allocator >::end(), blender::ComputeContext::parent(), and bNode::runtime.
Referenced by blender::nodes::partial_eval::NodeInContextDownstreamComparator::operator()().
|
static |
Creates a vector of integer for a node in a context that can be used to order them for evaluation.
Definition at line 29 of file partial_eval.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::begin(), BLI_assert, blender::Vector< T, InlineBufferCapacity, Allocator >::end(), blender::ComputeContext::parent(), and bNode::runtime.
Referenced by blender::nodes::partial_eval::NodeInContextUpstreamComparator::operator()().
| bool blender::nodes::partial_eval::is_supported_value_node | ( | const bNode & | node | ) |
Definition at line 15 of file partial_eval.cc.
References ELEM, and SH_NODE_VALUE.
Referenced by eval_upstream(), and blender::ed::space_node::std_node_socket_draw().