Blender V4.5
COM_utilities.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "BLI_index_range.hh"
9#include "BLI_task.hh"
10
12
13#include "GPU_shader.hh"
14
16#include "COM_result.hh"
17
18namespace blender::compositor {
19
20using namespace nodes::derived_node_tree_types;
21
22/* Returns true if the socket is available and not virtual. Returns false otherwise. */
23bool is_socket_available(const bNodeSocket *socket);
24
32
38
41
47 FunctionRef<bool(DNode)> condition);
48
51 FunctionRef<bool(DInputSocket)> condition);
52
54bool is_pixel_node(DNode node);
55
58
67void compute_dispatch_threads_at_least(GPUShader *shader,
68 int2 threads_range,
69 int2 local_size = int2(16));
70
71/* Returns true if a node preview needs to be computed for the give node. */
72bool is_node_preview_needed(const DNode &node);
73
74/* Returns the node output that will be used to generate previews. */
76
77/* -------------------------------------------------------------------- */
78/* Inline Functions.
79 */
80
81/* Executes the given function in parallel over the given 2D range. The given function gets the
82 * texel coordinates of the element of the range as an argument. */
83template<typename Function> inline void parallel_for(const int2 range, const Function &function)
84{
85 threading::parallel_for(IndexRange(range.y), 1, [&](const IndexRange sub_y_range) {
86 for (const int64_t y : sub_y_range) {
87 for (const int64_t x : IndexRange(range.x)) {
88 function(int2(x, y));
89 }
90 }
91 });
92}
93
94} // namespace blender::compositor
struct bNodeSocket bNodeSocket
#define input
#define output
int number_of_inputs_linked_to_output_conditioned(DOutputSocket output, FunctionRef< bool(DInputSocket)> condition)
Definition utilities.cc:101
bool is_output_linked_to_node_conditioned(DOutputSocket output, FunctionRef< bool(DNode)> condition)
Definition utilities.cc:88
DSocket get_input_origin_socket(DInputSocket input)
Definition utilities.cc:30
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
Definition utilities.cc:170
DOutputSocket find_preview_output_socket(const DNode &node)
Definition utilities.cc:200
ResultType get_node_socket_result_type(const bNodeSocket *socket)
Definition utilities.cc:66
DOutputSocket get_output_linked_to_input(DInputSocket input)
Definition utilities.cc:50
InputDescriptor input_descriptor_from_input_socket(const bNodeSocket *socket)
Definition utilities.cc:144
void parallel_for(const int2 range, const Function &function)
bool is_pixel_node(DNode node)
Definition utilities.cc:118
bool is_socket_available(const bNodeSocket *socket)
Definition utilities.cc:25
bool is_node_preview_needed(const DNode &node)
Definition utilities.cc:180
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:93
VecBase< int32_t, 2 > int2