Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-01-17 22:36:59 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-01-20 23:01:24 +0300
commit0039432cfcc596d9c97b30db30fd997c750fd0fb (patch)
tree11eb943ba830957b5f820332dac77efe51113253
parent9600f36cfcba0bb9182e8fd453b7ef2040f8886a (diff)
Fix T94715: multiple volumes using the same .vdb causes freeze
Needs more TBB task isolation, as even freeing an OpenVDB grid uses multithreading.
-rw-r--r--source/blender/blenkernel/intern/volume.cc40
1 files changed, 26 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index a72b5268e1d..4178e036d5d 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -137,11 +137,19 @@ static struct VolumeFileCache {
}
std::lock_guard<std::mutex> lock(mutex);
- return simplified_grids.lookup_or_add_cb(simplify_level, [&]() {
- const float resolution_factor = 1.0f / (1 << simplify_level);
- const VolumeGridType grid_type = BKE_volume_grid_type_openvdb(*grid);
- return BKE_volume_grid_create_with_changed_resolution(grid_type, *grid, resolution_factor);
+ openvdb::GridBase::Ptr simple_grid;
+
+ /* Isolate creating grid since that's multithreaded and we are
+ * holding a mutex lock. */
+ blender::threading::isolate_task([&] {
+ simple_grid = simplified_grids.lookup_or_add_cb(simplify_level, [&]() {
+ const float resolution_factor = 1.0f / (1 << simplify_level);
+ const VolumeGridType grid_type = BKE_volume_grid_type_openvdb(*grid);
+ return BKE_volume_grid_create_with_changed_resolution(
+ grid_type, *grid, resolution_factor);
+ });
});
+ return simple_grid;
}
/* Unique key: filename + grid name. */
@@ -246,16 +254,20 @@ static struct VolumeFileCache {
protected:
void update_for_remove_user(Entry &entry)
{
- if (entry.num_metadata_users + entry.num_tree_users == 0) {
- cache.erase(entry);
- }
- else if (entry.num_tree_users == 0) {
- /* Note we replace the grid rather than clearing, so that if there is
- * any other shared pointer to the grid it will keep the tree. */
- entry.grid = entry.grid->copyGridWithNewTree();
- entry.simplified_grids.clear();
- entry.is_loaded = false;
- }
+ /* Isolate file unloading since that's multithreaded and we are
+ * holding a mutex lock. */
+ blender::threading::isolate_task([&] {
+ if (entry.num_metadata_users + entry.num_tree_users == 0) {
+ cache.erase(entry);
+ }
+ else if (entry.num_tree_users == 0) {
+ /* Note we replace the grid rather than clearing, so that if there is
+ * any other shared pointer to the grid it will keep the tree. */
+ entry.grid = entry.grid->copyGridWithNewTree();
+ entry.simplified_grids.clear();
+ entry.is_loaded = false;
+ }
+ });
}
/* Cache contents */