[Bf-blender-cvs] [29e3b09] master: Fix T37890: compositor did not take number of thread setting into account.
Brecht Van Lommel
noreply at git.blender.org
Fri Dec 20 01:40:53 CET 2013
Commit: 29e3b098253270d4c5cf8337ad068bf4e98d7bdb
Author: Brecht Van Lommel
Date: Fri Dec 20 00:43:26 2013 +0100
http://developer.blender.org/rB29e3b098253270d4c5cf8337ad068bf4e98d7bdb
Fix T37890: compositor did not take number of thread setting into account.
===================================================================
M source/blender/compositor/intern/COM_WorkScheduler.cpp
M source/blender/compositor/intern/COM_WorkScheduler.h
M source/blender/compositor/intern/COM_compositor.cpp
===================================================================
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index 57e996f..76a3d92 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 4ab23cf..78bba1e 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 6f3f007..e92d2a3 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);
More information about the Bf-blender-cvs
mailing list