From b91b9a8ecaf5392ee64305e9c6f96297a9aec71f Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Tue, 27 Aug 2019 11:06:48 +0200 Subject: 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 --- source/blender/compositor/operations/COM_DenoiseOperation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/compositor/operations') 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 +static pthread_mutex_t oidn_lock = BLI_MUTEX_INITIALIZER; #endif #include @@ -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(); -- cgit v1.2.3