diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-06-05 13:53:38 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-06-22 14:06:47 +0300 |
commit | d8c2092b15de61a69bddbc082998a1dc786d73af (patch) | |
tree | b04a183c85b986db1e0d99fbee94be75608afec7 /intern/cycles/render/light.cpp | |
parent | ace3268482c6bfd9986815aaa6b027c99fa8e3f4 (diff) |
Cycles: make TBB a required library dependency, and use in a few places
Now that the rest of Blender also relies on TBB, no point in maintaining custom
code for paraller_for and thread local storage.
Diffstat (limited to 'intern/cycles/render/light.cpp')
-rw-r--r-- | intern/cycles/render/light.cpp | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 25c91a76d58..c0615c6217b 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -680,29 +680,13 @@ void LightManager::device_update_background(Device *device, float2 *cond_cdf = dscene->light_background_conditional_cdf.alloc(cdf_width * res.y); double time_start = time_dt(); - if (max(res.x, res.y) < 512) { - /* Small enough resolution, faster to do single-threaded. */ - background_cdf(0, res.y, res.x, res.y, &pixels, cond_cdf); - } - else { - /* Threaded evaluation for large resolution. */ - const int num_blocks = TaskScheduler::num_threads(); - const int chunk_size = res.y / num_blocks; - int start_row = 0; - TaskPool pool; - for (int i = 0; i < num_blocks; ++i) { - const int current_chunk_size = (i != num_blocks - 1) ? chunk_size : (res.y - i * chunk_size); - pool.push(function_bind(&background_cdf, - start_row, - start_row + current_chunk_size, - res.x, - res.y, - &pixels, - cond_cdf)); - start_row += current_chunk_size; - } - pool.wait_work(); - } + + /* Create CDF in parallel. */ + const int rows_per_task = divide_up(10240, res.x); + parallel_for(blocked_range<size_t>(0, res.y, rows_per_task), + [&](const blocked_range<size_t> &r) { + background_cdf(r.begin(), r.end(), res.x, res.y, &pixels, cond_cdf); + }); /* marginal CDFs (column, V direction, sum of rows) */ marg_cdf[0].x = cond_cdf[res.x].x; |