Blender Git Commit Log

Git Commits -> Revision d4c868d

Revision d4c868d by Jacques Lucke (master)
November 16, 2021, 09:16 (GMT)
Geometry Nodes: refactor virtual array system

Goals of this refactor:
* Simplify creating virtual arrays.
* Simplify passing virtual arrays around.
* Simplify converting between typed and generic virtual arrays.
* Reduce memory allocations.

As a quick reminder, a virtual arrays is a data structure that behaves like an
array (i.e. it can be accessed using an index). However, it may not actually
be stored as array internally. The two most important implementations
of virtual arrays are those that correspond to an actual plain array and those
that have the same value for every index. However, many more
implementations exist for various reasons (interfacing with legacy attributes,
unified iterator over all points in multiple splines, ...).

With this refactor the core types (`VArray`, `GVArray`, `VMutableArray` and
`GVMutableArray`) can be used like "normal values". They typically live
on the stack. Before, they were usually inside a `std::unique_ptr`. This makes
passing them around much easier. Creation of new virtual arrays is also
much simpler now due to some constructors. Memory allocations are
reduced by making use of small object optimization inside the core types.

Previously, `VArray` was a class with virtual methods that had to be overridden
to change the behavior of a the virtual array. Now,`VArray` has a fixed size
and has no virtual methods. Instead it contains a `VArrayImpl` that is
similar to the old `VArray`. `VArrayImpl` should rarely ever be used directly,
unless a new virtual array implementation is added.

To support the small object optimization for many `VArrayImpl` classes,
a new `blender::Any` type is added. It is similar to `std::any` with two
additional features. It has an adjustable inline buffer size and alignment.
The inline buffer size of `std::any` can't be relied on and is usually too
small for our use case here. Furthermore, `blender::Any` can store
additional user-defined type information without increasing the
stack size.

Differential Revision: https://developer.blender.org/D12986

Commit Details:

Full Hash: d4c868da9f97a06c3457b8eafd344a23ed704874
Parent Commit: 6d35972
Lines Changed: +3378, -2272

2 Added Paths:

/source/blender/blenlib/BLI_any.hh (+319, -0) (View)
/source/blender/blenlib/tests/BLI_any_test.cc (+108, -0) (View)

95 Modified Paths:

/source/blender/blenkernel/BKE_attribute_access.hh (+29, -34) (Diff)
/source/blender/blenkernel/BKE_geometry_set.hh (+53, -39) (Diff)
/source/blender/blenkernel/BKE_spline.hh (+9, -11) (Diff)
/source/blender/blenkernel/intern/attribute_access.cc (+67, -69) (Diff)
/source/blender/blenkernel/intern/attribute_access_intern.hh (+6, -9) (Diff)
/source/blender/blenkernel/intern/curve_to_mesh_convert.cc (+6, -8) (Diff)
/source/blender/blenkernel/intern/geometry_component_curve.cc (+100, -119) (Diff)
/source/blender/blenkernel/intern/geometry_component_instances.cc (+11, -15) (Diff)
/source/blender/blenkernel/intern/geometry_component_mesh.cc (+99, -107) (Diff)
/source/blender/blenkernel/intern/geometry_component_pointcloud.cc (+4, -5) (Diff)
/source/blender/blenkernel/intern/geometry_set_instances.cc (+4, -4) (Diff)
/source/blender/blenkernel/intern/mesh_sample.cc (+1, -1) (Diff)
/source/blender/blenkernel/intern/spline_base.cc (+5, -7) (Diff)
/source/blender/blenkernel/intern/spline_bezier.cc (+6, -7) (Diff)
/source/blender/blenkernel/intern/spline_nurbs.cc (+7, -9) (Diff)
/source/blender/blenkernel/intern/spline_poly.cc (+2, -4) (Diff)
/source/blender/blenlib/BLI_virtual_array.hh (+799, -279) (Diff)
/source/blender/blenlib/CMakeLists.txt (+2, -0) (Diff)
/source/blender/blenlib/tests/BLI_virtual_array_test.cc (+42, -13) (Diff)
/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc (+11, -11) (Diff)
/source/blender/functions/FN_field.hh (+31, -35) (Diff)
/source/blender/functions/FN_generic_vector_array.hh (+1, -2) (Diff)
/source/blender/functions/FN_generic_virtual_array.hh (+578, -674) (Diff)
/source/blender/functions/FN_generic_virtual_vector_array.hh (+7, -7) (Diff)
/source/blender/functions/FN_multi_function_params.hh (+12, -14) (Diff)
/source/blender/functions/intern/field.cc (+83, -81) (Diff)
/source/blender/functions/intern/generic_vector_array.cc (+2, -3) (Diff)
/source/blender/functions/intern/generic_virtual_array.cc (+461, -181) (Diff)
/source/blender/functions/intern/generic_virtual_vector_array.cc (+5, -5) (Diff)
/source/blender/functions/intern/multi_function_parallel.cc (+1, -3) (Diff)
/source/blender/functions/intern/multi_function_procedure_executor.cc (+2, -1) (Diff)
/source/blender/functions/tests/FN_field_test.cc (+24, -26) (Diff)
/source/blender/functions/tests/FN_multi_function_procedure_test.cc (+37, -0) (Diff)
/source/blender/geometry/intern/mesh_to_curve_convert.cc (+8, -8) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_align_rotation_to_vector.cc (+2, -2) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_clamp.cc (+7, -7) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_color_ramp.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_combine_xyz.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_compare.cc (+13, -13) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_convert.cc (+2, -2) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_curve_map.cc (+7, -8) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_map_range.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_math.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_mix.cc (+12, -9) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_proximity.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_randomize.cc (+4, -4) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_sample_texture.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_separate_xyz.cc (+2, -2) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_transfer.cc (+5, -5) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_vector_math.cc (+29, -29) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_vector_rotate.cc (+21, -21) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_curve_endpoints.cc (+4, -4) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_curve_reverse.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_curve_set_handles.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_curve_spline_type.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_curve_subdivide.cc (+3, -8) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_curve_to_points.cc (+9, -9) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_delete_geometry.cc (+4, -4) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_material_assign.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_mesh_to_curve.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_points_to_volume.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_point_distribute.cc (+9, -9) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_point_instance.cc (+4, -5) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_point_rotate.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_point_scale.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_point_separate.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_point_translate.cc (+2, -2) (Diff)
/source/blender/nodes/geometry/nodes/legacy/node_geo_raycast.cc (+5, -5) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc (+10, -10) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc (+5, -5) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc (+8, -8) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc (+7, -7) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc (+23, -25) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc (+4, -8) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc (+0, -4) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc (+5, -5) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc (+12, -12) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc (+4, -4) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc (+1, -1) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_input_normal.cc (+36, -44) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc (+12, -18) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc (+12, -13) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc (+15, -16) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc (+7, -10) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc (+8, -11) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc (+3, -3) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc (+2, -2) (Diff)
/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc (+9, -10) (Diff)
/source/blender/nodes/intern/node_geometry_exec.cc (+13, -13) (Diff)
/source/blender/nodes/intern/type_conversions.cc (+28, -30) (Diff)
/source/blender/nodes/NOD_geometry_exec.hh (+11, -16) (Diff)
/source/blender/nodes/NOD_type_conversions.hh (+2, -3) (Diff)
/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc (+8, -8) (Diff)
/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc (+15, -15) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021