Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/depsgraph_build.cc
| Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ******************** */ | /* ******************** */ | ||||
| /* Graph Building API's */ | /* Graph Building API's */ | ||||
| /* Build depsgraph for the given scene layer, and dump results in given | /* Build depsgraph for the given scene layer, and dump results in given | ||||
| * graph container. | * graph container. | ||||
| */ | */ | ||||
| void DEG_graph_build_from_scene_layer(Depsgraph *graph, | void DEG_graph_build_from_view_layer(Depsgraph *graph, | ||||
| Main *bmain, | Main *bmain, | ||||
| Scene *scene, | Scene *scene, | ||||
| SceneLayer *scene_layer) | ViewLayer *view_layer) | ||||
| { | { | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| TIMEIT_START(DEG_graph_build_from_scene_layer); | TIMEIT_START(DEG_graph_build_from_view_layer); | ||||
| #endif | #endif | ||||
| DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); | DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); | ||||
| /* TODO(sergey): This is a bit tricky, but ensures that all the data | /* TODO(sergey): This is a bit tricky, but ensures that all the data | ||||
| * is evaluated properly when depsgraph is becoming "visible". | * is evaluated properly when depsgraph is becoming "visible". | ||||
| * | * | ||||
| * This now could happen for both visible scene is changed and extra | * This now could happen for both visible scene is changed and extra | ||||
| * dependency graph was created for render engine. | * dependency graph was created for render engine. | ||||
| */ | */ | ||||
| const bool need_on_visible_update = (deg_graph->scene == NULL); | const bool need_on_visible_update = (deg_graph->scene == NULL); | ||||
| /* 1) Generate all the nodes in the graph first */ | /* 1) Generate all the nodes in the graph first */ | ||||
| DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph); | DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph); | ||||
| node_builder.begin_build(); | node_builder.begin_build(); | ||||
| node_builder.build_scene_layer(scene, | node_builder.build_view_layer(scene, | ||||
| scene_layer, | view_layer, | ||||
| DEG::DEG_ID_LINKED_DIRECTLY); | DEG::DEG_ID_LINKED_DIRECTLY); | ||||
| /* 2) Hook up relationships between operations - to determine evaluation | /* 2) Hook up relationships between operations - to determine evaluation | ||||
| * order. | * order. | ||||
| */ | */ | ||||
| DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph); | DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph); | ||||
| relation_builder.begin_build(); | relation_builder.begin_build(); | ||||
| relation_builder.build_scene_layer(scene, scene_layer); | relation_builder.build_view_layer(scene, view_layer); | ||||
| if (DEG_depsgraph_use_copy_on_write()) { | if (DEG_depsgraph_use_copy_on_write()) { | ||||
| relation_builder.build_copy_on_write_relations(); | relation_builder.build_copy_on_write_relations(); | ||||
| } | } | ||||
| /* Detect and solve cycles. */ | /* Detect and solve cycles. */ | ||||
| DEG::deg_graph_detect_cycles(deg_graph); | DEG::deg_graph_detect_cycles(deg_graph); | ||||
| /* 3) Simplify the graph by removing redundant relations (to optimize | /* 3) Simplify the graph by removing redundant relations (to optimize | ||||
| Show All 11 Lines | |||||
| #if 0 | #if 0 | ||||
| if (!DEG_debug_consistency_check(deg_graph)) { | if (!DEG_debug_consistency_check(deg_graph)) { | ||||
| printf("Consistency validation failed, ABORTING!\n"); | printf("Consistency validation failed, ABORTING!\n"); | ||||
| abort(); | abort(); | ||||
| } | } | ||||
| #endif | #endif | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| TIMEIT_END(DEG_graph_build_from_scene_layer); | TIMEIT_END(DEG_graph_build_from_view_layer); | ||||
| #endif | #endif | ||||
| /* Relations are up to date. */ | /* Relations are up to date. */ | ||||
| deg_graph->need_update = false; | deg_graph->need_update = false; | ||||
| if (need_on_visible_update) { | if (need_on_visible_update) { | ||||
| DEG_graph_on_visible_update(bmain, graph); | DEG_graph_on_visible_update(bmain, graph); | ||||
| } | } | ||||
| } | } | ||||
| /* 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) | ||||
| { | { | ||||
| DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); | DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); | ||||
| deg_graph->need_update = true; | deg_graph->need_update = true; | ||||
| } | } | ||||
| /* Create or update relations in the specified graph. */ | /* Create or update relations in the specified graph. */ | ||||
| void DEG_graph_relations_update(Depsgraph *graph, | void DEG_graph_relations_update(Depsgraph *graph, | ||||
| Main *bmain, | Main *bmain, | ||||
| Scene *scene, | Scene *scene, | ||||
| SceneLayer *scene_layer) | ViewLayer *view_layer) | ||||
| { | { | ||||
| DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)graph; | DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)graph; | ||||
| if (!deg_graph->need_update) { | if (!deg_graph->need_update) { | ||||
| /* Graph is up to date, nothing to do. */ | /* Graph is up to date, nothing to do. */ | ||||
| return; | return; | ||||
| } | } | ||||
| DEG_graph_build_from_scene_layer(graph, bmain, scene, scene_layer); | DEG_graph_build_from_view_layer(graph, bmain, scene, view_layer); | ||||
| } | } | ||||
| /* Tag all relations for update. */ | /* Tag all relations for update. */ | ||||
| void DEG_relations_tag_update(Main *bmain) | void DEG_relations_tag_update(Main *bmain) | ||||
| { | { | ||||
| DEG_DEBUG_PRINTF("%s: Tagging relations for update.\n", __func__); | DEG_DEBUG_PRINTF("%s: Tagging relations for update.\n", __func__); | ||||
| LINKLIST_FOREACH(Scene *, scene, &bmain->scene) { | LINKLIST_FOREACH(Scene *, scene, &bmain->scene) { | ||||
| LINKLIST_FOREACH(SceneLayer *, scene_layer, &scene->render_layers) { | LINKLIST_FOREACH(ViewLayer *, view_layer, &scene->view_layers) { | ||||
| Depsgraph *depsgraph = | Depsgraph *depsgraph = | ||||
| (Depsgraph *)BKE_scene_get_depsgraph(scene, | (Depsgraph *)BKE_scene_get_depsgraph(scene, | ||||
| scene_layer, | view_layer, | ||||
| false); | false); | ||||
| if (depsgraph != NULL) { | if (depsgraph != NULL) { | ||||
| DEG_graph_tag_relations_update(depsgraph); | DEG_graph_tag_relations_update(depsgraph); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines | |||||