Page MenuHome

BLI_array_utils::gather()
ClosedPublic

Authored by Mattias Fredriksson (Osares) on Aug 26 2022, 1:17 AM.

Details

Summary

Threaded representations of GVArray::materialize_compressed_to_uninitialized(..) has been reimplemented locally in multiple geometry node contexts. The purpose of this patch is therefore to:

  • Assemble these implementations in a single file.
  • Provide a naming convention that is easier to recognize in comparison to materialize_compressed_to_uninitialized().

It is likely the function has been reimplemented in more places but this is a starting point for assembling them in one place.

Diff Detail

Repository
rB Blender
Branch
gather (branched from master)
Build Status
Buildable 23493
Build 23493: arc lint + arc unit

Event Timeline

Mattias Fredriksson (Osares) requested review of this revision.Aug 26 2022, 1:17 AM
Mattias Fredriksson (Osares) created this revision.
Mattias Fredriksson (Osares) edited the summary of this revision. (Show Details)

Removed unused gather()

Thanks for splitting this out.

source/blender/blenlib/BLI_array_utils.hh
39–49

This could be moved to a .cc file to avoid adding the implementation to every compile unit.
Since that's one of the benefits of a runtime type system, we might as well use it.

Hans Goudey (HooglyBoogly) requested changes to this revision.Aug 30 2022, 1:19 AM
This revision now requires changes to proceed.Aug 30 2022, 1:19 AM
  • Moved gather() impl. to .cc
Aaron Carlisle (Blendify) added inline comments.
source/blender/blenlib/intern/BLI_array_utils.cc
1 ↗(On Diff #55333)
  • Rebased and resolved conflicts, BLI_array_utils.cc -> array_utils.cc, added license statement
  • unincluded BLI_utildefines.h, built with clang
This revision is now accepted and ready to land.Sep 14 2022, 11:26 AM
source/blender/blenlib/BLI_array_utils.hh
48–62

It would be nice to provide a version for Span too, so this can be useful in areas that don't use virtual arrays. That could be a separate step though.

Mattias Fredriksson (Osares) marked an inline comment as done.
  • Rebased, added gather(span), src
  • Asserts
Mattias Fredriksson (Osares) marked an inline comment as done.Sep 15 2022, 11:45 PM

Investigated using GSpan for gather() in mesh_to_curve_convert.cc. Due to attribute_math::convert_to_static_type() being part of BKE, with materialize_compressed_to_uninitialized() only implemented for IndexMask, and get_to_uninitialized() not being as performant. I decided to leave it as is since determining the appropriate approach was not apparent to me.

source/blender/blenlib/BLI_array_utils.hh
48–62

Added for implementations for gather(Span) from my local rejected Blender code depot. Been trying not to add unused functions as they seem to not been approved of 😁.

source/blender/blenlib/BLI_array_utils.hh
48–62

Yeah, generally we avoid it I guess, but I can already think of a few places where it would be helpful :)