Page MenuHome

Geometry Nodes: Add a function to get domain and type without allocation
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Apr 22 2021, 1:15 AM.

Details

Summary

Because we use virtual classes (and for other reasons), we must do a small
allocation when simply retrieving the data type and domain of an existing
attribute. This happened quite a lot actually to determine these values for
result attributes.

This patch adds a simple function to retrieve this meta data information
without building the virtual array. This should lower the overhead of
every attribute node, though the difference probably wouldn't be
noticible unless a tree had many many nodes.

Diff Detail

Repository
rB Blender
Branch
attribute-meta-data-lookup (branched from master)
Build Status
Buildable 14163
Build 14163: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Apr 22 2021, 1:15 AM
Hans Goudey (HooglyBoogly) created this revision.
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/blenkernel/BKE_geometry_set.hh
106

Does it make sense to use get instead of lookup for consistency?

This revision is now accepted and ready to land.Apr 22 2021, 10:45 AM
Hans Goudey (HooglyBoogly) marked an inline comment as done.Apr 22 2021, 2:33 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/blenkernel/BKE_geometry_set.hh
106

For attribute_lookup_meta_data, I think technically the corresponding consistent name might be attribute_try_get_meta_data, since sometimes it doesn't return a value though.
I wanted to avoid "try_get" since I think it sounds awkward, but just using "get" works for me

source/blender/blenkernel/BKE_geometry_set.hh
106

Just get is fine. The std::optional in the return type makes it more clear that it might fail.