Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
| Show First 20 Lines • Show All 321 Lines • ▼ Show 20 Lines | ViewLayer *get_original_view_layer(const Depsgraph *depsgraph, const IDNode *id_node) | ||||
| if (id_node->linked_state == DEG_ID_LINKED_DIRECTLY) { | if (id_node->linked_state == DEG_ID_LINKED_DIRECTLY) { | ||||
| return depsgraph->view_layer; | return depsgraph->view_layer; | ||||
| } | } | ||||
| else if (id_node->linked_state == DEG_ID_LINKED_VIA_SET) { | else if (id_node->linked_state == DEG_ID_LINKED_VIA_SET) { | ||||
| Scene *scene_orig = reinterpret_cast<Scene *>(id_node->id_orig); | Scene *scene_orig = reinterpret_cast<Scene *>(id_node->id_orig); | ||||
| return BKE_view_layer_default_render(scene_orig); | return BKE_view_layer_default_render(scene_orig); | ||||
| } | } | ||||
| /* Is possible to have scene linked indirectly (i.e. via the driver) which | /* Is possible to have scene linked indirectly (i.e. via the driver) which | ||||
| * we need to support. Currently there aer issues somewhere else, which | * we need to support. Currently there are issues somewhere else, which | ||||
| * makes testing hard. This is a reported problem, so will eventually be | * makes testing hard. This is a reported problem, so will eventually be | ||||
| * properly fixed. | * properly fixed. | ||||
| * | * | ||||
| * TODO(sergey): Support indirectly linked scene. */ | * TODO(sergey): Support indirectly linked scene. */ | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* Remove all view layers but the one which corresponds to an input one. */ | /* Remove all view layers but the one which corresponds to an input one. */ | ||||
| void scene_remove_unused_view_layers(const Depsgraph *depsgraph, | void scene_remove_unused_view_layers(const Depsgraph *depsgraph, | ||||
| const IDNode *id_node, | const IDNode *id_node, | ||||
| Scene *scene_cow) | Scene *scene_cow) | ||||
| { | { | ||||
| const ViewLayer *view_layer_input; | const ViewLayer *view_layer_input; | ||||
| /* Indirectly linked scenes means it's not an input scene and not a set scene, and is pulled via | |||||
| * some driver. Such scenes should not have view layers after copy. */ | |||||
| if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) { | if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) { | ||||
| /* Indirectly linked scenes means it's not an input scene and not a set scene, and is pulled | |||||
| * via some driver. Such scenes should not have view layers after copy. */ | |||||
| view_layer_input = NULL; | view_layer_input = NULL; | ||||
| } | } | ||||
| else if (depsgraph->is_render_pipeline_depsgraph) { | |||||
| /* If the dependency graph is used for post-processing (such as compositor) we do need to | |||||
| * have access to its view layer names so can not remove any view layers. | |||||
| * On a more positive side we can remove all the bases from all the view layers. */ | |||||
| return; | |||||
| } | |||||
| else { | else { | ||||
| view_layer_input = get_original_view_layer(depsgraph, id_node); | view_layer_input = get_original_view_layer(depsgraph, id_node); | ||||
| } | } | ||||
| ViewLayer *view_layer_eval = NULL; | ViewLayer *view_layer_eval = NULL; | ||||
| /* Find evaluated view layer. At the same time we free memory used by | /* Find evaluated view layer. At the same time we free memory used by | ||||
| * all other of the view layers. */ | * all other of the view layers. */ | ||||
| for (ViewLayer *view_layer_cow = reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first), | for (ViewLayer *view_layer_cow = reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first), | ||||
| *view_layer_next; | *view_layer_next; | ||||
| Show All 10 Lines | void scene_remove_unused_view_layers(const Depsgraph *depsgraph, | ||||
| /* Make evaluated view layer the only one in the evaluated scene (if it exists). */ | /* Make evaluated view layer the only one in the evaluated scene (if it exists). */ | ||||
| if (view_layer_eval != NULL) { | if (view_layer_eval != NULL) { | ||||
| view_layer_eval->prev = view_layer_eval->next = NULL; | view_layer_eval->prev = view_layer_eval->next = NULL; | ||||
| } | } | ||||
| scene_cow->view_layers.first = view_layer_eval; | scene_cow->view_layers.first = view_layer_eval; | ||||
| scene_cow->view_layers.last = view_layer_eval; | scene_cow->view_layers.last = view_layer_eval; | ||||
| } | } | ||||
| void scene_remove_all_bases(Scene *scene_cow) | |||||
| { | |||||
| LISTBASE_FOREACH (ViewLayer *, view_layer, &scene_cow->view_layers) { | |||||
| BLI_freelistN(&view_layer->object_bases); | |||||
| } | |||||
| } | |||||
| /* Makes it so given view layer only has bases corresponding to enabled | /* Makes it so given view layer only has bases corresponding to enabled | ||||
| * objects. */ | * objects. */ | ||||
| void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *view_layer) | void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *view_layer) | ||||
| { | { | ||||
| if (view_layer == NULL) { | if (view_layer == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| ListBase enabled_bases = {NULL, NULL}; | ListBase enabled_bases = {NULL, NULL}; | ||||
| Show All 37 Lines | void view_layer_update_orig_base_pointers(const ViewLayer *view_layer_orig, | ||||
| } | } | ||||
| } | } | ||||
| void scene_setup_view_layers_before_remap(const Depsgraph *depsgraph, | void scene_setup_view_layers_before_remap(const Depsgraph *depsgraph, | ||||
| const IDNode *id_node, | const IDNode *id_node, | ||||
| Scene *scene_cow) | Scene *scene_cow) | ||||
| { | { | ||||
| scene_remove_unused_view_layers(depsgraph, id_node, scene_cow); | scene_remove_unused_view_layers(depsgraph, id_node, scene_cow); | ||||
| /* If dependency graph is used for post-processing we don't need any bases and can free of them. | |||||
| * Do it before re-mapping to make that process faster. */ | |||||
| if (depsgraph->is_render_pipeline_depsgraph) { | |||||
| scene_remove_all_bases(scene_cow); | |||||
| } | |||||
| } | } | ||||
| void scene_setup_view_layers_after_remap(const Depsgraph *depsgraph, | void scene_setup_view_layers_after_remap(const Depsgraph *depsgraph, | ||||
| const IDNode *id_node, | const IDNode *id_node, | ||||
| Scene *scene_cow) | Scene *scene_cow) | ||||
| { | { | ||||
| const ViewLayer *view_layer_orig = get_original_view_layer(depsgraph, id_node); | const ViewLayer *view_layer_orig = get_original_view_layer(depsgraph, id_node); | ||||
| ViewLayer *view_layer_eval = reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first); | ViewLayer *view_layer_eval = reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first); | ||||
| ▲ Show 20 Lines • Show All 867 Lines • Show Last 20 Lines | |||||