perf: split viewDepth into separate depthBuffer for sort cache locality#8587
Merged
mvaligursky merged 1 commit intomainfrom Apr 10, 2026
Merged
perf: split viewDepth into separate depthBuffer for sort cache locality#8587mvaligursky merged 1 commit intomainfrom
mvaligursky merged 1 commit intomainfrom
Conversation
Move viewDepth out of projCache (slot 7) into a parallel depthBuffer, reducing CACHE_STRIDE from 8 to 7. Total memory is unchanged — projCache shrinks by 1 u32/splat while depthBuffer adds 1 u32/splat. Sort passes (bitonic, bucket sort, chunk sort) now read depth via stride-1 depthBuffer[entryIdx] instead of stride-8 projCache[entryIdx * 8 + 7], eliminating cache thrashing on random depth lookups. Measured 3x improvement on bucket sort (0.6ms → 0.2ms) and ~0.3ms total frame improvement on 17M-splat scenes. Also merges globalPairCounter and largeSplatCount into a single countersBuffer[2] to stay within the 10 storage-buffer-per-stage WebGPU limit on Metal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Splits
viewDepthout ofprojCacheinto a dedicated paralleldepthBuffer, improving sort pass cache behavior for zero additional memory cost.Changes:
CACHE_STRIDEfrom 8 to 7 by removingviewDepthfromprojCacheslot 7depthBuffer(1 u32 per splat) written during tile count, read by all sort and rasterize passesdepthBuffer[entryIdx]instead of stride-8projCache[entryIdx * 8 + 7], eliminating cache thrashing on random depth lookupsglobalPairCounterandlargeSplatCountinto a singlecountersBuffer[2]to stay within the WebGPU 10 storage-buffer-per-stage limit on MetalisActiveflag instead of early return, required for WGSL uniform control flow withatomicLoad-derived boundsPerformance: