Splats · interface

SplatSortScratch

The arrays a sort reuses, allocated once by the caller.

Explained in Gaussian splats.

interface SplatSortScratch
import type { SplatSortScratch } from '@driftengine/splats';

In depth

A sort allocates nothing, which is the whole reason this is a parameter rather than a local: the two histograms are 384 KB between them, and a capture re-sorts whenever the view turns. Doing that in a worker does not make an allocation free — it makes it somebody else's garbage.

Properties

NameTypeDescription
keysreadonlyUint16ArrayThe depth bucket of each splat, carried from the counting pass to the scatter.
countsreadonlyUint32ArrayThe depth histogram, then the prefix sum over it.
sizesreadonlyUint16ArrayThe size bucket of each splat, overwritten by the counting pass with whether it survived.
sizeCountsreadonlyUint32ArrayThe size histogram, walked from the top to find the budget's threshold.
bitsreadonlyFloat32ArrayTwo views of one four-byte buffer, for reading a float's bits without allocating a view.
More

A pair rather than a DataView because this is read once per splat per sort and the typed pair is one store and one load. It is in the scratch rather than at module scope for the same reason everything else here is: the sort is stringified into a worker and closes over nothing.

bitsAsUintreadonlyUint32Array