diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-05 23:44:33 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-05 23:44:33 +0400 |
commit | 8103381ded923a097eae5a0ba012ae41847a83ad (patch) | |
tree | b2d224fac3262dea4eca154480f26bdd10662c81 /intern/cycles/device | |
parent | c53fe94bb4973362278b488ef26384a029d3cc69 (diff) |
Cycles: threading optimizations
* Multithreaded image loading, each thread can load a separate image.
* Better multithreading for multiple instanced meshes, different threads can now
build BVH's for different meshes, rather than all cooperating on the same mesh.
Especially noticeable for dynamic BVH building for the viewport, gave about
2x faster build on 8 core in fairly complex scene with many objects.
* The main thread waiting for worker threads can now also work itself, so
(num_cores + 1) threads will be working, this supposedly gives better
performance on some operating systems, but did not measure performance for
this very detailed yet.
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index ec84047c44f..07988d32aff 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -44,7 +44,6 @@ public: KernelGlobals *kg; CPUDevice(int threads_num) - : task_pool(function_bind(&CPUDevice::thread_run, this, _1, _2)) { kg = kernel_globals_create(); @@ -113,10 +112,8 @@ public: #endif } - void thread_run(Task *task_, int thread_id) + void thread_run(DeviceTask *task) { - DeviceTask *task = (DeviceTask*)task_; - if(task->type == DeviceTask::PATH_TRACE) thread_path_trace(*task); else if(task->type == DeviceTask::TONEMAP) @@ -125,6 +122,15 @@ public: thread_shader(*task); } + class CPUDeviceTask : public DeviceTask { + public: + CPUDeviceTask(CPUDevice *device, DeviceTask& task) + : DeviceTask(task) + { + run = function_bind(&CPUDevice::thread_run, device, this); + } + }; + void thread_path_trace(DeviceTask& task) { if(task_pool.cancelled()) @@ -226,12 +232,12 @@ public: task.split(tasks, TaskScheduler::num_threads()*10); foreach(DeviceTask& task, tasks) - task_pool.push(new DeviceTask(task)); + task_pool.push(new CPUDeviceTask(this, task)); } void task_wait() { - task_pool.wait(); + task_pool.wait_work(); } void task_cancel() |