Builtin Library
- ..
- README.md1.9 KB
- bindings.yaml1.5 KB
- shader.wgsl2.0 KB
README.md
loops
Orders directed edges into rings and chains. This kernel links each edge to the
edge that follows it (next) and marks the edges a chain starts with (head);
the jump and loops_cut and loops_place kernels do the rest.
For the boundary of a mesh (core.boundary runs the sequence), the directed edges
are its open edges run the way their one face runs them (tail is a when the
core.edges table's reversed is 0, else b). The whole sequence over m edges
and npts points:
loops(STAGEclear, claim, link):next,head.jump(MODEmin), ceil(log2 m) rounds, starting fromparent=nextandvalue= the edge index: every edge holds the smallest index within reach, andparentholds the edge 2^k steps ahead.loops_cut(STAGEhead, cut): a ring (a cycle) starts at its smallest edge; a chain starts at its head. The edge before each start becomes the end of its list.jump(MODErank) over the cut lists, starting withvalue1 on every non-end edge: each edge's end and its distance to it.loops_place(STAGEclaim, place): each edge's ring (the first edge of its list) and its position along the ring.
A compaction of the first edges numbers the rings, and a prefix sum of ring
lengths (rank of the first edge plus 1) gives the ring starts; an edge's place in
the ordered listing is its ring's start plus its position.
Over a live count (COUNT=device, see the abi README) the stages claim and link run
over a capacity of edges whose live count is domain_count, and the n and npts
params are not read. Stage clear runs over the capacity of points and writes the
cleared value into every slot, which is the value a slot past the live points holds.
In stage link a slot past the live edges links to itself and is no head. It binds 7
storage buffers (6 in the plain variant).