Blender
V5.3
source
blender
compositor
COM_scheduler.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_function_ref.hh
"
8
#include "
BLI_set.hh
"
9
#include "
BLI_vector_set.hh
"
10
11
namespace
blender
{
12
struct
bNodeTree
;
13
struct
bNode
;
14
struct
bNodeSocket
;
15
struct
ComputeContextHash
;
16
class
ComputeContext
;
17
18
namespace
bke
{
19
class
bNodeTreeZone
;
20
}
21
22
}
// namespace blender
23
24
namespace
blender::compositor
{
25
26
class
Context
;
27
class
Result
;
28
29
struct
Schedule
{
30
/* The node group the schedule is for. */
31
const
bNodeTree
&
node_group
;
32
/* The zone that the schedule is for, if nullptr, the schedule is for the root node tree. */
33
const
bke::bNodeTreeZone
*
zone
=
nullptr
;
34
/* The node execution schedule. */
35
VectorSet<const bNode *>
nodes
;
36
/* Holds the set of all inputs sockets that needn't be computed because the node does not need
37
* them, for instance, the unneeded inputs of a Switch node. */
38
Set<const bNodeSocket *>
unneeded_inputs
;
39
};
40
41
/* A function that returns the result associated with the given socket if it is known statically
42
* and nullptr otherwise. For instance, the results associated with the sockets of the Group Input
43
* and Group Output nodes are known statically because they are those of the node group operation
44
* itself, not a node that is yet to be compiled and evaluated. */
45
using
SocketResultFn
=
FunctionRef
<
Result
*(
const
bNodeSocket
&)>;
46
47
/* Computes the execution schedule of the given node group in the given compute context. If the
48
* results associated with some of the sockets are known, the socket_result_fn callback should
49
* provide them. Only output types and node group outputs that are needed are computed. If a zone
50
* is provided, then only nodes in the zone are scheduled. The execution schedule only includes the
51
* zone output node of child zones, the caller will have to recursively schedule zones to fully
52
* schedule the node tree.
53
*
54
* This is essentially a post-order depth first traversal of the node tree from the needed output
55
* nodes to the leaf input nodes, with informed order of traversal of dependencies based on a
56
* heuristic estimation of the number of needed buffers. */
57
Schedule
compute_schedule
(
const
Context
&context,
58
const
bNodeTree
&node_group,
59
const
ComputeContext
&compute_context,
60
SocketResultFn
socket_result_fn,
61
const
bke::bNodeTreeZone
*zone =
nullptr
);
62
63
/* Computes how many times the given output is referenced in the given schedule, ignoring outgoing
64
* links to the given ignored nodes if not nullptr. */
65
int
compute_output_reference_count
(
const
bNodeSocket
&
output
,
66
const
Schedule
&schedule,
67
const
VectorSet<const bNode *>
*ignored_nodes =
nullptr
);
68
69
}
// namespace blender::compositor
BLI_function_ref.hh
BLI_set.hh
BLI_vector_set.hh
output
#define output
blender::ComputeContext
Definition
BLI_compute_context.hh:80
blender::FunctionRef
Definition
BLI_function_ref.hh:72
blender::Set
Definition
BLI_set.hh:106
blender::VectorSet
Definition
BLI_vector_set.hh:94
blender::bke::bNodeTreeZone
Definition
BKE_node_tree_zones.hh:23
blender::compositor::Context
Definition
COM_context.hh:53
blender::compositor::Result
Definition
COM_result.hh:125
blender::bke
Definition
AS_asset_library.hh:32
blender::compositor
Definition
BKE_node.hh:77
blender::compositor::compute_output_reference_count
int compute_output_reference_count(const bNodeSocket &output, const Schedule &schedule, const VectorSet< const bNode * > *ignored_nodes=nullptr)
Definition
scheduler.cc:780
blender::compositor::compute_schedule
Schedule compute_schedule(const Context &context, const bNodeTree &node_group, const ComputeContext &compute_context, SocketResultFn socket_result_fn, const bke::bNodeTreeZone *zone=nullptr)
Definition
scheduler.cc:720
blender::compositor::SocketResultFn
FunctionRef< Result *(const bNodeSocket &)> SocketResultFn
Definition
COM_scheduler.hh:45
blender
BMesh Iterators.
Definition
ANIM_action.hh:30
blender::ComputeContextHash
Definition
BLI_compute_context.hh:48
blender::bNodeSocket
Definition
DNA_node_types.h:1447
blender::bNodeTree
Definition
DNA_node_types.h:1891
blender::bNode
Definition
DNA_node_types.h:1641
blender::compositor::Schedule
Definition
COM_scheduler.hh:29
blender::compositor::Schedule::unneeded_inputs
Set< const bNodeSocket * > unneeded_inputs
Definition
COM_scheduler.hh:38
blender::compositor::Schedule::zone
const bke::bNodeTreeZone * zone
Definition
COM_scheduler.hh:33
blender::compositor::Schedule::nodes
VectorSet< const bNode * > nodes
Definition
COM_scheduler.hh:35
blender::compositor::Schedule::node_group
const bNodeTree & node_group
Definition
COM_scheduler.hh:31
Generated on
for Blender by
doxygen
1.18.0