From 50782df42586a5a038cad11530714371edaa5cd4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 4 Apr 2021 23:51:24 +0200 Subject: Render: faster animation and re-rendering with Persistent Data For Cycles, when enabling the Persistent Data option, the full render data will be preserved from frame-to-frame in animation renders and between re-renders of the scene. This means that any modifier evaluation, BVH building, OpenGL vertex buffer uploads, etc, can be done only once for unchanged objects. This comes at an increased memory cost. Previously there option was named Persistent Images and had a more limited impact on render time and memory. When using multiple view layers, only data from a single view layer is preserved to keep memory usage somewhat under control. However objects shared between view layers are preserved, and so this can speedup such renders as well, even single frame renders. For Eevee and Workbench this option is not available, however these engines will now always reuse the depsgraph for animation and multiple view layers. This can significantly speed up rendering. These engines do not support sharing the depsgraph between re-renders, due to technical issues regarding OpenGL contexts. Support for this could be added if those are solved, see the code comments for details. --- source/blender/depsgraph/intern/depsgraph_tag.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source/blender/depsgraph/intern/depsgraph_tag.cc') diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 2051ee3657a..504c3956d03 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -816,11 +816,22 @@ void DEG_on_visible_update(Main *bmain, const bool do_time) } } +void DEG_enable_editors_update(Depsgraph *depsgraph) +{ + deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; + graph->use_editors_update = true; +} + /* Check if something was changed in the database and inform * editors about this. */ -void DEG_ids_check_recalc( +void DEG_editors_update( Main *bmain, Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, bool time) { + deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; + if (!graph->use_editors_update) { + return; + } + bool updated = time || DEG_id_type_any_updated(depsgraph); DEGEditorUpdateContext update_ctx = {nullptr}; @@ -829,6 +840,8 @@ void DEG_ids_check_recalc( update_ctx.scene = scene; update_ctx.view_layer = view_layer; deg::deg_editors_scene_update(&update_ctx, updated); + + DEG_ids_clear_recalc(depsgraph); } static void deg_graph_clear_id_recalc_flags(ID *id) @@ -842,7 +855,7 @@ static void deg_graph_clear_id_recalc_flags(ID *id) /* XXX And what about scene's master collection here? */ } -void DEG_ids_clear_recalc(Main *UNUSED(bmain), Depsgraph *depsgraph) +void DEG_ids_clear_recalc(Depsgraph *depsgraph) { deg::Depsgraph *deg_graph = reinterpret_cast(depsgraph); /* TODO(sergey): Re-implement POST_UPDATE_HANDLER_WORKAROUND using entry_tags -- cgit v1.2.3