/** * splat-shared-sort.parity.ts * * JavaScript port of the WGSL kernel in `splat-shared-sort.wgsl`. Exists so * the kernel can be exercised in Node test harnesses (no WebGPU adapter * available there) and compared bit-for-bit against the CPU reference at * `packages/core/src/traits/MultiviewGaussianRendererTrait.ts::preprocess()`. * * Invariants (each enforced by tests): * 1. For ANY input fixture (positions + view eye/direction tuples), this * parity twin MUST produce the same `visibilityBitmasks` array as * MultiviewGaussianRendererTrait.preprocess() — bit-exact, not approximate. * 2. Distance keys (squared distance to centroid) MUST agree within f32 * tolerance when sorted descending — the back-to-front order must match. * 3. The cone-test threshold `DEFAULT_HALF_FOV_COS` MUST equal the CPU ref's * constant of the same name (currently 0.5 = cos(60deg) half-FOV). * * If the .wgsl file is edited, this parity twin MUST be updated in lockstep. * The test suite catches divergence: a structural regex check confirms the * .wgsl file contains the load-bearing operations (toGLen2, inverseSqrt, * safeNormalize, DEFAULT_HALF_FOV_COS); the behavioral tests confirm the JS * port matches the CPU reference. * * @see splat-shared-sort.wgsl * @see packages/core/src/traits/MultiviewGaussianRendererTrait.ts */ /** Half-FOV cosine threshold — MUST match WGSL constant + CPU ref. */ export declare const DEFAULT_HALF_FOV_COS = 0.5; /** Max view count encodable in the uint32 bitmask. */ export declare const MAX_BITMASK_VIEWS = 32; export interface ParityViewConfig { /** [x, y, z] world-space eye position. */ eyePosition: [number, number, number]; /** [x, y, z] eye look direction — need not be unit-length (safeNormalized internally). */ eyeDirection: [number, number, number]; } export interface ParityResult { /** Per-Gaussian squared distance to the shared centroid (sort key). */ distances: Float32Array; /** Per-Gaussian uint32 visibility bitmask: bit v set ⇒ Gaussian visible in views[v]. */ visibilityBitmasks: Uint32Array; /** Back-to-front sorted Gaussian indices (descending by distance). */ sortedIndices: Uint32Array; } /** * Pure-JS twin of the WGSL `cs_preprocess` kernel. * * @param positions Flat [x0,y0,z0, x1,y1,z1, …] array of Gaussian positions (length 3*N). * @param views Array of view configs. Order matters — bit v in the bitmask refers to views[v]. * @returns Object containing distances, visibilityBitmasks, and back-to-front sortedIndices. */ export declare function preprocessSharedSort(positions: Float32Array | readonly number[], views: readonly ParityViewConfig[]): ParityResult; //# sourceMappingURL=splat-shared-sort.parity.d.ts.map