Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

expand

Turns a count per element into runs. Element j takes counts[j] slots, in element order; slot s of the result holds owner[s], the element it belongs to, and local_index[s], its place within that element's run. offsets is the exclusive prefix sum of counts (what the scan kernel makes of it), so every slot finds its element by a binary search and has one writer.

owner is an appended output: its live count is the sum of the counts, up to the capacity the dispatch was given. Slots at and past the live count hold -1. An element with a count of zero has no slot; a column of all zeros gives a live count of zero.

Dispatch over n, the capacity of the result. Exact.

core.owner runs it to give every vertex its primitive and its place in the primitive's run. core.realize, core.pairs, core.adjacency, core.resample.curve, core.sample.surface, core.normals.corner and the geometry nodes that make new primitives (geometry.extrude, geometry.sweep, geometry.triangulate, geometry.bevel and others) expand their counts with it.

Over a live count (COUNT=device, see the abi README) the elements are the first domain_count of counts and offsets, so they can be held in runs larger than their live count, and the counter of owner states the sum of their counts as it is, above the capacity too: the first n slots are written and the sum minus n is how many did not fit. A node that states n as a bound checks the count against it. The plain variant clamps the count to n. It binds 6 storage buffers (5 in the plain variant).

Over live elements (ELEMENTS=device) the elements are the first element_count of counts and offsets, whatever n covers: a result sized by one class (the vertices) expanded from the elements of another (the primitives). It binds one storage buffer more.