diff options
Diffstat (limited to 'source/blender/compositor/intern')
-rw-r--r-- | source/blender/compositor/intern/COM_WorkScheduler.cpp | 20 | ||||
-rw-r--r-- | source/blender/compositor/intern/COM_WorkScheduler.h | 2 | ||||
-rw-r--r-- | source/blender/compositor/intern/COM_compositor.cpp | 3 |
3 files changed, 19 insertions, 6 deletions
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index 57e996fe3b2..76a3d92eb6c 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -271,7 +271,7 @@ static void clContextError(const char *errinfo, const void *private_info, size_t printf("OPENCL error: %s\n", errinfo); } -void WorkScheduler::initialize(bool use_opencl) +void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads) { /* initialize highlighting */ if (!g_highlightInitialized) { @@ -287,11 +287,23 @@ void WorkScheduler::initialize(bool use_opencl) } #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE + /* deinitialize if number of threads doesn't match */ + if (g_cpudevices.size() != num_cpu_threads) { + Device *device; + + while (g_cpudevices.size() > 0) { + device = g_cpudevices.back(); + g_cpudevices.pop_back(); + device->deinitialize(); + delete device; + } + + g_cpuInitialized = false; + } + /* initialize CPU threads */ if (!g_cpuInitialized) { - int numberOfCPUThreads = BLI_system_thread_count(); - - for (int index = 0; index < numberOfCPUThreads; index++) { + for (int index = 0; index < num_cpu_threads; index++) { CPUDevice *device = new CPUDevice(); device->initialize(); g_cpudevices.push_back(device); diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h index 4ab23cf9ae4..78bba1e3074 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.h +++ b/source/blender/compositor/intern/COM_WorkScheduler.h @@ -77,7 +77,7 @@ public: * * This function can be called multiple times to lazily initialize OpenCL. */ - static void initialize(bool use_opencl); + static void initialize(bool use_opencl, int num_cpu_threads); /** * @brief deinitialize the WorkScheduler diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 6f3f0074f2e..e92d2a3d004 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -26,6 +26,7 @@ extern "C" { #include "BLI_threads.h" } #include "BKE_main.h" +#include "BKE_scene.h" #include "BKE_global.h" #include "COM_compositor.h" @@ -72,7 +73,7 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering, /* initialize workscheduler, will check if already done. TODO deinitialize somewhere */ bool use_opencl = (editingtree->flag & NTREE_COM_OPENCL) != 0; - WorkScheduler::initialize(use_opencl); + WorkScheduler::initialize(use_opencl, BKE_render_num_threads(rd)); /* set progress bar to 0% and status to init compositing */ editingtree->progress(editingtree->prh, 0.0); |