Builtin Library
- ..
- README.md1.9 KB
- bindings.yaml2.1 KB
- shader.wgsl2.6 KB
README.md
edges_runs
Turns the sorted sides of a mesh into the edge table. Two stages share one
dispatch shape, chosen by the STAGE specialization:
STAGE headsflags, per sorted place, where a new edge starts;STAGE table, after the flags are compacted intostarts, writes each edge's two points (a<b) and the number of sides along it (fcount).
The whole sequence for a mesh with nv vertices: edges writes lo, hi,
face, rev; a stable sort by hi and then by lo gives order; STAGE heads flags
the heads; compact of the flags gives starts and the live edge count; STAGE table
writes the edges. An edge's faces are the primitives face[order[starts[e] + j]]
for j below fcount[e], so gather(face, order) is the faces column the
core.edges node answers, with starts as its faceStart and fcount its
faceCount. An edge is open when fcount is 1 and manifold when it is at most
2. Integers are 32-bit words, exact.
In the plain variant the n param is the number of sorted places (the vertex
slots, also the most edges there can be); stage table runs over the edges, and an
invocation past the live edges writes values nothing reads.
Over a live count (COUNT=device, see the abi README) domain_count is the number
of live sorted places in both stages, and the n param is not read. Stage heads runs
over the capacity of places and holds 0 in flag past the live ones. Stage table
runs over the capacity of edges: an edge is live where starts holds a place below
the live places (the slots past the live edges hold -1 where compact over a live
count makes them), a run ends at the live places, and every other slot holds -1 and
-1 in a and b and 0 in fcount. The device variant binds the buffers of its own
stage only: 5 storage buffers in stage heads and 8 in stage table (8 in the plain
variant).