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
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-04-07 19:44:32 +0300
committerFabian Schempp <fabianschempp@googlemail.com>2022-04-11 01:31:59 +0300
commit9dee3f46df2bf93a591a9fa19d59574acfe3f93e (patch)
treee9256ef8c9618ff91cb1d6b080b386f641f702b5 /source
parent5a855ba57ae4abef6133d4838e0158a5c5888944 (diff)
Geometry Nodes: Parallelize mesh line node
I observed a 4-5x performance improvement (from 50ms to 12ms) with five million points, though obviously the change depends on the hardware. In the future we may want to disable the parallelization in `parallel_invoke` when there is a small amount of points. Differential Revision: https://developer.blender.org/D14590
Diffstat (limited to 'source')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc31
1 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
index cbad4544860..8c1dea90f44 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
@@ -169,15 +169,6 @@ static void node_geo_exec(GeoNodeExecParams params)
namespace blender::nodes {
-static void fill_edge_data(MutableSpan<MEdge> edges)
-{
- for (const int i : edges.index_range()) {
- edges[i].v1 = i;
- edges[i].v2 = i + 1;
- edges[i].flag |= ME_LOOSEEDGE;
- }
-}
-
Mesh *create_line_mesh(const float3 start, const float3 delta, const int count)
{
if (count < 1) {
@@ -189,11 +180,23 @@ Mesh *create_line_mesh(const float3 start, const float3 delta, const int count)
MutableSpan<MVert> verts{mesh->mvert, mesh->totvert};
MutableSpan<MEdge> edges{mesh->medge, mesh->totedge};
- for (const int i : verts.index_range()) {
- copy_v3_v3(verts[i].co, start + delta * i);
- }
-
- fill_edge_data(edges);
+ threading::parallel_invoke(
+ [&]() {
+ threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
+ for (const int i : range) {
+ copy_v3_v3(verts[i].co, start + delta * i);
+ }
+ });
+ },
+ [&]() {
+ threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) {
+ for (const int i : range) {
+ edges[i].v1 = i;
+ edges[i].v2 = i + 1;
+ edges[i].flag |= ME_LOOSEEDGE;
+ }
+ });
+ });
return mesh;
}