From 6a4f5e6a8c3990330fe8839e39e0094ba5410ba4 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 18 Aug 2020 15:51:32 +0200 Subject: Depsgraph: simplify build API Reviewers: sergey, sybren Differential Revision: https://developer.blender.org/D8611 --- source/blender/depsgraph/DEG_depsgraph_build.h | 35 ++++--------------- .../blender/depsgraph/intern/builder/pipeline.cc | 11 +++--- source/blender/depsgraph/intern/builder/pipeline.h | 2 +- .../intern/builder/pipeline_all_objects.cc | 7 ++-- .../intern/builder/pipeline_all_objects.h | 2 +- .../intern/builder/pipeline_compositor.cc | 5 ++- .../depsgraph/intern/builder/pipeline_compositor.h | 3 +- .../depsgraph/intern/builder/pipeline_from_ids.cc | 5 ++- .../depsgraph/intern/builder/pipeline_from_ids.h | 3 +- .../depsgraph/intern/builder/pipeline_render.cc | 6 +--- .../depsgraph/intern/builder/pipeline_render.h | 2 +- .../intern/builder/pipeline_view_layer.cc | 7 ++-- .../depsgraph/intern/builder/pipeline_view_layer.h | 2 +- source/blender/depsgraph/intern/depsgraph_build.cc | 40 +++++++--------------- source/blender/depsgraph/intern/depsgraph_debug.cc | 2 +- 15 files changed, 39 insertions(+), 93 deletions(-) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index dd52c97e03f..2147a584765 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -51,50 +51,29 @@ extern "C" { /* Graph Building -------------------------------- */ /* Build depsgraph for the given scene, and dump results in given graph container. */ -void DEG_graph_build_from_view_layer(struct Depsgraph *graph, - struct Main *bmain, - struct Scene *scene, - struct ViewLayer *view_layer); +void DEG_graph_build_from_view_layer(struct Depsgraph *graph); /* Build depsgraph for all objects (so also invisible ones) in the given view layer. */ -void DEG_graph_build_for_all_objects(struct Depsgraph *graph, - struct Main *bmain, - struct Scene *scene, - struct ViewLayer *view_layer); +void DEG_graph_build_for_all_objects(struct Depsgraph *graph); /* Special version of builder which produces dependency graph suitable for the render pipeline. * It will contain sequencer and compositor (if needed) and all their dependencies. */ -void DEG_graph_build_for_render_pipeline(struct Depsgraph *graph, - struct Main *bmain, - struct Scene *scene, - struct ViewLayer *view_layer); +void DEG_graph_build_for_render_pipeline(struct Depsgraph *graph); /* Builds minimal dependency graph for compositor preview. * * Note that compositor editor might have pinned node tree, which is different from scene's node * tree. */ -void DEG_graph_build_for_compositor_preview(struct Depsgraph *graph, - struct Main *bmain, - struct Scene *scene, - struct ViewLayer *view_layer, - struct bNodeTree *nodetree); - -void DEG_graph_build_from_ids(struct Depsgraph *graph, - struct Main *bmain, - struct Scene *scene, - struct ViewLayer *view_layer, - struct ID **ids, - const int num_ids); +void DEG_graph_build_for_compositor_preview(struct Depsgraph *graph, struct bNodeTree *nodetree); + +void DEG_graph_build_from_ids(struct Depsgraph *graph, struct ID **ids, const int num_ids); /* Tag relations from the given graph for update. */ void DEG_graph_tag_relations_update(struct Depsgraph *graph); /* Create or update relations in the specified graph. */ -void DEG_graph_relations_update(struct Depsgraph *graph, - struct Main *bmain, - struct Scene *scene, - struct ViewLayer *view_layer); +void DEG_graph_relations_update(struct Depsgraph *graph); /* Tag all relations in the database for update.*/ void DEG_relations_tag_update(struct Main *bmain); diff --git a/source/blender/depsgraph/intern/builder/pipeline.cc b/source/blender/depsgraph/intern/builder/pipeline.cc index d6893ba11d8..b13077e4792 100644 --- a/source/blender/depsgraph/intern/builder/pipeline.cc +++ b/source/blender/depsgraph/intern/builder/pipeline.cc @@ -33,14 +33,11 @@ namespace blender { namespace deg { -AbstractBuilderPipeline::AbstractBuilderPipeline(::Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer) +AbstractBuilderPipeline::AbstractBuilderPipeline(::Depsgraph *graph) : deg_graph_(reinterpret_cast(graph)), - bmain_(bmain), - scene_(scene), - view_layer_(view_layer), + bmain_(deg_graph_->bmain), + scene_(deg_graph_->scene), + view_layer_(deg_graph_->view_layer), builder_cache_() { } diff --git a/source/blender/depsgraph/intern/builder/pipeline.h b/source/blender/depsgraph/intern/builder/pipeline.h index 2c9c78bb2cb..d98d834932c 100644 --- a/source/blender/depsgraph/intern/builder/pipeline.h +++ b/source/blender/depsgraph/intern/builder/pipeline.h @@ -49,7 +49,7 @@ class DepsgraphRelationBuilder; */ class AbstractBuilderPipeline { public: - AbstractBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer); + AbstractBuilderPipeline(::Depsgraph *graph); virtual ~AbstractBuilderPipeline(); void build(); diff --git a/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc b/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc index c926ff7541a..81d239239be 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc +++ b/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc @@ -58,11 +58,8 @@ class AllObjectsRelationBuilder : public DepsgraphRelationBuilder { } // namespace -AllObjectsBuilderPipeline::AllObjectsBuilderPipeline(::Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer) - : ViewLayerBuilderPipeline(graph, bmain, scene, view_layer) +AllObjectsBuilderPipeline::AllObjectsBuilderPipeline(::Depsgraph *graph) + : ViewLayerBuilderPipeline(graph) { } diff --git a/source/blender/depsgraph/intern/builder/pipeline_all_objects.h b/source/blender/depsgraph/intern/builder/pipeline_all_objects.h index 94f00ae840b..11ca2314331 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_all_objects.h +++ b/source/blender/depsgraph/intern/builder/pipeline_all_objects.h @@ -33,7 +33,7 @@ namespace deg { * (and their dependencies). */ class AllObjectsBuilderPipeline : public ViewLayerBuilderPipeline { public: - AllObjectsBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer); + AllObjectsBuilderPipeline(::Depsgraph *graph); protected: virtual unique_ptr construct_node_builder() override; diff --git a/source/blender/depsgraph/intern/builder/pipeline_compositor.cc b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc index 3e56f17fc7e..2b9922851c1 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_compositor.cc +++ b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc @@ -26,9 +26,8 @@ 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) +CompositorBuilderPipeline::CompositorBuilderPipeline(::Depsgraph *graph, bNodeTree *nodetree) + : AbstractBuilderPipeline(graph), nodetree_(nodetree) { deg_graph_->is_render_pipeline_depsgraph = true; } diff --git a/source/blender/depsgraph/intern/builder/pipeline_compositor.h b/source/blender/depsgraph/intern/builder/pipeline_compositor.h index 892ece7c2a4..46f1e3694d3 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_compositor.h +++ b/source/blender/depsgraph/intern/builder/pipeline_compositor.h @@ -32,8 +32,7 @@ namespace deg { class CompositorBuilderPipeline : public AbstractBuilderPipeline { public: - CompositorBuilderPipeline( - ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, bNodeTree *nodetree); + CompositorBuilderPipeline(::Depsgraph *graph, bNodeTree *nodetree); protected: virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override; diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc index c42bccaadec..87cfeb46693 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc +++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc @@ -114,9 +114,8 @@ class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder { } // namespace -FromIDsBuilderPipeline::FromIDsBuilderPipeline( - ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, Span ids) - : AbstractBuilderPipeline(graph, bmain, scene, view_layer), ids_(ids) +FromIDsBuilderPipeline::FromIDsBuilderPipeline(::Depsgraph *graph, Span ids) + : AbstractBuilderPipeline(graph), ids_(ids) { } diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h index a52a9f6f252..79fcfc52446 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h +++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h @@ -43,8 +43,7 @@ namespace deg { class FromIDsBuilderPipeline : public AbstractBuilderPipeline { public: - FromIDsBuilderPipeline( - ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, Span ids); + FromIDsBuilderPipeline(::Depsgraph *graph, Span ids); protected: virtual unique_ptr construct_node_builder() override; diff --git a/source/blender/depsgraph/intern/builder/pipeline_render.cc b/source/blender/depsgraph/intern/builder/pipeline_render.cc index 50a37d0d3e4..3b065f7f1bc 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_render.cc +++ b/source/blender/depsgraph/intern/builder/pipeline_render.cc @@ -26,11 +26,7 @@ namespace blender { namespace deg { -RenderBuilderPipeline::RenderBuilderPipeline(::Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer) - : AbstractBuilderPipeline(graph, bmain, scene, view_layer) +RenderBuilderPipeline::RenderBuilderPipeline(::Depsgraph *graph) : AbstractBuilderPipeline(graph) { deg_graph_->is_render_pipeline_depsgraph = true; } diff --git a/source/blender/depsgraph/intern/builder/pipeline_render.h b/source/blender/depsgraph/intern/builder/pipeline_render.h index df7f9e0de68..91a4be137b6 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_render.h +++ b/source/blender/depsgraph/intern/builder/pipeline_render.h @@ -30,7 +30,7 @@ namespace deg { class RenderBuilderPipeline : public AbstractBuilderPipeline { public: - RenderBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer); + RenderBuilderPipeline(::Depsgraph *graph); protected: virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override; diff --git a/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc index 3223f17f349..f1852a40a10 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc @@ -26,11 +26,8 @@ namespace blender { namespace deg { -ViewLayerBuilderPipeline::ViewLayerBuilderPipeline(::Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer) - : AbstractBuilderPipeline(graph, bmain, scene, view_layer) +ViewLayerBuilderPipeline::ViewLayerBuilderPipeline(::Depsgraph *graph) + : AbstractBuilderPipeline(graph) { } diff --git a/source/blender/depsgraph/intern/builder/pipeline_view_layer.h b/source/blender/depsgraph/intern/builder/pipeline_view_layer.h index fbd7b98acad..aa85dd7a47b 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_view_layer.h +++ b/source/blender/depsgraph/intern/builder/pipeline_view_layer.h @@ -30,7 +30,7 @@ namespace deg { class ViewLayerBuilderPipeline : public AbstractBuilderPipeline { public: - ViewLayerBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer); + ViewLayerBuilderPipeline(::Depsgraph *graph); protected: virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override; diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index dc49534eb2d..96c17ae4dc5 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -210,49 +210,33 @@ struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle) /* Graph Building API's */ /* 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) +void DEG_graph_build_from_view_layer(Depsgraph *graph) { - deg::ViewLayerBuilderPipeline builder(graph, bmain, scene, view_layer); + deg::ViewLayerBuilderPipeline builder(graph); builder.build(); } -void DEG_graph_build_for_all_objects(struct Depsgraph *graph, - struct Main *bmain, - struct Scene *scene, - struct ViewLayer *view_layer) +void DEG_graph_build_for_all_objects(struct Depsgraph *graph) { - deg::AllObjectsBuilderPipeline builder(graph, bmain, scene, view_layer); + deg::AllObjectsBuilderPipeline builder(graph); builder.build(); } -void DEG_graph_build_for_render_pipeline(Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer) +void DEG_graph_build_for_render_pipeline(Depsgraph *graph) { - deg::RenderBuilderPipeline builder(graph, bmain, scene, view_layer); + deg::RenderBuilderPipeline builder(graph); builder.build(); } -void DEG_graph_build_for_compositor_preview( - Depsgraph *graph, Main *bmain, Scene *scene, struct ViewLayer *view_layer, bNodeTree *nodetree) +void DEG_graph_build_for_compositor_preview(Depsgraph *graph, bNodeTree *nodetree) { - deg::CompositorBuilderPipeline builder(graph, bmain, scene, view_layer, nodetree); + deg::CompositorBuilderPipeline builder(graph, nodetree); builder.build(); } -void DEG_graph_build_from_ids(Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer, - ID **ids, - const int num_ids) +void DEG_graph_build_from_ids(Depsgraph *graph, ID **ids, const int num_ids) { - deg::FromIDsBuilderPipeline builder( - graph, bmain, scene, view_layer, blender::Span(ids, num_ids)); + deg::FromIDsBuilderPipeline builder(graph, blender::Span(ids, num_ids)); builder.build(); } @@ -275,14 +259,14 @@ void DEG_graph_tag_relations_update(Depsgraph *graph) } /* Create or update relations in the specified graph. */ -void DEG_graph_relations_update(Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer) +void DEG_graph_relations_update(Depsgraph *graph) { deg::Depsgraph *deg_graph = (deg::Depsgraph *)graph; if (!deg_graph->need_update) { /* Graph is up to date, nothing to do. */ return; } - DEG_graph_build_from_view_layer(graph, bmain, scene, view_layer); + DEG_graph_build_from_view_layer(graph); } /* Tag all relations for update. */ diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index 0763738ff59..c5e306f3148 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -93,7 +93,7 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph, { Depsgraph *temp_depsgraph = DEG_graph_new(bmain, scene, view_layer, DEG_get_mode(graph)); bool valid = true; - DEG_graph_build_from_view_layer(temp_depsgraph, bmain, scene, view_layer); + DEG_graph_build_from_view_layer(temp_depsgraph); if (!DEG_debug_compare(temp_depsgraph, graph)) { fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n"); BLI_assert(!"This should not happen!"); -- cgit v1.2.3