Blender V5.0
pixel_operation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include <limits>
6#include <string>
7
8#include "BLI_map.hh"
9#include "BLI_string_ref.hh"
10
12
14#include "COM_context.hh"
16#include "COM_operation.hh"
18#include "COM_result.hh"
19#include "COM_scheduler.hh"
21#include "COM_utilities.hh"
22
23namespace blender::compositor {
24
25using namespace nodes::derived_node_tree_types;
26
28 PixelCompileUnit &compile_unit,
29 const Schedule &schedule)
30 : Operation(context), compile_unit_(compile_unit), schedule_(schedule)
31{
32}
33
35{
36 if (context.use_gpu()) {
37 /* The GPU module currently only supports up to 8 output images in shaders, but once this
38 * limitation is lifted, we can replace that with GPU_max_images(). */
39 return 8;
40 }
41
42 return std::numeric_limits<int>::max();
43}
44
46{
50 /* Preview results gets as an extra reference in pixel operations as can be seen in the
51 * compute_results_reference_counts method, so release it after computing preview. */
52 result.release();
53 }
54}
55
60
65
70
72{
73 return inputs_to_reference_counts_map_.lookup(identifier);
74}
75
77{
78 for (const auto item : output_sockets_to_output_identifiers_map_.items()) {
80 item.key, [&](DInputSocket input) {
81 /* We only consider inputs that are not part of the pixel operations, because inputs
82 * that are part of the pixel operations are internal and do not deal with the result
83 * directly. */
84 return schedule.contains(input.node()) && !compile_unit_.contains(input.node());
85 });
86
87 if (preview_outputs_.contains(item.key)) {
88 reference_count++;
89 }
90
91 get_result(item.value).set_reference_count(reference_count);
92 }
93}
94
95} // namespace blender::compositor
Result & get_result(StringRef identifier)
Definition operation.cc:39
Operation(Context &context)
Definition operation.cc:22
StringRef get_output_identifier_from_output_socket(DOutputSocket output_socket)
Map< std::string, DOutputSocket > inputs_to_linked_outputs_map_
Map< std::string, int > inputs_to_reference_counts_map_
Map< std::string, DOutputSocket > & get_inputs_to_linked_outputs_map()
int get_internal_input_reference_count(const StringRef &identifier)
VectorSet< DOutputSocket > preview_outputs_
Map< DOutputSocket, std::string > output_sockets_to_output_identifiers_map_
PixelOperation(Context &context, PixelCompileUnit &compile_unit, const Schedule &schedule)
Map< ImplicitInput, std::string > implicit_inputs_to_input_identifiers_map_
static int maximum_number_of_outputs(Context &context)
void compute_results_reference_counts(const Schedule &schedule)
Map< ImplicitInput, std::string > & get_implicit_inputs_to_input_identifiers_map()
void set_reference_count(int count)
Definition result.cc:640
#define input
#define output
int number_of_inputs_linked_to_output_conditioned(DOutputSocket output, FunctionRef< bool(DInputSocket)> condition)
Definition utilities.cc:126
VectorSet< DNode > Schedule
VectorSet< DNode > PixelCompileUnit
void compute_preview(Context &context, const nodes::DNode &node, const Result &input_result)