Geometry Nodes: optimize group input logging

Previously, group input values were logged for each group input socket. This
means that each value might be logged many times currently when there are many
Group Input nodes.

This patch changes it so that group input values are only logged for a single
socket.  In the provided file from #145385 this speeds up playback performance
from 23 to 39 fps. The next bottleneck there is node editor drawing. If I change
the Geometry Nodes editor to another editor type the speedup is 36 (`main`) to
110 fps (this patch).

Pull Request: https://projects.blender.org/blender/blender/pulls/145781
This commit is contained in:
Jacques Lucke
2025-09-05 13:00:24 +02:00
parent 9856615813
commit 40488038cf
2 changed files with 17 additions and 2 deletions

View File

@@ -1764,11 +1764,15 @@ class GeometryNodesLazyFunctionLogger : public lf::GraphExecutor::Logger {
return;
}
const Span<const bNodeSocket *> bsockets =
lf_graph_info_.mapping.bsockets_by_lf_socket_map.lookup(&lf_socket);
Span<const bNodeSocket *> bsockets = lf_graph_info_.mapping.bsockets_by_lf_socket_map.lookup(
&lf_socket);
if (bsockets.is_empty()) {
return;
}
if (bsockets[0]->owner_node().is_group_input()) {
/* Only log a group input once instead of for every group input node separately. */
bsockets = bsockets.take_front(1);
}
for (const bNodeSocket *bsocket : bsockets) {
/* Avoid logging to some sockets when the same value will also be logged to a linked socket.

View File

@@ -688,6 +688,7 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket)
Stack<const bNodeSocket *> sockets_to_check;
sockets_to_check.push(&query_socket);
added_sockets.add(&query_socket);
const bNodeTree &tree = query_socket.owner_tree();
while (!sockets_to_check.is_empty()) {
const bNodeSocket &socket = *sockets_to_check.pop();
@@ -738,6 +739,16 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket)
}
}
}
else if (node.is_group_input()) {
const int index = socket.index();
/* Check if the value is stored for any other group input node. */
for (const bNode *other_group_input : tree.group_input_nodes()) {
const bNodeSocket &other_socket = other_group_input->output_socket(index);
if (added_sockets.add(&other_socket)) {
sockets_to_check.push(&other_socket);
}
}
}
}
}