Fix T37890: compositor did not take number of thread setting into account.

This commit is contained in:
Brecht Van Lommel 2013-12-20 00:43:26 +01:00
parent 8ed0878f0f
commit 29e3b09825
Notes: blender-bot 2023-02-14 11:27:31 +01:00
Referenced by issue #37890, Compositor does not honor fixed threads in performance render settings
3 changed files with 19 additions and 6 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);