Blender V5.0
source/blender/depsgraph/intern/builder/pipeline.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "pipeline.h"
6
7#include "BLI_listbase.h"
8#include "BLI_time.h"
9
10#include "BKE_global.hh"
11
12#include "DNA_scene_types.h"
13
14#include "deg_builder_cycle.h"
15#include "deg_builder_nodes.h"
18
19namespace blender::deg {
20
22 : deg_graph_(reinterpret_cast<Depsgraph *>(graph)),
23 bmain_(deg_graph_->bmain),
24 scene_(deg_graph_->scene),
25 view_layer_(deg_graph_->view_layer)
26{
27}
28
30{
31 double start_time = 0.0;
33 start_time = BLI_time_now_seconds();
34 }
35
40
42 printf("Depsgraph built in %f seconds.\n", BLI_time_now_seconds() - start_time);
43 }
44}
45
52
54{
55 /* Generate all the nodes in the graph first */
56 std::unique_ptr<DepsgraphNodeBuilder> node_builder = construct_node_builder();
57 node_builder->begin_build();
58 build_nodes(*node_builder);
59 node_builder->end_build();
60}
61
63{
64 /* Hook up relationships between operations - to determine evaluation order. */
65 std::unique_ptr<DepsgraphRelationBuilder> relation_builder = construct_relation_builder();
66 relation_builder->begin_build();
67 build_relations(*relation_builder);
68 relation_builder->build_copy_on_write_relations();
69 relation_builder->build_driver_relations();
70}
71
73{
74 /* Detect and solve cycles. */
76 /* Simplify the graph by removing redundant relations (to optimize
77 * traversal later). */
78 /* TODO: it would be useful to have an option to disable this in cases where
79 * it is causing trouble. */
80 if (G.debug_value == 799) {
82 }
83 /* Store pointers to commonly used evaluated datablocks. */
84 deg_graph_->scene_cow = (Scene *)deg_graph_->get_cow_id(&deg_graph_->scene->id);
85 /* Flush visibility layer and re-schedule nodes for update. */
87 DEG_graph_tag_on_visible_update(reinterpret_cast<::Depsgraph *>(deg_graph_), false);
88#if 0
90 printf("Consistency validation failed, ABORTING!\n");
91 abort();
92 }
93#endif
94 /* Relations are up to date. */
95 deg_graph_->need_update_relations = false;
96}
97
98std::unique_ptr<DepsgraphNodeBuilder> AbstractBuilderPipeline::construct_node_builder()
99{
100 return std::make_unique<DepsgraphNodeBuilder>(bmain_, deg_graph_, &builder_cache_);
101}
102
103std::unique_ptr<DepsgraphRelationBuilder> AbstractBuilderPipeline::construct_relation_builder()
104{
105 return std::make_unique<DepsgraphRelationBuilder>(bmain_, deg_graph_, &builder_cache_);
106}
107
108} // namespace blender::deg
@ G_DEBUG_DEPSGRAPH_TIME
@ G_DEBUG_DEPSGRAPH_BUILD
#define BLI_assert(a)
Definition BLI_assert.h:46
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
Platform independent time functions.
double BLI_time_now_seconds(void)
Definition time.cc:113
void DEG_graph_tag_on_visible_update(Depsgraph *depsgraph, bool do_time)
bool DEG_debug_consistency_check(Depsgraph *graph)
virtual std::unique_ptr< DepsgraphNodeBuilder > construct_node_builder()
virtual void build_nodes(DepsgraphNodeBuilder &node_builder)=0
virtual std::unique_ptr< DepsgraphRelationBuilder > construct_relation_builder()
virtual void build_relations(DepsgraphRelationBuilder &relation_builder)=0
#define printf(...)
#define G(x, y, z)
void deg_graph_transitive_reduction(Depsgraph *graph)
void deg_graph_detect_cycles(Depsgraph *graph)
void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)