GS WebGPU fastpath#18648
Conversation
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Reviewer - this PR has made changes to one or more package.json files. |
|
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18648/merge/index.html#WGZLGJ#4600 Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves): https://playground.babylonjs.com/?snapshot=refs/pull/18648/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/18648/merge#BCU1XR#0 If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools. |
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
|
Reviewer - this PR has made changes to one or more package.json files. |
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
Visualization tests for WebGPU |
⚡ Performance Test ResultsBaseline: Latest · Candidate: Dev
🔘 Not Significant — p ≥ 0.05 (1)
|
|
WebGL2 visualization test reporter: |
|
Reviewer - this PR has made changes to one or more package.json files. |
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
⚡ Performance Test Results❌ Failed Tests (1)
|
|
Reviewer - this PR has made changes to one or more package.json files. |
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
|
Reviewer - this PR has made changes to one or more package.json files. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a WebGPU compute “fast path” for Gaussian Splatting by moving depth sorting (and optional frustum culling + indirect draw) onto the GPU, supported by new WGSL compute shaders and a reusable hierarchical exclusive prefix-sum helper.
Changes:
- Add a WebGPU compute-based Gaussian Splatting GPU sorter (counting-sort style) plus optional GPU culling + GPU-driven indirect draws.
- Add a reusable
PrefixSumComputehelper + WGSL scan shaders and wire it into the sorter/culling pipeline. - Extend engine/mesh plumbing for caller-owned indirect draw buffers, plus devhost validation scene and a small unit test.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/treeshaking/side-effects-manifest/core/ShadersWGSL.json | Registers new WGSL compute shader side effects for tree-shaking. |
| scripts/treeshaking/side-effects-manifest/core/Meshes.json | Registers the new GPU sorter module side effects. |
| scripts/treeshaking/side-effects-manifest/core/Compute.json | Registers the new prefix sum compute wrapper side effects. |
| packages/tools/devHost/src/testScene/main.ts | Switches devhost test scene to WebGPU engine setup. |
| packages/tools/devHost/src/testScene/createScene.ts | Loads a .splat and forces GPU sort path; exposes runtime verification info. |
| packages/public/@babylonjs/core/package.json | Publishes new JS entrypoints for prefix sum + GPU sorter. |
| packages/dev/core/test/unit/Meshes/babylon.gaussianSplatting.gpuSorter.test.ts | Adds unit coverage for compute-support detection. |
| packages/dev/core/src/ShadersWGSL/prefixSumScanBlock.compute.fx | Adds WGSL block-scan shader used by hierarchical exclusive scan. |
| packages/dev/core/src/ShadersWGSL/prefixSumAddOffsets.compute.fx | Adds WGSL add-offsets shader for hierarchical exclusive scan. |
| packages/dev/core/src/ShadersWGSL/gaussianSplattingSortClear.compute.fx | Adds histogram clear compute pass. |
| packages/dev/core/src/ShadersWGSL/gaussianSplattingSortDepth.compute.fx | Adds depth + range reduction compute pass. |
| packages/dev/core/src/ShadersWGSL/gaussianSplattingSortHistogram.compute.fx | Adds bucket histogram compute pass. |
| packages/dev/core/src/ShadersWGSL/gaussianSplattingSortScatter.compute.fx | Adds scatter compute pass to produce sorted indices. |
| packages/dev/core/src/ShadersWGSL/gaussianSplattingCull.compute.fx | Adds post-sort frustum-flag compute pass. |
| packages/dev/core/src/ShadersWGSL/gaussianSplattingCullCompact.compute.fx | Adds compaction compute pass for visible splats. |
| packages/dev/core/src/ShadersWGSL/gaussianSplattingCullFinalize.compute.fx | Adds indirect-args + padding finalize compute pass. |
| packages/dev/core/src/ShadersWGSL/gaussianSplatting.vertex.fx | Clips the GPU-culling padding sentinel (-1) so partial instances render nothing. |
| packages/dev/core/src/Meshes/thinInstanceMesh.types.ts | Adds internal API surface to bind a GPU-produced splat-index buffer. |
| packages/dev/core/src/Meshes/thinInstanceMesh.pure.ts | Implements GPU DataBuffer binding as thin-instance splatIndex attributes. |
| packages/dev/core/src/Meshes/mesh.pure.ts | Adds _indirectDrawBuffer plumbing and uses indirect draw when present. |
| packages/dev/core/src/Meshes/GaussianSplatting/pure.ts | Exposes the new GPU sorter via the pure barrel. |
| packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMeshBase.ts | Ensures GPU sorter side effects are included in the non-pure path. |
| packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.ts | Adds GPU sort mode controls and integrates GPU sort/cull/indirect draw path. |
| packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.ts | Side-effect wrapper importing shaders + prefix sum. |
| packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.pure.ts | Implements compute-driven sorting, optional culling, and indirect args handling. |
| packages/dev/core/src/Engines/webgpuEngine.pure.ts | Adds a caller-owned indirect draw path into the WebGPU fast draw pipeline. |
| packages/dev/core/src/Engines/abstractEngine.pure.ts | Adds a base API for drawIndexedIndirect via caller-owned buffer (WebGPU-only). |
| packages/dev/core/src/Compute/pure.ts | Exposes prefix sum helper via compute pure barrel. |
| packages/dev/core/src/Compute/prefixSumCompute.ts | Side-effect wrapper importing prefix-sum WGSL shaders. |
| packages/dev/core/src/Compute/prefixSumCompute.pure.ts | Implements hierarchical exclusive prefix sum driver with per-dispatch UBO ring. |
Comments suppressed due to low confidence (1)
packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.ts:3285
- When
_useGpuSortswitches fromtruetofalse(e.g. runtime change ofGpuSortMode), any previously GPU-bound state is not cleared. In particular, per-camera meshes may still have_indirectDrawBufferset andsplatIndexBufferSet=truefrom the GPU path, so the worker path will callthinInstanceBufferUpdated("splatIndex")and fail to update (the GPU buffer wrapper is not updatable) and may continue issuing indirect draws. Clearing these flags/bindings when falling back to the worker path avoids stale rendering/crashes.
}
protected _instantiateWorker(): void {
if (!this._vertexCount) {
return;
}
if (this._disableDepthSort) {
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
|
Reviewer - this PR has made changes to one or more package.json files. |
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18648/merge/index.html#WGZLGJ#4600 Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves): https://playground.babylonjs.com/?snapshot=refs/pull/18648/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/18648/merge#BCU1XR#0 If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools. |
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
|
let me know if you need approval or is it still in draft |
No description provided.