Blender V5.3
zone_operation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "DNA_node_types.h"
6
8#include "BKE_node.hh"
9#include "BKE_node_runtime.hh"
11
12#include "NOD_eval_log.hh"
13
14#include "COM_operation.hh"
15#include "COM_result.hh"
16#include "COM_scheduler.hh"
17#include "COM_utilities.hh"
19#include "COM_zone_operation.hh"
21
22namespace blender::compositor {
23
26 const ComputeContext &compute_context)
27 : Operation(context), zone_(zone), compute_context_(compute_context)
28{
29 /* Declare inputs. */
30 for (const bNodeSocket *input : this->zone().input_node()->input_sockets()) {
31 if (!is_socket_available(input)) {
32 continue;
33 }
34
35 const InputDescriptor input_descriptor = InputDescriptor{get_node_socket_result_type(input),
37 this->declare_input_descriptor(input->identifier, input_descriptor);
38 }
39
40 /* Declare inputs for border links. */
41 Set<const bNodeSocket *> outputs_already_considered;
42 for (const bNodeLink *link : zone_.border_links) {
43 const bNodeSocket *output = get_output_linked_to_input(*link->tosock);
44 if (!output) {
45 continue;
46 }
47
48 if (outputs_already_considered.contains(output)) {
49 continue;
50 }
51 outputs_already_considered.add_new(output);
52
53 const InputDescriptor input_descriptor = InputDescriptor{get_node_socket_result_type(output),
54 InputRealizationMode::None};
55 const std::string input_identifier = ZoneTreeOperation::get_external_input_identifier(*output);
56 this->declare_input_descriptor(input_identifier, input_descriptor);
57 }
58
59 /* Declare outputs. */
60 for (const bNodeSocket *output : this->zone().output_node()->output_sockets()) {
61 if (!is_socket_available(output)) {
62 continue;
63 }
64
65 this->populate_result(output->identifier, get_node_socket_result_type(output));
66 }
67}
68
70{
71 for (const bNodeSocket *output : this->zone().output_node()->output_sockets()) {
73 continue;
74 }
75
76 const int reference_count = compute_output_reference_count(*output, schedule);
77 this->get_result(output->identifier).set_reference_count(reference_count);
78 }
79}
80
82{
83 return zone_;
84}
85
87{
89 if (!log) {
90 return;
91 }
92 nodes::eval_log::NodeTreeLogger &tree_logger = log->get_local_tree_logger(compute_context_);
93
94 /* Log output values. */
95 for (const bNodeSocket *output_socket : this->zone().output_node()->output_sockets()) {
96 if (!is_socket_available(output_socket)) {
97 continue;
98 }
99
100 const Result &result = this->get_result(output_socket->identifier);
101 log_result(this->context(), tree_logger, *output_socket, result);
102 }
103
104 /* Log input values. */
105 for (const bNodeSocket *input_socket : this->zone().input_node()->input_sockets()) {
106 if (!is_socket_available(input_socket)) {
107 continue;
108 }
109
110 const Result &input = this->get_input(input_socket->identifier);
111 log_result(this->context(), tree_logger, *input_socket, input);
112 }
113}
114
115} // namespace blender::compositor
#define output
bool contains(const Key &key) const
Definition BLI_set.hh:310
void add_new(const Key &key)
Definition BLI_set.hh:233
Vector< const bNodeLink * > border_links
virtual nodes::eval_log::NodesEvalLog * nodes_evaluation_log() const
Result & get_result(StringRef identifier)
Definition operation.cc:40
Operation(Context &context)
Definition operation.cc:22
Context & context() const
Definition operation.cc:57
Result & get_input(StringRef identifier) const
Definition operation.cc:35
void declare_input_descriptor(StringRef identifier, InputDescriptor descriptor)
Definition operation.cc:127
const bke::bNodeTreeZone & zone() const
ZoneOperation(Context &context, const bke::bNodeTreeZone &zone, const ComputeContext &compute_context)
void compute_results_reference_counts(const Schedule &schedule)
static std::string get_external_input_identifier(const bNodeSocket &output)
#define log
int compute_output_reference_count(const bNodeSocket &output, const Schedule &schedule, const VectorSet< const bNode * > *ignored_nodes=nullptr)
Definition scheduler.cc:780
void log_result(Context &context, nodes::eval_log::NodeTreeLogger &logger, const bNodeSocket &socket, const Result &result)
ResultType get_node_socket_result_type(const bNodeSocket *socket)
Definition utilities.cc:103
bool is_socket_available(const bNodeSocket *socket)
Definition utilities.cc:26