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:
authorMattias Fredriksson <Osares>2022-09-18 06:12:02 +0300
committerHans Goudey <h.goudey@me.com>2022-09-18 06:12:02 +0300
commitce54f4855674059ef9124a27bff0741f97c75eec (patch)
treeaa81be7e4a224d1e06e687d414007a534a6a87c8 /source/blender/blenlib/intern/array_utils.cc
parent095516403c48ad1586d732ba2fc8d641827f7572 (diff)
BLI: Add generic utlity for gathering values with indices
Add new functions to `array_utils` namespace called `gather(..)`. Versions of `GVArray::materialize_compressed_to_uninitialized(..)` with threading have been reimplemented locally in multiple geometry node contexts. The purpose of this patch is therefore to: * Assemble these implementations in a single file. * Provide a naming convention that is easier to recognize. Differential Revision: https://developer.blender.org/D15786
Diffstat (limited to 'source/blender/blenlib/intern/array_utils.cc')
-rw-r--r--source/blender/blenlib/intern/array_utils.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/array_utils.cc b/source/blender/blenlib/intern/array_utils.cc
index a0fc8810199..a837d6aceec 100644
--- a/source/blender/blenlib/intern/array_utils.cc
+++ b/source/blender/blenlib/intern/array_utils.cc
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_array_utils.hh"
-#include "BLI_task.hh"
namespace blender::array_utils {
@@ -17,4 +16,16 @@ void copy(const GVArray &src,
});
}
+void gather(const GVArray &src,
+ const IndexMask indices,
+ GMutableSpan dst,
+ const int64_t grain_size)
+{
+ BLI_assert(src.type() == dst.type());
+ BLI_assert(indices.size() == dst.size());
+ threading::parallel_for(indices.index_range(), grain_size, [&](const IndexRange range) {
+ src.materialize_compressed_to_uninitialized(indices.slice(range), dst.slice(range).data());
+ });
+}
+
} // namespace blender::array_utils