Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r--source/blender/depsgraph/CMakeLists.txt10
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc24
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc87
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.h2
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline.cc132
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline.h77
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_compositor.cc49
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_compositor.h47
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_from_ids.cc154
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_from_ids.h62
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_render.cc49
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_render.h41
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_view_layer.cc48
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_view_layer.h41
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc261
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc5
19 files changed, 832 insertions, 267 deletions
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 51fce738700..417aaa2c4c0 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -54,6 +54,11 @@ set(SRC
intern/builder/deg_builder_remove_noop.cc
intern/builder/deg_builder_rna.cc
intern/builder/deg_builder_transitive.cc
+ intern/builder/pipeline.cc
+ intern/builder/pipeline_compositor.cc
+ intern/builder/pipeline_from_ids.cc
+ intern/builder/pipeline_render.cc
+ intern/builder/pipeline_view_layer.cc
intern/debug/deg_debug.cc
intern/debug/deg_debug_relations_graphviz.cc
intern/debug/deg_debug_stats_gnuplot.cc
@@ -110,6 +115,11 @@ set(SRC
intern/builder/deg_builder_remove_noop.h
intern/builder/deg_builder_rna.h
intern/builder/deg_builder_transitive.h
+ intern/builder/pipeline.h
+ intern/builder/pipeline_compositor.h
+ intern/builder/pipeline_from_ids.h
+ intern/builder/pipeline_render.h
+ intern/builder/pipeline_view_layer.h
intern/debug/deg_debug.h
intern/debug/deg_time_average.h
intern/eval/deg_eval.h
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index dcdcf0c05ca..e262c880421 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1126,6 +1126,12 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
if (object->type != OB_MESH) {
continue;
}
+ if (object->rigidbody_object == nullptr) {
+ continue;
+ }
+ if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
+ continue;
+ }
/* Create operation for flushing results. */
/* Object's transform component - where the rigidbody operation
* lives. */
@@ -1466,6 +1472,18 @@ void DepsgraphNodeBuilder::build_light(Light *lamp)
function_bind(BKE_light_eval, _1, lamp_cow));
}
+void DepsgraphNodeBuilder::build_nodetree_socket(bNodeSocket *socket)
+{
+ build_idproperties(socket->prop);
+
+ if (socket->type == SOCK_OBJECT) {
+ build_id((ID *)((bNodeSocketValueObject *)socket->default_value)->value);
+ }
+ else if (socket->type == SOCK_IMAGE) {
+ build_id((ID *)((bNodeSocketValueImage *)socket->default_value)->value);
+ }
+}
+
void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
{
if (ntree == nullptr) {
@@ -1494,10 +1512,10 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) {
build_idproperties(bnode->prop);
LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->inputs) {
- build_idproperties(socket->prop);
+ build_nodetree_socket(socket);
}
LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->outputs) {
- build_idproperties(socket->prop);
+ build_nodetree_socket(socket);
}
ID *id = bnode->id;
@@ -1780,8 +1798,10 @@ void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
return;
}
add_id_node(&simulation->id);
+ build_idproperties(simulation->id.properties);
build_animdata(&simulation->id);
build_parameters(&simulation->id);
+ build_nodetree(simulation->nodetree);
Simulation *simulation_cow = get_cow_datablock(simulation);
Scene *scene_cow = get_cow_datablock(scene_);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 256fa3450a6..40f42705a52 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -31,6 +31,7 @@
#include "DEG_depsgraph.h"
+struct bNodeSocket;
struct CacheFile;
struct Camera;
struct Collection;
@@ -211,6 +212,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
virtual void build_camera(Camera *camera);
virtual void build_light(Light *lamp);
virtual void build_nodetree(bNodeTree *ntree);
+ virtual void build_nodetree_socket(bNodeSocket *socket);
virtual void build_material(Material *ma);
virtual void build_materials(Material **materials, int num_materials);
virtual void build_freestyle_lineset(FreestyleLineSet *fls);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index c5c509ee853..5ae71dd1792 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1698,6 +1698,22 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
if (object->type != OB_MESH) {
continue;
}
+ if (object->rigidbody_object == nullptr) {
+ continue;
+ }
+ if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
+ continue;
+ }
+
+ if (object->parent != nullptr && object->parent->rigidbody_object != nullptr &&
+ object->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) {
+ /* If we are a child of a compound shape object, the transforms and sim evaluation will be
+ * handled by the parent compound shape object. Do not add any evaluation triggers
+ * for the child objects.
+ */
+ continue;
+ }
+
OperationKey rb_transform_copy_key(
&object->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
/* Rigid body synchronization depends on the actual simulation. */
@@ -1747,13 +1763,18 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
/* final result of the constraint object's transform controls how
* the constraint affects the physics sim for these objects. */
ComponentKey trans_key(&object->id, NodeType::TRANSFORM);
- OperationKey ob1_key(
- &rbc->ob1->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
- OperationKey ob2_key(
- &rbc->ob2->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
- /* Constrained-objects sync depends on the constraint-holder. */
- add_relation(trans_key, ob1_key, "RigidBodyConstraint -> RBC.Object_1");
- add_relation(trans_key, ob2_key, "RigidBodyConstraint -> RBC.Object_2");
+ if (rbc->ob1->rigidbody_object->type == RBO_TYPE_ACTIVE) {
+ OperationKey ob1_key(
+ &rbc->ob1->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
+ /* Constrained-objects sync depends on the constraint-holder. */
+ add_relation(trans_key, ob1_key, "RigidBodyConstraint -> RBC.Object_1");
+ }
+ if (rbc->ob2->rigidbody_object->type == RBO_TYPE_ACTIVE) {
+ OperationKey ob2_key(
+ &rbc->ob2->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
+ /* Constrained-objects sync depends on the constraint-holder. */
+ add_relation(trans_key, ob2_key, "RigidBodyConstraint -> RBC.Object_2");
+ }
/* Ensure that sim depends on this constraint's transform. */
add_relation(trans_key, rb_simulate_key, "RigidBodyConstraint Transform -> RB Simulation");
}
@@ -2276,6 +2297,24 @@ void DepsgraphRelationBuilder::build_light(Light *lamp)
add_relation(lamp_parameters_key, shading_key, "Light Shading Parameters");
}
+void DepsgraphRelationBuilder::build_nodetree_socket(bNodeSocket *socket)
+{
+ build_idproperties(socket->prop);
+
+ if (socket->type == SOCK_OBJECT) {
+ Object *object = ((bNodeSocketValueObject *)socket->default_value)->value;
+ if (object != nullptr) {
+ build_object(object);
+ }
+ }
+ else if (socket->type == SOCK_IMAGE) {
+ Image *image = ((bNodeSocketValueImage *)socket->default_value)->value;
+ if (image != nullptr) {
+ build_image(image);
+ }
+ }
+}
+
void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
{
if (ntree == nullptr) {
@@ -2292,10 +2331,10 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) {
build_idproperties(bnode->prop);
LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->inputs) {
- build_idproperties(socket->prop);
+ build_nodetree_socket(socket);
}
LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->outputs) {
- build_idproperties(socket->prop);
+ build_nodetree_socket(socket);
}
ID *id = bnode->id;
@@ -2602,13 +2641,39 @@ void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
if (built_map_.checkIsBuiltAndTag(simulation)) {
return;
}
+ build_idproperties(simulation->id.properties);
build_animdata(&simulation->id);
build_parameters(&simulation->id);
- OperationKey simulation_update_key(
+ build_nodetree(simulation->nodetree);
+ build_nested_nodetree(&simulation->id, simulation->nodetree);
+
+ OperationKey simulation_eval_key(
&simulation->id, NodeType::SIMULATION, OperationCode::SIMULATION_EVAL);
TimeSourceKey time_src_key;
- add_relation(time_src_key, simulation_update_key, "TimeSrc -> Simulation");
+ add_relation(time_src_key, simulation_eval_key, "TimeSrc -> Simulation");
+
+ OperationKey nodetree_key(
+ &simulation->nodetree->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
+ add_relation(nodetree_key, simulation_eval_key, "NodeTree -> Simulation", 0);
+
+ LISTBASE_FOREACH (SimulationDependency *, dependency, &simulation->dependencies) {
+ if (dependency->id == nullptr) {
+ continue;
+ }
+ build_id(dependency->id);
+ if (GS(dependency->id->name) == ID_OB) {
+ Object *object = (Object *)dependency->id;
+ if (dependency->flag & SIM_DEPENDS_ON_TRANSFORM) {
+ ComponentKey object_transform_key(&object->id, NodeType::TRANSFORM);
+ add_relation(object_transform_key, simulation_eval_key, "Object Transform -> Simulation");
+ }
+ if (dependency->flag & SIM_DEPENDS_ON_GEOMETRY) {
+ ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY);
+ add_relation(object_geometry_key, simulation_eval_key, "Object Geometry -> Simulation");
+ }
+ }
+ }
}
void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index b4b0dc71f85..04f2a3f911d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -46,6 +46,7 @@
#include "intern/node/deg_node_operation.h"
struct Base;
+struct bNodeSocket;
struct CacheFile;
struct Camera;
struct Collection;
@@ -275,6 +276,7 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
virtual void build_camera(Camera *camera);
virtual void build_light(Light *lamp);
virtual void build_nodetree(bNodeTree *ntree);
+ virtual void build_nodetree_socket(bNodeSocket *socket);
virtual void build_material(Material *ma);
virtual void build_materials(Material **materials, int num_materials);
virtual void build_freestyle_lineset(FreestyleLineSet *fls);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.h b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
index c48c6489c47..d03903d508c 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
@@ -96,7 +96,7 @@ class RNANodeQuery {
/* Check whether prop_identifier contains rna_path_component.
*
- * This checks more than a substring:
+ * This checks more than a sub-string:
*
* prop_identifier contains(prop_identifier, "location")
* ------------------------ -------------------------------------
diff --git a/source/blender/depsgraph/intern/builder/pipeline.cc b/source/blender/depsgraph/intern/builder/pipeline.cc
new file mode 100644
index 00000000000..d6893ba11d8
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline.cc
@@ -0,0 +1,132 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline.h"
+
+#include "PIL_time.h"
+
+#include "BKE_global.h"
+
+#include "DNA_scene_types.h"
+
+#include "deg_builder_cycle.h"
+#include "deg_builder_nodes.h"
+#include "deg_builder_relations.h"
+#include "deg_builder_transitive.h"
+
+namespace blender {
+namespace deg {
+
+AbstractBuilderPipeline::AbstractBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
+ : deg_graph_(reinterpret_cast<Depsgraph *>(graph)),
+ bmain_(bmain),
+ scene_(scene),
+ view_layer_(view_layer),
+ builder_cache_()
+{
+}
+
+AbstractBuilderPipeline::~AbstractBuilderPipeline()
+{
+}
+
+void AbstractBuilderPipeline::build()
+{
+ double start_time = 0.0;
+ if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
+ start_time = PIL_check_seconds_timer();
+ }
+
+ build_step_sanity_check();
+ build_step_nodes();
+ build_step_relations();
+ build_step_finalize();
+
+ if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
+ printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
+ }
+}
+
+void AbstractBuilderPipeline::build_step_sanity_check()
+{
+ BLI_assert(BLI_findindex(&scene_->view_layers, view_layer_) != -1);
+ BLI_assert(deg_graph_->scene == scene_);
+ BLI_assert(deg_graph_->view_layer == view_layer_);
+}
+
+void AbstractBuilderPipeline::build_step_nodes()
+{
+ /* Generate all the nodes in the graph first */
+ unique_ptr<DepsgraphNodeBuilder> node_builder = construct_node_builder();
+ node_builder->begin_build();
+ build_nodes(*node_builder);
+ node_builder->end_build();
+}
+
+void AbstractBuilderPipeline::build_step_relations()
+{
+ /* Hook up relationships between operations - to determine evaluation order. */
+ unique_ptr<DepsgraphRelationBuilder> relation_builder = construct_relation_builder();
+ relation_builder->begin_build();
+ build_relations(*relation_builder);
+ relation_builder->build_copy_on_write_relations();
+ relation_builder->build_driver_relations();
+}
+
+void AbstractBuilderPipeline::build_step_finalize()
+{
+ /* Detect and solve cycles. */
+ deg_graph_detect_cycles(deg_graph_);
+ /* Simplify the graph by removing redundant relations (to optimize
+ * traversal later). */
+ /* TODO: it would be useful to have an option to disable this in cases where
+ * it is causing trouble. */
+ if (G.debug_value == 799) {
+ deg_graph_transitive_reduction(deg_graph_);
+ }
+ /* Store pointers to commonly used valuated datablocks. */
+ deg_graph_->scene_cow = (Scene *)deg_graph_->get_cow_id(&deg_graph_->scene->id);
+ /* Flush visibility layer and re-schedule nodes for update. */
+ deg_graph_build_finalize(bmain_, deg_graph_);
+ DEG_graph_on_visible_update(bmain_, reinterpret_cast<::Depsgraph *>(deg_graph_), false);
+#if 0
+ if (!DEG_debug_consistency_check(deg_graph_)) {
+ printf("Consistency validation failed, ABORTING!\n");
+ abort();
+ }
+#endif
+ /* Relations are up to date. */
+ deg_graph_->need_update = false;
+}
+
+unique_ptr<DepsgraphNodeBuilder> AbstractBuilderPipeline::construct_node_builder()
+{
+ return std::make_unique<DepsgraphNodeBuilder>(bmain_, deg_graph_, &builder_cache_);
+}
+
+unique_ptr<DepsgraphRelationBuilder> AbstractBuilderPipeline::construct_relation_builder()
+{
+ return std::make_unique<DepsgraphRelationBuilder>(bmain_, deg_graph_, &builder_cache_);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline.h b/source/blender/depsgraph/intern/builder/pipeline.h
new file mode 100644
index 00000000000..2c9c78bb2cb
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline.h
@@ -0,0 +1,77 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "deg_builder_cache.h"
+
+#include "intern/depsgraph_type.h"
+
+struct Main;
+struct Scene;
+struct ViewLayer;
+struct Depsgraph;
+
+namespace blender {
+namespace deg {
+
+struct Depsgraph;
+class DepsgraphNodeBuilder;
+class DepsgraphRelationBuilder;
+
+/* Base class for Depsgraph Builder pipelines.
+ *
+ * Basically it runs through the following steps:
+ * - sanity check
+ * - build nodes
+ * - build relations
+ * - finalize
+ */
+class AbstractBuilderPipeline {
+ public:
+ AbstractBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer);
+ virtual ~AbstractBuilderPipeline();
+
+ void build();
+
+ protected:
+ Depsgraph *deg_graph_;
+ Main *bmain_;
+ Scene *scene_;
+ ViewLayer *view_layer_;
+ DepsgraphBuilderCache builder_cache_;
+
+ virtual unique_ptr<DepsgraphNodeBuilder> construct_node_builder();
+ virtual unique_ptr<DepsgraphRelationBuilder> construct_relation_builder();
+
+ virtual void build_step_sanity_check();
+ void build_step_nodes();
+ void build_step_relations();
+ void build_step_finalize();
+
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) = 0;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) = 0;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_compositor.cc b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc
new file mode 100644
index 00000000000..3e56f17fc7e
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc
@@ -0,0 +1,49 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_compositor.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+CompositorBuilderPipeline::CompositorBuilderPipeline(
+ ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, bNodeTree *nodetree)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer), nodetree_(nodetree)
+{
+ deg_graph_->is_render_pipeline_depsgraph = true;
+}
+
+void CompositorBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_scene_render(scene_, view_layer_);
+ node_builder.build_nodetree(nodetree_);
+}
+
+void CompositorBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_scene_render(scene_, view_layer_);
+ relation_builder.build_nodetree(nodetree_);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_compositor.h b/source/blender/depsgraph/intern/builder/pipeline_compositor.h
new file mode 100644
index 00000000000..892ece7c2a4
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_compositor.h
@@ -0,0 +1,47 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+struct bNodeTree;
+
+namespace blender {
+namespace deg {
+
+class CompositorBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ CompositorBuilderPipeline(
+ ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, bNodeTree *nodetree);
+
+ protected:
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+
+ private:
+ bNodeTree *nodetree_;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc
new file mode 100644
index 00000000000..e44f554f197
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc
@@ -0,0 +1,154 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_from_ids.h"
+
+#include "DNA_layer_types.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+namespace {
+
+class DepsgraphFromIDsFilter {
+ public:
+ DepsgraphFromIDsFilter(ID **ids, const int num_ids)
+ {
+ for (int i = 0; i < num_ids; ++i) {
+ ids_.add(ids[i]);
+ }
+ }
+
+ bool contains(ID *id)
+ {
+ return ids_.contains(id);
+ }
+
+ protected:
+ Set<ID *> ids_;
+};
+
+class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {
+ public:
+ DepsgraphFromIDsNodeBuilder(
+ Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
+ : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids, num_ids)
+ {
+ }
+
+ virtual bool need_pull_base_into_graph(Base *base) override
+ {
+ if (!filter_.contains(&base->object->id)) {
+ return false;
+ }
+ return DepsgraphNodeBuilder::need_pull_base_into_graph(base);
+ }
+
+ virtual void build_object_proxy_group(Object *object, bool is_visible) override
+ {
+ if (object->proxy_group == nullptr) {
+ return;
+ }
+ if (!filter_.contains(&object->proxy_group->id)) {
+ return;
+ }
+ DepsgraphNodeBuilder::build_object_proxy_group(object, is_visible);
+ }
+
+ protected:
+ DepsgraphFromIDsFilter filter_;
+};
+
+class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder {
+ public:
+ DepsgraphFromIDsRelationBuilder(
+ Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
+ : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids, num_ids)
+ {
+ }
+
+ virtual bool need_pull_base_into_graph(Base *base) override
+ {
+ if (!filter_.contains(&base->object->id)) {
+ return false;
+ }
+ return DepsgraphRelationBuilder::need_pull_base_into_graph(base);
+ }
+
+ virtual void build_object_proxy_group(Object *object) override
+ {
+ if (object->proxy_group == nullptr) {
+ return;
+ }
+ if (!filter_.contains(&object->proxy_group->id)) {
+ return;
+ }
+ DepsgraphRelationBuilder::build_object_proxy_group(object);
+ }
+
+ protected:
+ DepsgraphFromIDsFilter filter_;
+};
+
+} // namespace
+
+FromIDsBuilderPipeline::FromIDsBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ ID **ids,
+ const int num_ids)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer), ids_(ids), num_ids_(num_ids)
+{
+}
+
+unique_ptr<DepsgraphNodeBuilder> FromIDsBuilderPipeline::construct_node_builder()
+{
+ return std::make_unique<DepsgraphFromIDsNodeBuilder>(
+ bmain_, deg_graph_, &builder_cache_, ids_, num_ids_);
+}
+
+unique_ptr<DepsgraphRelationBuilder> FromIDsBuilderPipeline::construct_relation_builder()
+{
+ return std::make_unique<DepsgraphFromIDsRelationBuilder>(
+ bmain_, deg_graph_, &builder_cache_, ids_, num_ids_);
+}
+
+void FromIDsBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+ for (int i = 0; i < num_ids_; ++i) {
+ node_builder.build_id(ids_[i]);
+ }
+}
+
+void FromIDsBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+ for (int i = 0; i < num_ids_; ++i) {
+ relation_builder.build_id(ids_[i]);
+ }
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h
new file mode 100644
index 00000000000..4a507f2c728
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h
@@ -0,0 +1,62 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+namespace blender {
+namespace deg {
+
+/* Optimized builders for dependency graph built from a given set of IDs.
+ *
+ * General notes:
+ *
+ * - We pull in all bases if their objects are in the set of IDs. This allows to have proper
+ * visibility and other flags assigned to the objects.
+ * All other bases (the ones which points to object which is outside of the set of IDs) are
+ * completely ignored.
+ *
+ * - Proxy groups pointing to objects which are outside of the IDs set are also ignored.
+ * This way we avoid high-poly character body pulled into the dependency graph when it's coming
+ * from a library into an animation file and the dependency graph constructed for a proxy rig. */
+
+class FromIDsBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ FromIDsBuilderPipeline(
+ ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, ID **ids, int num_ids);
+
+ protected:
+ virtual unique_ptr<DepsgraphNodeBuilder> construct_node_builder() override;
+ virtual unique_ptr<DepsgraphRelationBuilder> construct_relation_builder() override;
+
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+
+ private:
+ ID **ids_;
+ const int num_ids_;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_render.cc b/source/blender/depsgraph/intern/builder/pipeline_render.cc
new file mode 100644
index 00000000000..50a37d0d3e4
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_render.cc
@@ -0,0 +1,49 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_render.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+RenderBuilderPipeline::RenderBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer)
+{
+ deg_graph_->is_render_pipeline_depsgraph = true;
+}
+
+void RenderBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_scene_render(scene_, view_layer_);
+}
+
+void RenderBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_scene_render(scene_, view_layer_);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_render.h b/source/blender/depsgraph/intern/builder/pipeline_render.h
new file mode 100644
index 00000000000..df7f9e0de68
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_render.h
@@ -0,0 +1,41 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+namespace blender {
+namespace deg {
+
+class RenderBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ RenderBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer);
+
+ protected:
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc
new file mode 100644
index 00000000000..3223f17f349
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc
@@ -0,0 +1,48 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_view_layer.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+ViewLayerBuilderPipeline::ViewLayerBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer)
+{
+}
+
+void ViewLayerBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+}
+
+void ViewLayerBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_view_layer.h b/source/blender/depsgraph/intern/builder/pipeline_view_layer.h
new file mode 100644
index 00000000000..fbd7b98acad
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_view_layer.h
@@ -0,0 +1,41 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+namespace blender {
+namespace deg {
+
+class ViewLayerBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ ViewLayerBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer);
+
+ protected:
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index c11d051e663..fb933cb38f3 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -43,12 +43,11 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_debug.h"
-#include "builder/deg_builder.h"
-#include "builder/deg_builder_cache.h"
-#include "builder/deg_builder_cycle.h"
-#include "builder/deg_builder_nodes.h"
#include "builder/deg_builder_relations.h"
-#include "builder/deg_builder_transitive.h"
+#include "builder/pipeline_compositor.h"
+#include "builder/pipeline_from_ids.h"
+#include "builder/pipeline_render.h"
+#include "builder/pipeline_view_layer.h"
#include "intern/debug/deg_debug.h"
@@ -209,65 +208,14 @@ struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle)
/* ******************** */
/* Graph Building API's */
-static void graph_build_finalize_common(deg::Depsgraph *deg_graph, Main *bmain)
-{
- /* Detect and solve cycles. */
- deg::deg_graph_detect_cycles(deg_graph);
- /* Simplify the graph by removing redundant relations (to optimize
- * traversal later). */
- /* TODO: it would be useful to have an option to disable this in cases where
- * it is causing trouble. */
- if (G.debug_value == 799) {
- deg::deg_graph_transitive_reduction(deg_graph);
- }
- /* Store pointers to commonly used valuated datablocks. */
- deg_graph->scene_cow = (Scene *)deg_graph->get_cow_id(&deg_graph->scene->id);
- /* Flush visibility layer and re-schedule nodes for update. */
- deg::deg_graph_build_finalize(bmain, deg_graph);
- DEG_graph_on_visible_update(bmain, reinterpret_cast<::Depsgraph *>(deg_graph), false);
-#if 0
- if (!DEG_debug_consistency_check(deg_graph)) {
- printf("Consistency validation failed, ABORTING!\n");
- abort();
- }
-#endif
- /* Relations are up to date. */
- deg_graph->need_update = false;
-}
-
/* Build depsgraph for the given scene layer, and dump results in given graph container. */
void DEG_graph_build_from_view_layer(Depsgraph *graph,
Main *bmain,
Scene *scene,
ViewLayer *view_layer)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
- BLI_assert(deg_graph->scene == scene);
- BLI_assert(deg_graph->view_layer == view_layer);
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
- node_builder.begin_build();
- node_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation order. */
- deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
- relation_builder.begin_build();
- relation_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::ViewLayerBuilderPipeline builder(graph, bmain, scene, view_layer);
+ builder.build();
}
void DEG_graph_build_for_render_pipeline(Depsgraph *graph,
@@ -275,170 +223,17 @@ void DEG_graph_build_for_render_pipeline(Depsgraph *graph,
Scene *scene,
ViewLayer *view_layer)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(deg_graph->scene == scene);
- deg_graph->is_render_pipeline_depsgraph = true;
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
- node_builder.begin_build();
- node_builder.build_scene_render(scene, view_layer);
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation
- * order. */
- deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
- relation_builder.begin_build();
- relation_builder.build_scene_render(scene, view_layer);
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::RenderBuilderPipeline builder(graph, bmain, scene, view_layer);
+ builder.build();
}
void DEG_graph_build_for_compositor_preview(
Depsgraph *graph, Main *bmain, Scene *scene, struct ViewLayer *view_layer, bNodeTree *nodetree)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(deg_graph->scene == scene);
- deg_graph->is_render_pipeline_depsgraph = true;
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
- node_builder.begin_build();
- node_builder.build_scene_render(scene, view_layer);
- node_builder.build_nodetree(nodetree);
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation
- * order. */
- deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
- relation_builder.begin_build();
- relation_builder.build_scene_render(scene, view_layer);
- relation_builder.build_nodetree(nodetree);
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::CompositorBuilderPipeline builder(graph, bmain, scene, view_layer, nodetree);
+ builder.build();
}
-/* Optimized builders for dependency graph built from a given set of IDs.
- *
- * General notes:
- *
- * - We pull in all bases if their objects are in the set of IDs. This allows to have proper
- * visibility and other flags assigned to the objects.
- * All other bases (the ones which points to object which is outside of the set of IDs) are
- * completely ignored.
- *
- * - Proxy groups pointing to objects which are outside of the IDs set are also ignored.
- * This way we avoid high-poly character body pulled into the dependency graph when it's coming
- * from a library into an animation file and the dependency graph constructed for a proxy rig. */
-
-namespace blender {
-namespace deg {
-namespace {
-
-class DepsgraphFromIDsFilter {
- public:
- DepsgraphFromIDsFilter(ID **ids, const int num_ids)
- {
- for (int i = 0; i < num_ids; ++i) {
- ids_.add(ids[i]);
- }
- }
-
- bool contains(ID *id)
- {
- return ids_.contains(id);
- }
-
- protected:
- Set<ID *> ids_;
-};
-
-class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {
- public:
- DepsgraphFromIDsNodeBuilder(
- Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
- : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids, num_ids)
- {
- }
-
- virtual bool need_pull_base_into_graph(Base *base) override
- {
- if (!filter_.contains(&base->object->id)) {
- return false;
- }
- return DepsgraphNodeBuilder::need_pull_base_into_graph(base);
- }
-
- virtual void build_object_proxy_group(Object *object, bool is_visible) override
- {
- if (object->proxy_group == nullptr) {
- return;
- }
- if (!filter_.contains(&object->proxy_group->id)) {
- return;
- }
- DepsgraphNodeBuilder::build_object_proxy_group(object, is_visible);
- }
-
- protected:
- DepsgraphFromIDsFilter filter_;
-};
-
-class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder {
- public:
- DepsgraphFromIDsRelationBuilder(
- Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
- : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids, num_ids)
- {
- }
-
- virtual bool need_pull_base_into_graph(Base *base) override
- {
- if (!filter_.contains(&base->object->id)) {
- return false;
- }
- return DepsgraphRelationBuilder::need_pull_base_into_graph(base);
- }
-
- virtual void build_object_proxy_group(Object *object) override
- {
- if (object->proxy_group == nullptr) {
- return;
- }
- if (!filter_.contains(&object->proxy_group->id)) {
- return;
- }
- DepsgraphRelationBuilder::build_object_proxy_group(object);
- }
-
- protected:
- DepsgraphFromIDsFilter filter_;
-};
-
-} // namespace
-} // namespace deg
-} // namespace blender
-
void DEG_graph_build_from_ids(Depsgraph *graph,
Main *bmain,
Scene *scene,
@@ -446,40 +241,8 @@ void DEG_graph_build_from_ids(Depsgraph *graph,
ID **ids,
const int num_ids)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
- BLI_assert(deg_graph->scene == scene);
- BLI_assert(deg_graph->view_layer == view_layer);
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphFromIDsNodeBuilder node_builder(bmain, deg_graph, &builder_cache, ids, num_ids);
- node_builder.begin_build();
- node_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- for (int i = 0; i < num_ids; ++i) {
- node_builder.build_id(ids[i]);
- }
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation order. */
- deg::DepsgraphFromIDsRelationBuilder relation_builder(
- bmain, deg_graph, &builder_cache, ids, num_ids);
- relation_builder.begin_build();
- relation_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- for (int i = 0; i < num_ids; ++i) {
- relation_builder.build_id(ids[i]);
- }
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::FromIDsBuilderPipeline builder(graph, bmain, scene, view_layer, ids, num_ids);
+ builder.build();
}
/* Tag graph relations for update. */
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 848275eb899..1d8fba21857 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -48,11 +48,8 @@
#include "BKE_idtype.h"
#include "BKE_node.h"
#include "BKE_scene.h"
-#include "BKE_workspace.h"
-
-#define new new_
#include "BKE_screen.h"
-#undef new
+#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_debug.h"
@@ -786,6 +783,7 @@ void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type)
DEG_graph_id_type_tag(depsgraph, ID_LA);
DEG_graph_id_type_tag(depsgraph, ID_WO);
DEG_graph_id_type_tag(depsgraph, ID_SCE);
+ DEG_graph_id_type_tag(depsgraph, ID_SIM);
}
const int id_type_index = BKE_idtype_idcode_to_index(id_type);
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index c1e1ed3036d..89df41944e5 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -120,6 +120,7 @@ union NestedIDHackTempStorage {
Scene scene;
Tex tex;
World world;
+ Simulation simulation;
};
/* Set nested owned ID pointers to nullptr. */
@@ -137,6 +138,7 @@ void nested_id_hack_discard_pointers(ID *id_cow)
SPECIAL_CASE(ID_MA, Material, nodetree)
SPECIAL_CASE(ID_TE, Tex, nodetree)
SPECIAL_CASE(ID_WO, World, nodetree)
+ SPECIAL_CASE(ID_SIM, Simulation, nodetree)
SPECIAL_CASE(ID_CU, Curve, key)
SPECIAL_CASE(ID_LT, Lattice, key)
@@ -185,6 +187,7 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
SPECIAL_CASE(ID_MA, Material, nodetree, material)
SPECIAL_CASE(ID_TE, Tex, nodetree, tex)
SPECIAL_CASE(ID_WO, World, nodetree, world)
+ SPECIAL_CASE(ID_SIM, Simulation, nodetree, simulation)
SPECIAL_CASE(ID_CU, Curve, key, curve)
SPECIAL_CASE(ID_LT, Lattice, key, lattice)
@@ -224,6 +227,7 @@ void nested_id_hack_restore_pointers(const ID *old_id, ID *new_id)
SPECIAL_CASE(ID_SCE, Scene, nodetree)
SPECIAL_CASE(ID_TE, Tex, nodetree)
SPECIAL_CASE(ID_WO, World, nodetree)
+ SPECIAL_CASE(ID_SIM, Simulation, nodetree)
SPECIAL_CASE(ID_CU, Curve, key)
SPECIAL_CASE(ID_LT, Lattice, key)
@@ -261,6 +265,7 @@ void ntree_hack_remap_pointers(const Depsgraph *depsgraph, ID *id_cow)
SPECIAL_CASE(ID_SCE, Scene, nodetree, bNodeTree)
SPECIAL_CASE(ID_TE, Tex, nodetree, bNodeTree)
SPECIAL_CASE(ID_WO, World, nodetree, bNodeTree)
+ SPECIAL_CASE(ID_SIM, Simulation, nodetree, bNodeTree)
SPECIAL_CASE(ID_CU, Curve, key, Key)
SPECIAL_CASE(ID_LT, Lattice, key, Key)