Blender  V2.93
source/blender/depsgraph/intern/builder/pipeline.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2020 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #include "pipeline.h"
21 
22 #include "PIL_time.h"
23 
24 #include "BKE_global.h"
25 
26 #include "DNA_scene_types.h"
27 
28 #include "deg_builder_cycle.h"
29 #include "deg_builder_nodes.h"
30 #include "deg_builder_relations.h"
31 #include "deg_builder_transitive.h"
32 
33 namespace blender::deg {
34 
36  : deg_graph_(reinterpret_cast<Depsgraph *>(graph)),
37  bmain_(deg_graph_->bmain),
38  scene_(deg_graph_->scene),
39  view_layer_(deg_graph_->view_layer)
40 {
41 }
42 
44 {
45  double start_time = 0.0;
47  start_time = PIL_check_seconds_timer();
48  }
49 
54 
56  printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
57  }
58 }
59 
61 {
65 }
66 
68 {
69  /* Generate all the nodes in the graph first */
70  unique_ptr<DepsgraphNodeBuilder> node_builder = construct_node_builder();
71  node_builder->begin_build();
73  node_builder->end_build();
74 }
75 
77 {
78  /* Hook up relationships between operations - to determine evaluation order. */
79  unique_ptr<DepsgraphRelationBuilder> relation_builder = construct_relation_builder();
80  relation_builder->begin_build();
81  build_relations(*relation_builder);
82  relation_builder->build_copy_on_write_relations();
83  relation_builder->build_driver_relations();
84 }
85 
87 {
88  /* Detect and solve cycles. */
90  /* Simplify the graph by removing redundant relations (to optimize
91  * traversal later). */
92  /* TODO: it would be useful to have an option to disable this in cases where
93  * it is causing trouble. */
94  if (G.debug_value == 799) {
96  }
97  /* Store pointers to commonly used evaluated datablocks. */
99  /* Flush visibility layer and re-schedule nodes for update. */
101  DEG_graph_on_visible_update(bmain_, reinterpret_cast<::Depsgraph *>(deg_graph_), false);
102 #if 0
104  printf("Consistency validation failed, ABORTING!\n");
105  abort();
106  }
107 #endif
108  /* Relations are up to date. */
109  deg_graph_->need_update = false;
110 }
111 
112 unique_ptr<DepsgraphNodeBuilder> AbstractBuilderPipeline::construct_node_builder()
113 {
114  return std::make_unique<DepsgraphNodeBuilder>(bmain_, deg_graph_, &builder_cache_);
115 }
116 
117 unique_ptr<DepsgraphRelationBuilder> AbstractBuilderPipeline::construct_relation_builder()
118 {
119  return std::make_unique<DepsgraphRelationBuilder>(bmain_, deg_graph_, &builder_cache_);
120 }
121 
122 } // namespace blender::deg
@ G_DEBUG_DEPSGRAPH_TIME
Definition: BKE_global.h:144
@ G_DEBUG_DEPSGRAPH_BUILD
Definition: BKE_global.h:141
#define BLI_assert(a)
Definition: BLI_assert.h:58
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void DEG_graph_on_visible_update(struct Main *bmain, Depsgraph *depsgraph, const 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
DepsgraphNodeBuilder * node_builder
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:202
ListBase view_layers
ID * get_cow_id(const ID *id_orig) const
Definition: depsgraph.cc:249
ViewLayer * view_layer
Definition: depsgraph.h:135
double PIL_check_seconds_timer(void)
Definition: time.c:80
#define G(x, y, z)