Geometry Nodes: Blur node speed up #109764

Merged
Hans Goudey merged 4 commits from mod_moder/blender:tmp_cleanup_blur_tp_map into main 2023-07-10 13:47:36 +02:00

View File

@ -197,27 +197,30 @@ static void build_face_to_face_by_edge_map(const OffsetIndices<int> polys,
Array<int> &r_offsets,
Array<int> &r_indices)
{
Array<int> edge_to_poly_offsets;
Array<int> edge_to_poly_offset_data;
mod_moder marked this conversation as resolved Outdated

offsets_data -> offset_data

`offsets_data` -> `offset_data`
Array<int> edge_to_poly_indices;
const GroupedSpan<int> edge_to_poly_map = bke::mesh::build_edge_to_poly_map(
polys, corner_edges, edges_num, edge_to_poly_offsets, edge_to_poly_indices);
polys, corner_edges, edges_num, edge_to_poly_offset_data, edge_to_poly_indices);
const OffsetIndices<int> edge_to_poly_offsets(edge_to_poly_offset_data);
r_offsets = Array<int>(polys.size() + 1, 0);
for (const int poly_i : polys.index_range()) {
threading::parallel_for(polys.index_range(), 4096, [&](const IndexRange range) {
for (const int poly_i : range) {
for (const int edge : corner_edges.slice(polys[poly_i])) {
for (const int neighbor : edge_to_poly_map[edge]) {
if (neighbor != poly_i) {
r_offsets[poly_i]++;
/* Subtract polygon itself from the number of polygons connected to the edge. */
mod_moder marked this conversation as resolved Outdated

/* Subtract polygon itself from the number of polygons connected to the edge. */

` /* Subtract polygon itself from the number of polygons connected to the edge. */`
r_offsets[poly_i] += edge_to_poly_offsets[edge].size() - 1;
}
}
}
}
const OffsetIndices offsets = offset_indices::accumulate_counts_to_offsets(r_offsets);
});
const OffsetIndices<int> offsets = offset_indices::accumulate_counts_to_offsets(r_offsets);
r_indices.reinitialize(offsets.total_size());
mod_moder marked this conversation as resolved Outdated

I'm not sure about adding these early returns. I'm not sure it would help performance for the expected case (which isn't where many faces have no neighbors)

I'm not sure about adding these early returns. I'm not sure it would help performance for the expected case (which isn't where many faces have no neighbors)

Yes, it would be strange to have such an option .. But on the other hand, maybe?

Yes, it would be strange to have such an option .. But on the other hand, maybe?

It's fine to optimize the node for the expected case. Without some measurements demonstrating these returns improve performance, I'd rather leave them to a separate commit I guess

It's fine to optimize the node for the expected case. Without some measurements demonstrating these returns improve performance, I'd rather leave them to a separate commit I guess
threading::parallel_for(polys.index_range(), 1024, [&](IndexRange range) {
for (const int poly_i : range) {
MutableSpan<int> neighbors = r_indices.as_mutable_span().slice(offsets[poly_i]);
if (neighbors.is_empty()) {
continue;
}
int count = 0;
for (const int edge : corner_edges.slice(polys[poly_i])) {
for (const int neighbor : edge_to_poly_map[edge]) {