Compositor: Inline 2D threaded for utility
This patch inlines the 2D threaded for utility used by the compositor for better performance.
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_function_ref.hh"
|
||||
#include "BLI_index_range.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_task.hh"
|
||||
|
||||
#include "NOD_derived_node_tree.hh"
|
||||
|
||||
@@ -70,8 +71,21 @@ bool is_node_preview_needed(const DNode &node);
|
||||
/* Returns the node output that will be used to generate previews. */
|
||||
DOutputSocket find_preview_output_socket(const DNode &node);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Inline Functions.
|
||||
*/
|
||||
|
||||
/* Executes the given function in parallel over the given 2D range. The given function gets the
|
||||
* texel coordinates of the element of the range as an argument. */
|
||||
void parallel_for(const int2 range, FunctionRef<void(int2)> function);
|
||||
template<typename Function> inline void parallel_for(const int2 range, const Function &function)
|
||||
{
|
||||
threading::parallel_for(IndexRange(range.y), 1, [&](const IndexRange sub_y_range) {
|
||||
for (const int64_t y : sub_y_range) {
|
||||
for (const int64_t x : IndexRange(range.x)) {
|
||||
function(int2(x, y));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace blender::realtime_compositor
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_function_ref.hh"
|
||||
#include "BLI_index_range.hh"
|
||||
#include "BLI_math_vector.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_task.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
@@ -169,15 +166,4 @@ DOutputSocket find_preview_output_socket(const DNode &node)
|
||||
return DOutputSocket();
|
||||
}
|
||||
|
||||
void parallel_for(const int2 range, FunctionRef<void(int2)> function)
|
||||
{
|
||||
threading::parallel_for(IndexRange(range.y), 1, [&](const IndexRange sub_y_range) {
|
||||
for (const int64_t y : sub_y_range) {
|
||||
for (const int64_t x : IndexRange(range.x)) {
|
||||
function(int2(x, y));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace blender::realtime_compositor
|
||||
|
||||
Reference in New Issue
Block a user