Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/intern/COM_WorkScheduler.cpp')
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index fc6ea1299cf..e5b9f58ee93 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -50,7 +50,8 @@
/// @brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created
-static vector<CPUDevice *> g_cpudevices;
+static vector<CPUDevice*> g_cpudevices;
+static ThreadLocal(CPUDevice *) g_thread_device;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
/// @brief list of all thread for every CPUDevice in cpudevices a thread exists
@@ -153,9 +154,9 @@ int COM_isHighlightedbNode(bNode *bnode)
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
void *WorkScheduler::thread_execute_cpu(void *data)
{
- Device *device = (Device *)data;
+ CPUDevice *device = (CPUDevice *)data;
WorkPackage *work;
-
+ BLI_thread_local_set(g_thread_device, device);
while ((work = (WorkPackage *)BLI_thread_queue_pop(g_cpuqueue))) {
HIGHLIGHT(work);
device->execute(work);
@@ -310,18 +311,20 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
device->deinitialize();
delete device;
}
-
+ if (g_cpuInitialized) {
+ BLI_thread_local_delete(g_thread_device);
+ }
g_cpuInitialized = false;
}
/* initialize CPU threads */
if (!g_cpuInitialized) {
for (int index = 0; index < num_cpu_threads; index++) {
- CPUDevice *device = new CPUDevice();
+ CPUDevice *device = new CPUDevice(index);
device->initialize();
g_cpudevices.push_back(device);
}
-
+ BLI_thread_local_create(g_thread_device);
g_cpuInitialized = true;
}
@@ -407,7 +410,7 @@ void WorkScheduler::deinitialize()
device->deinitialize();
delete device;
}
-
+ BLI_thread_local_delete(g_thread_device);
g_cpuInitialized = false;
}
@@ -450,3 +453,8 @@ void WorkScheduler::deinitialize()
}
}
+int WorkScheduler::current_thread_id()
+{
+ CPUDevice *device = (CPUDevice *)BLI_thread_local_get(g_thread_device);
+ return device->thread_id();
+}