Geometry Nodes: Avoid copying attributes before reordering #117910
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Depends on
Reference: blender/blender#117910
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:tmp_sort_elements_del_att"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Instead of creating copy of shared attribute to write sorted data, create new empty domains and copy only needed attributes.
Good find. It seems like it would be better not to copy the attributes in the first place. Basically using
BKE_mesh_new_nomain
andBKE_mesh_copy_parameters
instead ofBKE_mesh_copy_for_eval
.We still need to copy all attributes in other domains.
Hmm, right. That would make things more complicated. In that case, how about calling
CustomData_free(&dst_mesh.vert_data, dst_mesh.verts_num);
in the switch cases inreorder_mesh_exec
? That would be clearest since this is just a performance optimization.This need to be done for all supported components.
Im okay with creating empty components, resizing them and coping all attributes in non-target domain... just a lot of hard code with extending components..
Okay, this is nice since we can remove
clean_unused_attributes
.@blender-bot build
Geometry Nodes: Sort Elements node: Delete old attributesto Geometry Nodes: Avoid copying attributes before reordering@ -248,3 +301,1 @@
Mesh *dst_mesh = BKE_mesh_copy_for_eval(&src_mesh);
clean_unused_attributes(propagation_info, dst_mesh->attributes_for_write());
reorder_mesh_exec(src_mesh, old_by_new_map, domain, *dst_mesh);
Mesh *dst_mesh = BKE_mesh_new_nomain(
Actually, this will be a regression in some cases, because the builtin attributes and face offsets won't be shared anymore.
Face offsets can be shared?
Isn't
bke::copy_attributes
copy built-in attributes?BKE_mesh_new_nomain
creates the attributes. Once they already exist, they won't be shared bycopy_attributes
. And yes, face offsets can be shared.Sorry for merging with main and changes in the same commit.
@ -244,3 +298,1 @@
Mesh *dst_mesh = BKE_mesh_copy_for_eval(&src_mesh);
clean_unused_attributes(propagation_info, dst_mesh->attributes_for_write());
reorder_mesh_exec(src_mesh, old_by_new_map, domain, *dst_mesh);
Mesh *dst_mesh = BKE_mesh_new_nomain(
This will allocate the builtin attributes only to free them a moment later. I do think it's better to use some function like
create_mesh_no_attributes
.@ -114,0 +144,4 @@
const bke::AttributeAccessor src_attributes = src_mesh.attributes();
bke::MutableAttributeAccessor dst_attributes = dst_mesh.attributes_for_write();
remove_attributes({"position", ".edge_verts", ".corner_vert", ".corner_edge"}, dst_attributes);
Pretty sure this is unnecessary now
@ -265,3 +318,1 @@
bke::CurvesGeometry dst_curves = bke::CurvesGeometry(src_curves);
clean_unused_attributes(propagation_info, dst_curves.attributes_for_write());
reorder_curves_exec(src_curves, old_by_new_map, dst_curves);
bke::CurvesGeometry dst_curves = bke::CurvesGeometry(src_curves.points_num(),
The same optimization would apply to curves and point clouds
Not sure this is actually optimization rather than just new abstraction for future optimizations of how data block with custom data were allocated. But i can add new functions to construct point cloud/curves/ and so now.
It's worth testing then, I think that's reasonable since the goal of this whole PR is optimization.
I mean, right now we still allocate custom data for mesh, but delete it just in time. This can be done both in
reorder.cc
and inmesh.cc
, but here is no much change, while this allocation is even did.Checkout
From your project repository, check out a new branch and test the changes.