import * as THREE from 'three/webgpu'; /** Slowest automatic cadence: at least one sort per second while the view is dirty. */ export declare const MAX_ADAPTIVE_SORT_INTERVAL_MS = 1000; /** Frames at or below this stay on the count/device automatic interval. */ export declare const SORT_HEALTHY_FRAME_MS = 20; /** Frames at or above this stretch cadence all the way to {@link MAX_ADAPTIVE_SORT_INTERVAL_MS}. */ export declare const SORT_STRESSED_FRAME_MS = 33; /** * A single frame this long starts a 1 s sort cooldown. * Chromium often reports a triple-vsync stall as ~49.9 ms, which missed the * previous 50 ms gate and kept scheduling radix into the hitch. */ export declare const SORT_HITCH_FRAME_MS = 48; export type SortSubmissionAction = 'none' | 'submitted' | 'coalesced' | 'suppressed'; export type SortSubmissionTracking = 'pending' | 'gpu-completion' | 'render-ack-fallback'; export type SortSubmissionDiagnostics = { serial: number; frame: number; action: SortSubmissionAction; tracking: SortSubmissionTracking | null; acknowledgementMs: number | null; inputCount: number; }; /** Validates the public fixed sort-interval override. */ export declare function validateSortIntervalMs(value: number | undefined): number | undefined; /** * Returns the automatic WebGPU sort interval for the current active splat count. * * Mobile keeps a floor even for small scenes. A sort is never free: the * counting sorter's clear and scan passes cost the same whatever the splat * count, so on a mobile GPU an every-changed-frame sort stalls the frame * (measured on an Adreno 750: a few frames, then a freeze, repeating). Two * frames of sort latency while the camera moves is imperceptible next to that * - and {@link WebGpuSortScheduler.shouldSubmit} still sorts immediately once * the camera settles, so a stationary view is always exactly ordered. */ export declare function automaticSortIntervalMs(activeCount: number, isMobile?: boolean): number; /** * Stretches the automatic sort interval when recent frames are already long. * * GPU radix/counting is queued (`renderer.compute`), not CPU-awaited, but it * still shares the WebGPU queue with the splat draw, so a scheduled sort can * hitch that one frame. Backing off toward 1 s after a hitch is what stops a * hitch every vsync; {@link MAX_ADAPTIVE_SORT_INTERVAL_MS} keeps a dirty view * from going longer than one second without a sort. An explicit * `sortIntervalMs` override is not passed through here. */ export declare function adaptiveSortIntervalMs(baseIntervalMs: number, frameIntervalEma: number, hitchCooldownUntil: number, now: number): number; /** * Gates WebGPU sort submissions while retaining content swaps and the * final camera pose. Accepted-sort state is committed separately so sorter * backpressure never causes a request to be forgotten. */ export declare class WebGpuSortScheduler { private readonly sortIntervalMs; private readonly isMobile; private xrJitterToleranceEnabled; private readonly previousModelView; private readonly currentInverseModelView; private readonly acceptedInverseModelView; private hasPreviousModelView; private legacyWasMoving; private forcePending; private lastAcceptedAt; private acceptedCount; private submissionSerialValue; private submissionFrameValue; private submissionInputCountValue; private submissionActionValue; private submissionTrackingValue; private submissionAcknowledgementMsValue; private submissionInFlight; private submissionAwaitingRender; private submissionAcknowledgedFrame; private submissionFallbackReleaseFrame; private submissionFallbackReleaseAt; private deferredSubmission; private lastBeginAt; private frameIntervalEma; private hitchCooldownUntil; constructor(sortIntervalMs?: number, isMobile?: boolean); /** Ignore submillimetre headset tracking noise only while XR presents. */ setXrJitterTolerance(enabled: boolean): void; /** Forces the next changed or content-invalidated pose to bypass throttling. */ invalidate(): void; /** * Content changes replace pool indices underneath the current draw order. * They must bypass cadence so a newly active range never renders through a * stale sort while the camera is moving. */ invalidateContent(): void; /** * Whether an invalidation is still waiting for an accepted sort. The WebGL2 * worker path consults this directly: it has no cadence, but a content swap * under a stationary camera must still trigger a re-sort - the swap reset * the draw list to unsorted active order, and without this the scene would * render in that unsorted order until the camera next moved (visible * blend-order flicker on every streaming swap). */ hasPendingForce(): boolean; /** * Returns whether a sort should be submitted at this timestamp. */ shouldSubmit(modelView: THREE.Matrix4, lastAcceptedModelView: THREE.Matrix4, activeCount: number, now: number): boolean; /** * Whether the adaptive cadence would admit a sort at `now`, without touching * the motion tracking {@link shouldSubmit} maintains (it is consulted once * per frame). A compute-projection re-dispatch under a held gate asks this * so the replacement projection and sort follow the cadence the vertex path * and the SH refresh already share, instead of landing on every frame the * GPU fence outlasts: at 8.7M splats that per-frame re-projection doubled * the overview frame p95 on an RTX 3090. Interval 0 (small scenes, explicit * `sortIntervalMs: 0`) is always due, so those still re-project every held * frame. */ isCadenceDue(activeCount: number, now: number): boolean; /** * Commits timing state only after the sorter accepts a submission. */ markAccepted(now: number): void; /** Starts a render frame and reports whether a previous sort still holds the gate. */ beginSubmissionFrame(frame: number, now: number): boolean; /** * Records that the current sort candidate was skipped because a previous * GPU pass still owns the order buffer. Pass `true` only for content / * active-list changes that must re-sort when the buffer is free. Camera-only * motion should pass `false` and keep {@link shouldSubmit} cadence. */ markSubmissionSuppressed(needsResubmission: boolean): void; /** * Assigns a serial to an accepted sort. GPU work is queued, never awaited * here: {@link acknowledgeSubmission} watches `onSubmittedWorkDone` only to * release this gate so a second radix pass cannot stack on the same order * buffer. */ markSubmission(frame: number, inputCount: number): void; /** Whether a GPU sort still owns the shared order buffer. */ hasSubmissionInFlight(): boolean; /** Whether the matching draw callback still needs to acknowledge the submission. */ hasSubmissionAwaitingRender(): boolean; /** Acknowledges the rendered submission and arms either the GPU or Chromium fallback release. */ acknowledgeSubmission(frame: number, now: number, completion?: Promise): void; /** Development-only state for the frame diagnostics. */ submissionDiagnostics(): SortSubmissionDiagnostics; /** Internal diagnostics for the demo HUD; it does not alter scheduling. */ snapshot(): { acceptedCount: number; lastAcceptedAt: number; }; private noteFrameDuration; private resolveInterval; private armFallback; private completeSubmission; private shouldSubmitLegacy; private isWithinMobilePoseTolerance; }