[Bf-blender-cvs] [b91b9a8ecaf] master: Compositor: Run only one instance of OIDN at a time.

Stefan Werner noreply at git.blender.org
Tue Aug 27 11:06:49 CEST 2019


Commit: b91b9a8ecaf5392ee64305e9c6f96297a9aec71f
Author: Stefan Werner
Date:   Tue Aug 27 11:06:48 2019 +0200
Branches: master
https://developer.blender.org/rBb91b9a8ecaf5392ee64305e9c6f96297a9aec71f

Compositor: Run only one instance of OIDN at a time.

Running multiple instances of OIDN simultaneously can use dozens
of GBs of memory. Since OIDN is multithreaded internally, we can run
only one instance at a time and should not lose much performance.
Fixing T69006

===================================================================

M	source/blender/compositor/operations/COM_DenoiseOperation.cpp

===================================================================

diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cpp b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
index ad53ab13def..39ebc63ed20 100644
--- a/source/blender/compositor/operations/COM_DenoiseOperation.cpp
+++ b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
@@ -22,7 +22,9 @@
 #include "COM_DenoiseOperation.h"
 #include "BLI_math.h"
 #ifdef WITH_OPENIMAGEDENOISE
+#  include "BLI_threads.h"
 #  include <OpenImageDenoise/oidn.hpp>
+static pthread_mutex_t oidn_lock = BLI_MUTEX_INITIALIZER;
 #endif
 #include <iostream>
 
@@ -139,7 +141,11 @@ void DenoiseOperation::generateDenoise(float *data,
   }
 
   filter.commit();
+  /* Since it's memory intensive, it's better to run only one instance of OIDN at a time.
+   * OpenImageDenoise is multithreaded internally and should use all available cores nonetheless. */
+  BLI_mutex_lock(&oidn_lock);
   filter.execute();
+  BLI_mutex_unlock(&oidn_lock);
 
   /* copy the alpha channel, OpenImageDenoise currently only supports RGB */
   size_t numPixels = inputTileColor->getWidth() * inputTileColor->getHeight();



More information about the Bf-blender-cvs mailing list