/** * @role Bridge * Portable stable WebGPU radix sorting adapted to Three.js TSL compute nodes. */ import * as THREE from 'three/webgpu'; import type { SplatSortCenterAdapter, SplatSorter } from './sorter'; import type { SplatSortMetric } from './splat-mesh-types'; import { type PerSourceSortTransform } from './compute-sorter'; import { type SplatSortRange } from './splat-sort-bounds'; /** * Stable four-bit-per-pass WebGPU radix sorter. * * The ranked scatter follows PlayCanvas/WebGPU-Radix-Sort's per-digit bitmask * design. Three.js does not currently expose atomic workgroup arrays in TSL, * so masks use disjoint global-storage slices per workgroup. Workgroup and * storage barriers retain the same stable ranking semantics without relying * on cross-workgroup execution order. */ export declare class RadixSorter implements SplatSorter { readonly kind: "radix"; readonly passCount: number; submissionCount: number; private readonly renderer; private readonly stages; private readonly workingAttributes; /** Frees the JS mirrors three keeps behind the GPU-only ping-pong buffers. */ private readonly mirrors; /** Set by {@link dispose}; makes a second dispose a no-op. */ private disposed; private readonly viewRow0; private readonly viewRow1; private readonly viewRow2; private readonly depthMin; private readonly depthScale; private readonly activeCount; private readonly viewCenter; /** Exact mode avoids scene-bounds quantization entirely. */ private readonly exactDepth; private readonly sortMetric; /** Largest quantized key; radial keys are narrower (see RADIAL_RADIX_KEY_BITS). */ private readonly keyMax; constructor(options: { renderer: THREE.WebGPURenderer; capacity: number; centersTexture?: THREE.DataTexture; dataTextureWidth?: number; /** Gathered world-space centers for a unified renderer. */ centersBuffer?: THREE.StorageBufferAttribute; /** Live source placements for a merged pool of local-space centers. */ perSource?: PerSourceSortTransform; splatIndexAttribute: THREE.StorageInstancedBufferAttribute; sourceIndexAttribute: THREE.StorageBufferAttribute; /** Keep every Float32 depth bit instead of quantizing to 24 bits. */ exactDepth?: boolean; /** Camera-space ordering key. Default `'depth'`. */ sortMetric?: SplatSortMetric; /** Displaces texture-read centers before measuring; see `SplatSortCenterAdapter`. */ sortCenter?: SplatSortCenterAdapter; }); sort(modelView: THREE.Matrix4, activeCount: number, bounds: THREE.Sphere, visibleRange?: SplatSortRange | null): boolean; dispose(): void; }