refactor: Switch gsplat work buffer from row-aligned to pixel-offset layout#8484
Merged
mvaligursky merged 2 commits intomainfrom Feb 26, 2026
Merged
refactor: Switch gsplat work buffer from row-aligned to pixel-offset layout#8484mvaligursky merged 2 commits intomainfrom
mvaligursky merged 2 commits intomainfrom
Conversation
…layout Replace row-based lineStart/lineCount allocation with contiguous pixel-offset packing, eliminating row padding waste. Simplify texture sizing from binary search to Math.ceil(Math.sqrt(totalPixels)), and clean up shader uniforms (remove uStartLine, combine uLineCount + uTextureWidth into ivec2 uTextureSize). Made-with: Cursor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors GSplat work-buffer addressing from row-aligned allocation to contiguous pixel-offset packing, updating both CPU/GPU metadata flow and the copy-to-workbuffer shaders to match the new layout.
Changes:
- Replace per-splat row allocation (
lineStart/lineCount/viewport) with contiguouspixelOffsetpacking across splats. - Simplify work-buffer sizing to
ceil(sqrt(totalActiveSplats))and propagate new layout metadata through sorting/compaction. - Update GLSL/WGSL copy shaders and render pass uniforms (remove
uStartLine, replaceuLineCount/uTextureWidthwithuTextureSize).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplatCopyInstancedQuad.js | Switch vertex uniform inputs to uTextureSize for NDC mapping. |
| src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js | Remove uStartLine and compute local row directly from absolute rowStart. |
| src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplatCopyInstancedQuad.js | Switch vertex uniform inputs to uTextureSize for NDC mapping. |
| src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js | Remove uStartLine and compute local row directly from absolute rowStart. |
| src/scene/gsplat-unified/gsplat-world-state.js | Compute textureSize from total pixels and assign contiguous pixel offsets. |
| src/scene/gsplat-unified/gsplat-work-buffer-render-pass.js | Remove per-splat viewport/start-line; set uTextureSize and render full RT. |
| src/scene/gsplat-unified/gsplat-unified-sort-worker.js | Build index map using pixelOffsets rather than lineStarts * textureSize. |
| src/scene/gsplat-unified/gsplat-manager.js | Use totalActiveSplats consistently; send pixelOffsets in intervals payload. |
| src/scene/gsplat-unified/gsplat-interval-compaction.js | Use pixelOffset as the work-buffer base index for interval metadata. |
| src/scene/gsplat-unified/gsplat-info.js | Introduce pixelOffset + setLayout; build sub-draws from absolute target offset. |
Comments suppressed due to low confidence (1)
src/scene/gsplat-unified/gsplat-info.js:224
setLayoutwill callupdateSubDrawseven whenactiveSplatsis 0. In that case the synthesized interval is[0, 0),subDrawCountstays 0, andTextureUtils.calcTextureSize(0, ...)returns invalid dimensions (width 0 / height NaN), which will break texture creation. Add an early return foractiveSplats === 0(and ensuresubDrawTexture/subDrawCountare cleared) or makeupdateSubDrawshandlesubDrawCount === 0safely.
setLayout(pixelOffset, textureSize, activeSplats) {
this.pixelOffset = pixelOffset;
// Synthesize a full-range interval when none exist, so all paths use sub-draws
if (this.intervals.length === 0) {
this.intervals[0] = 0;
this.intervals[1] = activeSplats;
}
this.updateSubDraws(textureSize);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
lineStart/lineCountwork buffer allocation with contiguous pixel-offset packing, eliminating up totextureSize - 1pixels of padding waste per splatestimateTextureSize) toMath.ceil(Math.sqrt(totalPixels))uStartLine, combinesuLineCount+uTextureWidthinto a singleivec2 uTextureSize(future-proof for non-square textures)