From 14966dfe0febdb5ecc6ca4582907b1e275cc7f2f Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 8 Oct 2025 13:54:09 +0200 Subject: [PATCH] Nodes: skip processing some unlinked outputs in usage inferencing This is a partial fix for #146949. It speeds up drawing by about 15% for me. Pull Request: https://projects.blender.org/blender/blender/pulls/147612 --- .../nodes/intern/socket_usage_inference.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/blender/nodes/intern/socket_usage_inference.cc b/source/blender/nodes/intern/socket_usage_inference.cc index 8382e43febf..9d7f216eb2e 100644 --- a/source/blender/nodes/intern/socket_usage_inference.cc +++ b/source/blender/nodes/intern/socket_usage_inference.cc @@ -543,25 +543,30 @@ class SocketUsageInferencerImpl { const ComputeContext *dependent_socket_context) { /* Check if any of the dependent outputs are used. */ - SocketInContext next_unknown_output; + SocketInContext next_unknown_socket; bool any_output_used = false; for (const bNodeSocket *dependent_socket_ptr : dependent_outputs) { const SocketInContext dependent_socket{dependent_socket_context, dependent_socket_ptr}; const std::optional is_used = all_socket_usages_.lookup_try(dependent_socket); - if (!is_used.has_value() && !next_unknown_output) { - next_unknown_output = dependent_socket; - continue; + if (!is_used.has_value()) { + if (dependent_socket_ptr->is_output() && !dependent_socket_ptr->is_directly_linked()) { + continue; + } + if (!next_unknown_socket) { + next_unknown_socket = dependent_socket; + continue; + } } if (is_used.value_or(false)) { any_output_used = true; break; } } - if (next_unknown_output) { + if (next_unknown_socket) { /* Create a task that checks if the next dependent socket is used. Intentionally only create * a task for the very next one and not for all, because that could potentially trigger a lot * of unnecessary evaluations. */ - this->push_usage_task(next_unknown_output); + this->push_usage_task(next_unknown_socket); return; } if (!any_output_used) {