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:
authorManuel Castilla <manzanillawork@gmail.com>2021-07-26 20:16:25 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-07-26 21:13:55 +0300
commite33814ef6baece51cbf9249f4e450eaa4075e707 (patch)
treefc391e9fe063272bb54ffe3ce06e7e5c6d993dc1 /source/blender/compositor/intern/COM_ExecutionSystem.h
parent883fb49d4f1101d5614049c53196546e308a6d33 (diff)
Compositor: Full frame Levels node
Adds full frame implementation to this node operations. No functional changes. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D11749
Diffstat (limited to 'source/blender/compositor/intern/COM_ExecutionSystem.h')
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 38c3432a8ec..ad6f9fd4bdb 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -31,6 +31,7 @@ class ExecutionGroup;
#include "DNA_node_types.h"
#include "BLI_vector.hh"
+#include "atomic_ops.h"
namespace blender::compositor {
@@ -150,6 +151,11 @@ class ExecutionSystem {
*/
ExecutionModel *execution_model_;
+ /**
+ * Number of cpu threads available for work execution.
+ */
+ int num_work_threads_;
+
ThreadMutex work_mutex_;
ThreadCondition work_finished_cond_;
@@ -201,6 +207,27 @@ class ExecutionSystem {
void execute_work(const rcti &work_rect, std::function<void(const rcti &split_rect)> work_func);
+ /**
+ * Multi-threadedly execute given work function passing work_rect splits as argument. On
+ * finished, caller thread will call reduce_func for each thread result.
+ */
+ template<typename TResult>
+ void execute_work(const rcti &work_rect,
+ std::function<TResult(const rcti &split_rect)> work_func,
+ TResult &join,
+ std::function<void(TResult &join, const TResult &chunk)> reduce_func)
+ {
+ Array<TResult> chunks(num_work_threads_);
+ int num_started = 0;
+ execute_work(work_rect, [&](const rcti &split_rect) {
+ const int current = atomic_fetch_and_add_int32(&num_started, 1);
+ chunks[current] = work_func(split_rect);
+ });
+ for (const int i : IndexRange(num_started)) {
+ reduce_func(join, chunks[i]);
+ }
+ }
+
bool is_breaked() const;
private: