From 7422f2ea7a286bd90d4b892f493fa4477276925d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 8 Oct 2025 19:14:37 +0200 Subject: [PATCH 1/2] Fix #147559: performance regression due to unnecessary geometry copy The geometry was copied later on when it was modified because there was still a reference to it in the modifier. Since this uses implicit sharing, if there is more than one reference, the data has to be copied before it can be modified. Pull Request: https://projects.blender.org/blender/blender/pulls/147644 --- source/blender/nodes/intern/geometry_nodes_execute.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/nodes/intern/geometry_nodes_execute.cc b/source/blender/nodes/intern/geometry_nodes_execute.cc index 5a78b8a0538..b1f07a194f4 100644 --- a/source/blender/nodes/intern/geometry_nodes_execute.cc +++ b/source/blender/nodes/intern/geometry_nodes_execute.cc @@ -875,7 +875,7 @@ bke::GeometrySet execute_geometry_nodes_on_geometry(const bNodeTree &btree, const eNodeSocketDatatype socket_type = typeinfo ? typeinfo->type : SOCK_CUSTOM; if (socket_type == SOCK_GEOMETRY && i == 0) { bke::SocketValueVariant &value = scope.construct(); - value.set(input_geometry); + value.set(std::move(input_geometry)); param_inputs[function.inputs.main[0]] = &value; continue; } From dd75c0b5ec319adbeec5834aac755266c4edf806 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 8 Oct 2025 19:26:12 +0200 Subject: [PATCH 2/2] Fix #147429: Set Resolution node doesn't use default for unselected curves The fix in this case is to properly use the stored builtin attribute defaults when capturing the field on the mesh. I extracted that to a function so the code would read better with early returns. Pull Request: https://projects.blender.org/blender/blender/pulls/147646 --- .../blenkernel/intern/geometry_fields.cc | 28 +++++++++++++++++-- .../curves/resolution_default.blend | 3 ++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/files/modeling/geometry_nodes/curves/resolution_default.blend diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc index 817919b66c7..1ebd605bbb7 100644 --- a/source/blender/blenkernel/intern/geometry_fields.cc +++ b/source/blender/blenkernel/intern/geometry_fields.cc @@ -805,6 +805,31 @@ static bool attribute_data_matches_varray(const GAttributeReader &attribute, con return varray_info.data == attribute_info.data; } +static void initialize_new_data(MutableAttributeAccessor &attributes, + const AttrDomain domain, + const int domain_size, + const StringRef name, + const CPPType &type, + const bke::AttrType data_type, + void *buffer) +{ + /* NOTE: It's unnecessary to fill the values for elements that will be selected and also set + * during field evaluation. A future optimization could evaluate the selection separately and use + * its inverse here. */ + + if (attributes.is_builtin(name)) { + if (const GPointer value = attributes.get_builtin_default(name)) { + type.fill_construct_n(value.get(), buffer, domain_size); + return; + } + } + if (const GAttributeReader old_attribute = attributes.lookup(name, domain, data_type)) { + old_attribute.varray.materialize(buffer); + return; + } + type.fill_construct_n(type.default_value(), buffer, domain_size); +} + bool try_capture_fields_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const Span attribute_ids, @@ -881,8 +906,7 @@ bool try_capture_fields_on_geometry(MutableAttributeAccessor attributes, * - The field does not depend on that attribute (we can't easily check for that yet). */ void *buffer = MEM_mallocN_aligned(type.size * domain_size, type.alignment, __func__); if (!selection_is_full) { - const GAttributeReader old_attribute = attributes.lookup_or_default(id, domain, data_type); - old_attribute.varray.materialize(buffer); + initialize_new_data(attributes, domain, domain_size, id, type, data_type, buffer); } GMutableSpan dst(type, buffer, domain_size); diff --git a/tests/files/modeling/geometry_nodes/curves/resolution_default.blend b/tests/files/modeling/geometry_nodes/curves/resolution_default.blend new file mode 100644 index 00000000000..3d4d936f97d --- /dev/null +++ b/tests/files/modeling/geometry_nodes/curves/resolution_default.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d28cf0e56803966fb61b3d6c84de8bc391d0852d58bac8416d24c5aeece297c +size 369676