Source geometry from work buffer for SOG spherical harmonics updates#8902
Merged
Conversation
Color-only (spherical harmonics) work buffer updates for SOG resources now reconstruct geometry from the work buffer's stored world-space transform data instead of re-reading and dequantizing the source SOG textures (means_l/means_u/quats/scales). - Add gsplatWorkBufferGeometry chunk (GLSL + WGSL) that decodes the stored center/rotation/scale (both compact and packed work buffer encodings) and converts them back to local space, preserving the getCenter/getRotation/getScale API used by setWorkBufferModifier code. - Add a work-buffer-geometry path to gsplatCopyToWorkbuffer and unify the shared color/SH tail across both paths. - Add a dataFormat layout tag to GSplatFormat (set by GSplatParams) so the decode variant is selected from the format identity rather than by inspecting stream pixel formats. - Gate behind GSplatResourceBase#supportsWorkBufferGeometry (SOG only).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes SOG (splat-over-geometry) spherical harmonics (SH) refreshes by reconstructing geometry (center/rotation/scale) from the already-populated work buffer transform streams, avoiding repeated source texture reads + dequantization during color-only updates.
Changes:
- Adds a new
gsplatWorkBufferGeometryshader chunk (GLSL + WGSL) to decode work-buffer transform data and exposegetCenter/getRotation/getScalefor modifier code. - Updates the
gsplatCopyToWorkbuffershaders to optionally source geometry from the work buffer on the color-only (SH) update path and unify SH evaluation tail logic. - Introduces
GSplatFormat.dataFormat(set byGSplatParams) and a per-resource opt-in (supportsWorkBufferGeometry) enabled for SOG resources.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/scene/shader-lib/wgsl/collections/gsplat-chunks-wgsl.js | Registers the new WGSL work-buffer geometry chunk for inclusion. |
| src/scene/shader-lib/wgsl/chunks/gsplat/vert/formats/sog.js | Compiles out SOG geometry getters when sourcing geometry from the work buffer. |
| src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplatWorkBufferGeometry.js | Adds WGSL work-buffer geometry decode + getter implementations. |
| src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js | Adds work-buffer-geometry path for color-only updates and unifies SH direction handling. |
| src/scene/shader-lib/glsl/collections/gsplat-chunks-glsl.js | Registers the new GLSL work-buffer geometry chunk for inclusion. |
| src/scene/shader-lib/glsl/chunks/gsplat/vert/formats/sog.js | Compiles out SOG geometry getters under work-buffer geometry mode. |
| src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplatWorkBufferGeometry.js | Adds GLSL work-buffer geometry decode + getter implementations. |
| src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js | Adds work-buffer-geometry path for color-only updates and unifies SH direction handling. |
| src/scene/gsplat/gsplat-sog-resource.js | Opts SOG resources into work-buffer geometry sourcing (supportsWorkBufferGeometry). |
| src/scene/gsplat/gsplat-resource-base.js | Enables GSPLAT_WORKBUFFER_GEOMETRY(+COMPACT) defines for color-only passes when supported. |
| src/scene/gsplat/gsplat-format.js | Adds dataFormat tag to identify work buffer layout without stream-format inspection. |
| src/scene/gsplat-unified/gsplat-work-buffer-render-pass.js | Binds work-buffer transform textures / camera position and sets matrix_model_inverse for the new decode path. |
| src/scene/gsplat-unified/gsplat-params.js | Sets format.dataFormat when creating work-buffer formats. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The work-buffer-sourced geometry uniforms (transform textures, camera position, inverse model matrix) are only consumed by shaders compiled with GSPLAT_WORKBUFFER_GEOMETRY, which exist only for resources where supportsWorkBufferGeometry is true. Gate their setup on that condition so color-only (SH) updates of other formats skip the redundant scope resolves and, notably, the per-splat Mat4 inversion. Addresses review feedback on #8902.
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.
Color-only (spherical harmonics) work buffer updates for SOG resources now reconstruct geometry from the work buffer's stored world-space transform data instead of re-reading and dequantizing the source SOG textures. This skips the means/quats/scales source fetches (and V2 codebook lookups) on the SH-refresh pass, which fires whenever the camera translates.
Changes:
gsplatWorkBufferGeometryshader chunk (GLSL + WGSL) that decodes the stored center/rotation/scale for both compact and packed work buffer encodings, then converts them back to local space so user modifier code keeps working unchanged.gsplatCopyToWorkbuffershaders and unify the shared color/SH tail across both the full-render and SH-only paths.dataFormatlayout tag toGSplatFormat(set byGSplatParams) so the decode variant is selected from the format's identity rather than by inspecting stream pixel formats.GSplatResourceBase#supportsWorkBufferGeometry, enabled for SOG only; all other formats keep the existing source-read path.Performance:
Behavior notes:
setWorkBufferModifiercode on the SH path,getCenter/getRotation/getScalenow return post-modifier values reconstructed from the work buffer, so rotation/scale carry the work buffer format's quantization.