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
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')
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cc3
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h27
2 files changed, 29 insertions, 1 deletions
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cc b/source/blender/compositor/intern/COM_ExecutionSystem.cc
index cd2738fc2c7..a449d86deb9 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cc
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc
@@ -82,6 +82,7 @@ ExecutionSystem::ExecutionSystem(RenderData *rd,
BLI_assert_msg(0, "Non implemented execution model");
break;
}
+ num_work_threads_ = WorkScheduler::get_num_cpu_threads();
}
ExecutionSystem::~ExecutionSystem()
@@ -130,7 +131,7 @@ void ExecutionSystem::execute_work(const rcti &work_rect,
/* Split work vertically to maximize continuous memory. */
const int work_height = BLI_rcti_size_y(&work_rect);
- const int num_sub_works = MIN2(WorkScheduler::get_num_cpu_threads(), work_height);
+ const int num_sub_works = MIN2(num_work_threads_, work_height);
const int split_height = num_sub_works == 0 ? 0 : work_height / num_sub_works;
int remaining_height = work_height - split_height * num_sub_works;
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: