Blender V5.3
node_tree_logging.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
7#include "BKE_node.hh"
8#include "BKE_node_runtime.hh"
9
10#include "NOD_eval_log.hh"
11
12#include "COM_bundle_item.hh"
13#include "COM_result.hh"
14#include "COM_utilities.hh"
16
17namespace blender::compositor {
18
33
35 Context &context, LinearAllocator<> *allocator, const Result &result)
36{
38 for (const auto &item : result.get_single_value<nodes::BundlePtr>()->items()) {
39 Result bundle_result = BundleItem::get_result(context, item.value);
40 BLI_SCOPED_DEFER([&]() { bundle_result.release(); });
41 items.append({item.key.ustr(), {Result::type_name(bundle_result.type())}});
42 }
43 return allocator->construct<nodes::eval_log::BundleValueLog>(std::move(items));
44}
45
47 LinearAllocator<> *allocator, const Result &result)
48{
51 const ClosurePtr &closure = result.get_single_value<ClosurePtr>();
52 if (!closure) {
54 std::move(inputs), std::move(outputs), std::nullopt, nullptr);
55 }
56
57 for (const bNodeSocket *input : closure->zone.input_node()->output_sockets()) {
58 if (is_socket_available(input)) {
59 inputs.append({input->name, input->typeinfo});
60 }
61 }
62
63 for (const bNodeSocket *output : closure->zone.output_node()->input_sockets()) {
65 outputs.append({output->name, output->typeinfo});
66 }
67 }
68
69 const nodes::ClosureSourceLocation closure_source_location{
70 &closure->zone.output_node()->owner_tree(),
71 closure->zone.output_node()->identifier,
72 closure->compute_context.hash(),
73 &closure->compute_context};
74
76 std::move(inputs), std::move(outputs), closure_source_location, nullptr);
77}
78
79void log_result(Context &context,
81 const bNodeSocket &socket,
82 const Result &result)
83{
84 if (!result.is_allocated()) {
85 return;
86 }
87
88 auto &socket_values = socket.in_out == SOCK_IN ? logger.input_socket_values :
90
91 if (!result.is_single_value()) {
92 socket_values.append(*logger.allocator,
93 {socket.owner_node().identifier,
94 socket.index(),
95 get_image_info_log(logger.allocator, result)});
96 return;
97 }
98
99 if (result.type() == ResultType::Closure) {
100 socket_values.append(*logger.allocator,
101 {socket.owner_node().identifier,
102 socket.index(),
103 get_closure_info_log(logger.allocator, result)});
104 return;
105 }
106
107 if (result.type() == ResultType::Bundle) {
108 socket_values.append(*logger.allocator,
109 {socket.owner_node().identifier,
110 socket.index(),
111 get_bundle_info_log(context, logger.allocator, result)});
112 return;
113 }
114
115 logger.log_value(socket.owner_node(), socket, result.single_value());
116}
117
118} // namespace blender::compositor
#define BLI_SCOPED_DEFER(function_to_defer)
#define output
const ComputeContextHash & hash() const
destruct_ptr< T > construct(Args &&...args)
const bNode * output_node() const
const bNode * input_node() const
static Result get_result(Context &context, const nodes::BundleItemValue &item_value)
const ComputeContext & compute_context
const bke::bNodeTreeZone & zone
RealizationOptions realization_options
static const char * type_name(const ResultType type)
Definition result.cc:424
static ResultType type(gpu::TextureFormat format)
Definition result.cc:337
linear_allocator::ChunkedList< SocketValueLog, 16 > input_socket_values
linear_allocator::ChunkedList< SocketValueLog, 16 > output_socket_values
void log_value(const bNode &node, const bNodeSocket &socket, GPointer value)
Definition eval_log.cc:319
StringRefNull to_string(const Interpolation &interpolation)
Definition domain.cc:112
static destruct_ptr< nodes::eval_log::BundleValueLog > get_bundle_info_log(Context &context, LinearAllocator<> *allocator, const Result &result)
void log_result(Context &context, nodes::eval_log::NodeTreeLogger &logger, const bNodeSocket &socket, const Result &result)
ImplicitSharingPtr< Closure > ClosurePtr
static destruct_ptr< nodes::eval_log::ClosureValueLog > get_closure_info_log(LinearAllocator<> *allocator, const Result &result)
static destruct_ptr< nodes::eval_log::ImageInfoLog > get_image_info_log(LinearAllocator<> *allocator, const Domain &domain, const ResultPrecision &precision)
bool is_socket_available(const bNodeSocket *socket)
Definition utilities.cc:26
ImplicitSharingPtr< Bundle > BundlePtr
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr
eNodeSocketInOut in_out