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>2021-06-14 16:50:24 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-06-15 18:28:44 +0300
commitfcc844f8fbd0d10aeb5012c0b25babe76c278e9e (patch)
treecac9fac5b9350a8a2b839188332ba4ef63f2aa44 /source/blender/blenkernel/intern/volume.cc
parentb3f0dc29070c28f19773fd185dae10f004a4f23e (diff)
BLI: use explicit task isolation, no longer part of parallel operations
After looking into task isolation issues with Sergey, we couldn't find the reason behind the deadlocks that we are getting in T87938 and a Sprite Fright file involving motion blur renders. There is no apparent place where we adding or waiting on tasks in a task group from different isolation regions, which is what is known to cause problems. Yet it still hangs. Either we do not understand some limitation of TBB isolation, or there is a bug in TBB, but we could not figure it out. Instead the idea is to use isolation only where we know we need it: when holding a mutex lock and then doing some multithreaded operation within that locked region. Three places where we do this now: * Generated images * Cached BVH tree building * OpenVDB lazy grid loading Compared to the more automatic approach previously used, there is the downside that it is easy to miss places where we need isolation. Yet doing it more automatically is also causing unexpected issue and bugs that we found no solution for, so this seems better. Patch implemented by Sergey and me. Differential Revision: https://developer.blender.org/D11603
Diffstat (limited to 'source/blender/blenkernel/intern/volume.cc')
-rw-r--r--source/blender/blenkernel/intern/volume.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index c0ce57818d1..41f0b5c6b72 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -324,15 +324,20 @@ struct VolumeGrid {
openvdb::io::File file(filepath);
- try {
- file.setCopyMaxBytes(0);
- file.open();
- openvdb::GridBase::Ptr vdb_grid = file.readGrid(name());
- entry->grid->setTree(vdb_grid->baseTreePtr());
- }
- catch (const openvdb::IoError &e) {
- entry->error_msg = e.what();
- }
+ /* Isolate file loading since that's potentially multithreaded and we are
+ * holding a mutex lock. See BLI_task_isolate. Note OpenVDB already uses
+ * TBB, so it's fine to use here without a wrapper. */
+ tbb::this_task_arena::isolate([&] {
+ try {
+ file.setCopyMaxBytes(0);
+ file.open();
+ openvdb::GridBase::Ptr vdb_grid = file.readGrid(name());
+ entry->grid->setTree(vdb_grid->baseTreePtr());
+ }
+ catch (const openvdb::IoError &e) {
+ entry->error_msg = e.what();
+ }
+ });
std::atomic_thread_fence(std::memory_order_release);
entry->is_loaded = true;