Log inGet started
Package

compact.computeShader

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

compact

Turns a keep mask into the indices of the kept elements, and the map back from every element to the place it holds among them.

indices lists the elements whose mask word is not 0 (a float mask of 0.0 and 1.0 reads the same way), in run order; its live count is the number kept. inverse holds, for every element, its place among the kept ones, or -1 for an element that is not kept, so a column carried to the kept elements (a gather by indices) and a column of per-kept values carried back (a read through inverse) agree on which element is which. The nodes that keep a subset of elements run it: core.select, core.weld, core.edges, core.boundary, core.islands, curve.grow, geometry.extrude, geometry.ribbon, instances.to_points, sdf.mesh and sim.particles.

The dispatch size n is the number of elements. One workgroup of 256 works the whole run, each invocation a stretch of ceil(n / 256) consecutive elements: the stretches' kept counts are summed in order once, and each invocation stores its kept elements from the count before its stretch, so a run of any length costs one sum of 256 counts. The other workgroups of a larger dispatch return.

Exact: the order is the run's own, so the same mask gives the same answer on every dispatch.

Over a live count (COUNT=device, see the abi README) n is the capacity and the first domain_count mask words are the elements: words past it are not read, a slot of inverse at or past it holds -1, and the slots of indices past the kept ones hold -1. Each slot at or past the live count is written -1 by the invocation of the dispatch that stands for it, so the slots past a short live count cost one write each across the whole dispatch. indices has room for n and its counter is the live count the next kernel takes as its domain. It binds 5 storage buffers (4 in the plain variant).