Skip to content

Commit

Permalink
Fix #108778: Crash when rendering multiple view layers
Browse files Browse the repository at this point in the history
The rendering pipeline will re-use dependency graph and request
for re-building its relations for every new view layer, and try
to re-use as much evaluation as possible.

This could potentially run into situation when a content of
collection is changed: due to the difference in the per-view
layer visibility. If the evaluated collection has an object cache
this will make the cache to get out-of-sync with the actual
content. The cache on the evaluated collection might be created
when instancing system iterates over the collection.

This change makes it so the cache is freed when the dependency
graph relations are updated. This might be a bit too intrusive.
There might be ways to somehow ensure the content of the collection
is still the same as it was before the relations update, but this
is much more complicated task. Perhaps the performance is already
good enough.

This is a collaboration with Jacques Lucke, who was looking into
the same report, bouncing some ideas back and forth, and helped
testing the patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/108816
  • Loading branch information
sergeyvfx authored and Sergey Sharybin committed Jun 9, 2023
1 parent b3356b1 commit 823514f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/blender/depsgraph/intern/builder/deg_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "BLI_utildefines.h"

#include "BKE_action.h"
#include "BKE_collection.h"

#include "RNA_prototypes.h"

Expand Down Expand Up @@ -183,6 +184,14 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
flag |= ID_RECALC_NTREE_OUTPUT;
}
}
else {
/* Collection content might have changed (children collection might have been added or
* removed from the graph based on their inclusion and visibility flags). */
const ID_Type id_type = GS(id_node->id_cow->name);
if (id_type == ID_GR) {
BKE_collection_object_cache_free(reinterpret_cast<Collection *>(id_node->id_cow));
}
}
/* Restore recalc flags from original ID, which could possibly contain recalc flags set by
* an operator and then were carried on by the undo system. */
flag |= id_orig->recalc;
Expand Down

0 comments on commit 823514f

Please sign in to comment.