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/util/util_task.h | |
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/util/util_task.h')
-rw-r--r-- | intern/cycles/util/util_task.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index acdb2cb50a2..6b7562c2267 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -29,7 +29,7 @@ class Task; class TaskPool; class TaskScheduler; -typedef boost::function<void(Task*,int)> TaskRunFunction; +typedef boost::function<void(void)> TaskRunFunction; /* Task * @@ -39,7 +39,11 @@ class Task { public: Task() {}; + Task(const TaskRunFunction& run_) : run(run_) {} + virtual ~Task() {} + + TaskRunFunction run; }; /* Task Pool @@ -54,12 +58,13 @@ public: class TaskPool { public: - TaskPool(const TaskRunFunction& run); + TaskPool(); ~TaskPool(); void push(Task *task, bool front = false); + void push(const TaskRunFunction& run, bool front = false); - void wait(); /* wait until all tasks are done */ + void wait_work(); /* work and wait until all tasks are done */ void cancel(); /* cancel all tasks, keep worker threads running */ void stop(); /* stop all worker threads */ @@ -70,8 +75,6 @@ protected: void done_increase(int done); - TaskRunFunction run; - thread_mutex done_mutex; thread_condition_variable done_cond; @@ -103,6 +106,7 @@ protected: static thread_mutex mutex; static int users; static vector<thread*> threads; + static vector<int> thread_level; static volatile bool do_exit; static list<Entry> queue; |