Attributes: Integrate implicit sharing with the attribute API #107059

Merged
Jacques Lucke merged 8 commits from HooglyBoogly/blender:implicit-sharing-attribute-api into main 2023-04-19 11:21:21 +02:00
Member

Add the ability to retrieve implicit sharing info directly from the
C++ attribute API, which simplifies memory usage and performance
optimizations making use of it. This commit uses the additions to
the API to avoid copies in a few places:

  • The "rest_position" attribute in the mesh modifier stack
  • Instance on Points node
  • Instances to points node
  • Mesh to points node
  • Points to vertices node

Many files are affected because in order to include the new information
in the API's returned data, I had to switch a bunch of types from
VArray to AttributeReader. This generally makes sense anyway, since
it allows retrieving the domain, which wasn't possible before in some
cases. I overloaded the * deference operator for some syntactic sugar
to avoid the (very ugly) .varray that would be necessary otherwise.

A test with 8 million points and four color attributes, on a Ryzen 7950x:

Before
image

After
image

Add the ability to retrieve implicit sharing info directly from the C++ attribute API, which simplifies memory usage and performance optimizations making use of it. This commit uses the additions to the API to avoid copies in a few places: - The "rest_position" attribute in the mesh modifier stack - Instance on Points node - Instances to points node - Mesh to points node - Points to vertices node Many files are affected because in order to include the new information in the API's returned data, I had to switch a bunch of types from `VArray` to `AttributeReader`. This generally makes sense anyway, since it allows retrieving the domain, which wasn't possible before in some cases. I overloaded the `*` deference operator for some syntactic sugar to avoid the (very ugly) `.varray` that would be necessary otherwise. A test with 8 million points and four color attributes, on a Ryzen 7950x: **Before** ![image](/attachments/09471c1b-7953-4a82-8ab2-0b9ba0ee418c) **After** ![image](/attachments/93308044-1766-4ed7-8e52-93df48385536)
Hans Goudey added 1 commit 2023-04-18 05:48:12 +02:00
ed151b09c9 WIP: Attributes: Integrate implicit sharing with the attribute API
Add the ability to retrieve implicit sharing info directly from the
C++ attribute API, which simplifies memory usage and performance
optimizations making use of it. This commit uses the additions to
the API to avoid copies in a few places:
- The "rest_position" attribute in the mesh modifier stack
- Instance on Points node
- Instances to points node
- Mesh to points node
- Points to vertices node

Many files are affected because in order to include the new information
in the API's returned data, I had to switch a bunch of types from
`VArray` to `AttributeReader`. This generally makes sense anyway, since
it allows retrieving the domain, which wasn't possible before in some
cases. I overloaded the `*` deference operator for some syntactic sugar
to avoid the (very ugly) `.varray` that would be necessary otherwise.

TODO:
- [ ] Fix tests
    - [ ] cycles_pointcloud_cpu (Failed)
    - [ ] geo_node_attributes_test_attribute_curve_map (Failed)
    - [ ] geo_node_attributes_test_attribute_map_range (Failed)
    - [ ] geo_node_attributes_test_attribute_proximity (Failed)
    - [ ] geo_node_curves_test_handle_type_selection (Failed)
    - [ ] geo_node_curves_test_spline_parameter (Failed)
    - [ ] geo_node_geometry_test_delete_geometry (SEGFAULT)
    - [ ] geo_node_geometry_test_realize_instances_materials (Subprocess aborted)
    - [ ] geo_node_instance_test_instance_on_points (Subprocess aborted)
    - [ ] geo_node_instance_test_instance_to_points (Subprocess aborted)
    - [ ] geo_node_instance_test_instance_transforms (Subprocess aborted)
    - [ ] geo_node_mesh_test_set_position_normals_update (Subprocess aborted)
    - [ ] geo_node_points_test_point_instance (Subprocess aborted)
    - [ ] geo_node_utilities_test_accumulate_field_column_grid (Subprocess aborted)
    - [ ] geo_node_vector_test_vector_map_range (Subprocess aborted)
Hans Goudey added this to the Nodes & Physics project 2023-04-18 05:48:28 +02:00
Hans Goudey added 4 commits 2023-04-18 17:58:09 +02:00
Hans Goudey changed title from WIP: Attributes: Integrate implicit sharing with the attribute API to Attributes: Integrate implicit sharing with the attribute API 2023-04-18 18:07:23 +02:00
Hans Goudey requested review from Jacques Lucke 2023-04-18 18:11:39 +02:00
Hans Goudey added the
Interest
Modeling
Interest
Performance
labels 2023-04-18 18:12:02 +02:00
Hans Goudey added 1 commit 2023-04-18 21:07:16 +02:00
Jacques Lucke requested changes 2023-04-18 23:11:04 +02:00
@ -666,0 +663,4 @@
attributes.add<float3>(
"rest_position",
ATTR_DOMAIN_POINT,
AttributeInitShared(positions.varray.common_info().data, *positions.sharing_info));
Member

I think you make too many implicit assumptions here:

  • The attribute is definitely shared.
  • The attribute is definitely stored as continuous array.

Both assumptions generally have to be checked for.

I think you make too many implicit assumptions here: * The attribute is definitely shared. * The attribute is definitely stored as continuous array. Both assumptions generally have to be checked for.
Author
Member

I thought it was reasonable to assume that sharing_info != nullptr implies varray.is_span(), but I can also check the latter explicitly too. I guess this will get nicer when attributes don't always have to be stored as contiguous arrays.

I should definitely check for sharing_info here though. I did it elsewhere and forgot here.

I thought it was reasonable to assume that `sharing_info != nullptr` implies `varray.is_span()`, but I can also check the latter explicitly too. I guess this will get nicer when attributes don't always have to be stored as contiguous arrays. I should definitely check for `sharing_info` here though. I did it elsewhere and forgot here.
Hans Goudey added 2 commits 2023-04-18 23:20:25 +02:00
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey requested review from Jacques Lucke 2023-04-18 23:20:58 +02:00
Jacques Lucke approved these changes 2023-04-19 11:20:11 +02:00
Jacques Lucke merged commit e45ed69349 into main 2023-04-19 11:21:21 +02:00
Jacques Lucke deleted branch implicit-sharing-attribute-api 2023-04-19 11:21:22 +02:00
Sign in to join this conversation.
No reviewers
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 Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107059
No description provided.