Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/depsgraph_build.cc
| Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle) | ||||
| DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); | DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); | ||||
| DEG::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder; | DEG::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder; | ||||
| return reinterpret_cast<Depsgraph *>(relation_builder->getGraph()); | return reinterpret_cast<Depsgraph *>(relation_builder->getGraph()); | ||||
| } | } | ||||
| /* ******************** */ | /* ******************** */ | ||||
| /* Graph Building API's */ | /* Graph Building API's */ | ||||
| /* Build depsgraph for the given scene layer, and dump results in given | static void graph_build_finalize_common(DEG::Depsgraph *deg_graph, Main *bmain) | ||||
| * graph container. | { | ||||
| */ | /* 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(°_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)); | |||||
| #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, | void DEG_graph_build_from_view_layer(Depsgraph *graph, | ||||
| Main *bmain, | Main *bmain, | ||||
| Scene *scene, | Scene *scene, | ||||
| ViewLayer *view_layer) | ViewLayer *view_layer) | ||||
| { | { | ||||
| double start_time = 0.0; | double start_time = 0.0; | ||||
| if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { | if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { | ||||
| start_time = PIL_check_seconds_timer(); | start_time = PIL_check_seconds_timer(); | ||||
| } | } | ||||
| DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); | DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); | ||||
| /* Perform sanity checks. */ | /* Perform sanity checks. */ | ||||
| BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1); | BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1); | ||||
| BLI_assert(deg_graph->scene == scene); | BLI_assert(deg_graph->scene == scene); | ||||
| BLI_assert(deg_graph->view_layer == view_layer); | BLI_assert(deg_graph->view_layer == view_layer); | ||||
| DEG::DepsgraphBuilderCache builder_cache; | DEG::DepsgraphBuilderCache builder_cache; | ||||
| /* Generate all the nodes in the graph first */ | /* Generate all the nodes in the graph first */ | ||||
| DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); | DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); | ||||
| node_builder.begin_build(); | node_builder.begin_build(); | ||||
| node_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY); | node_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY); | ||||
| node_builder.end_build(); | node_builder.end_build(); | ||||
| /* Hook up relationships between operations - to determine evaluation | /* Hook up relationships between operations - to determine evaluation order. */ | ||||
| * order. */ | |||||
| DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); | DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); | ||||
| relation_builder.begin_build(); | relation_builder.begin_build(); | ||||
| relation_builder.build_view_layer(scene, view_layer); | relation_builder.build_view_layer(scene, view_layer); | ||||
| relation_builder.build_copy_on_write_relations(); | relation_builder.build_copy_on_write_relations(); | ||||
| /* Detect and solve cycles. */ | /* Finalize building. */ | ||||
| DEG::deg_graph_detect_cycles(deg_graph); | graph_build_finalize_common(deg_graph, bmain); | ||||
| /* Simplify the graph by removing redundant relations (to optimize | /* Finish statistics. */ | ||||
| * traversal later). */ | if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { | ||||
| /* TODO: it would be useful to have an option to disable this in cases where | printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time); | ||||
| * 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(°_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, graph); | |||||
| #if 0 | |||||
| if (!DEG_debug_consistency_check(deg_graph)) { | |||||
| printf("Consistency validation failed, ABORTING!\n"); | |||||
| abort(); | |||||
| } | } | ||||
| #endif | |||||
| /* Relations are up to date. */ | void DEG_graph_build_for_render_pipeline(Depsgraph *graph, | ||||
| deg_graph->need_update = false; | 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(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); | |||||
| 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); | |||||
| relation_builder.build_copy_on_write_relations(); | |||||
| /* Finalize building. */ | |||||
| graph_build_finalize_common(deg_graph, bmain); | |||||
| /* Finish statistics. */ | /* Finish statistics. */ | ||||
| if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { | if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { | ||||
| printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time); | printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time); | ||||
| } | } | ||||
| } | } | ||||
| /* Tag graph relations for update. */ | /* Tag graph relations for update. */ | ||||
| void DEG_graph_tag_relations_update(Depsgraph *graph) | void DEG_graph_tag_relations_update(Depsgraph *graph) | ||||
| Show All 40 Lines | |||||