Blender  V3.3
source/blender/depsgraph/intern/builder/pipeline.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 
4 #include "pipeline.h"
5 
6 #include "PIL_time.h"
7 
8 #include "BKE_global.h"
9 
10 #include "DNA_scene_types.h"
11 
12 #include "deg_builder_cycle.h"
13 #include "deg_builder_nodes.h"
14 #include "deg_builder_relations.h"
15 #include "deg_builder_transitive.h"
16 
17 namespace blender::deg {
18 
20  : deg_graph_(reinterpret_cast<Depsgraph *>(graph)),
21  bmain_(deg_graph_->bmain),
22  scene_(deg_graph_->scene),
23  view_layer_(deg_graph_->view_layer)
24 {
25 }
26 
28 {
29  double start_time = 0.0;
31  start_time = PIL_check_seconds_timer();
32  }
33 
38 
40  printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
41  }
42 }
43 
45 {
49 }
50 
52 {
53  /* Generate all the nodes in the graph first */
54  unique_ptr<DepsgraphNodeBuilder> node_builder = construct_node_builder();
55  node_builder->begin_build();
56  build_nodes(*node_builder);
57  node_builder->end_build();
58 }
59 
61 {
62  /* Hook up relationships between operations - to determine evaluation order. */
63  unique_ptr<DepsgraphRelationBuilder> relation_builder = construct_relation_builder();
64  relation_builder->begin_build();
65  build_relations(*relation_builder);
66  relation_builder->build_copy_on_write_relations();
67  relation_builder->build_driver_relations();
68 }
69 
71 {
72  /* Detect and solve cycles. */
74  /* Simplify the graph by removing redundant relations (to optimize
75  * traversal later). */
76  /* TODO: it would be useful to have an option to disable this in cases where
77  * it is causing trouble. */
78  if (G.debug_value == 799) {
80  }
81  /* Store pointers to commonly used evaluated datablocks. */
83  /* Flush visibility layer and re-schedule nodes for update. */
85  DEG_graph_tag_on_visible_update(reinterpret_cast<::Depsgraph *>(deg_graph_), false);
86 #if 0
88  printf("Consistency validation failed, ABORTING!\n");
89  abort();
90  }
91 #endif
92  /* Relations are up to date. */
94 }
95 
96 unique_ptr<DepsgraphNodeBuilder> AbstractBuilderPipeline::construct_node_builder()
97 {
98  return std::make_unique<DepsgraphNodeBuilder>(bmain_, deg_graph_, &builder_cache_);
99 }
100 
101 unique_ptr<DepsgraphRelationBuilder> AbstractBuilderPipeline::construct_relation_builder()
102 {
103  return std::make_unique<DepsgraphRelationBuilder>(bmain_, deg_graph_, &builder_cache_);
104 }
105 
106 } // namespace blender::deg
@ G_DEBUG_DEPSGRAPH_TIME
Definition: BKE_global.h:185
@ G_DEBUG_DEPSGRAPH_BUILD
Definition: BKE_global.h:182
#define BLI_assert(a)
Definition: BLI_assert.h:46
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void DEG_graph_tag_on_visible_update(Depsgraph *depsgraph, bool do_time)
bool DEG_debug_consistency_check(struct Depsgraph *graph)
Platform independent time functions.
virtual unique_ptr< DepsgraphRelationBuilder > construct_relation_builder()
virtual unique_ptr< DepsgraphNodeBuilder > construct_node_builder()
virtual void build_nodes(DepsgraphNodeBuilder &node_builder)=0
virtual void build_relations(DepsgraphRelationBuilder &relation_builder)=0
Depsgraph * graph
Scene scene
#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)
Definition: deg_builder.cc:136
ListBase view_layers
ID * get_cow_id(const ID *id_orig) const
Definition: depsgraph.cc:236
ViewLayer * view_layer
Definition: depsgraph.h:129
double PIL_check_seconds_timer(void)
Definition: time.c:64