Refine GSplatRenderer API: rename methods for clarity#8522
Conversation
Rename configureMaterial() to onWorkBufferFormatChanged(), merge setIndirectDraw()+updateIndirect() into setGpuSortedRendering(), and rename disableIndirectDraw() to setCpuSortedRendering(). Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
Refactors the unified GSplat rendering interface to better distinguish CPU-sorted vs GPU-driven/indirect rendering, and to centralize handling of work-buffer format changes.
Changes:
- Renames/reshapes renderer lifecycle hooks (
configureMaterial→onWorkBufferFormatChanged) and rendering-mode APIs (setIndirectDraw/updateIndirect/disableIndirectDraw→setGpuSortedRendering/setCpuSortedRendering). - Updates
GSplatQuadRendererto implement the new hooks and consolidate indirect/GPU-driven setup. - Updates
GSplatManagerto call the new renderer APIs during work-buffer rebuilds and sorting/compaction transitions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/scene/gsplat-unified/gsplat-renderer.js | Updates the base renderer API to new hook/mode method names. |
| src/scene/gsplat-unified/gsplat-quad-renderer.js | Implements onWorkBufferFormatChanged and consolidates GPU-driven rendering configuration. |
| src/scene/gsplat-unified/gsplat-manager.js | Switches manager orchestration to the new renderer hook/mode methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Switch renderer to CPU mode once, before destroying both compaction systems. | ||
| const useCpuSort = false; | ||
| this.renderer.setCpuSortedRendering(); | ||
| this.destroyIntervalCompaction(useCpuSort); | ||
| this.destroyCompaction(useCpuSort); |
There was a problem hiding this comment.
GSplatManager.destroy() calls renderer.destroy() before destroyGpuSorting(), but destroyGpuSorting() now calls renderer.setCpuSortedRendering(). If destroyGpuSorting() runs after the renderer has been destroyed, this will touch destroyed MeshInstance/Material state and can throw. Either call destroyGpuSorting() before renderer.destroy(), or guard/skip the renderer mode switch when the manager is being destroyed (e.g. based on this._destroyed / renderer existence).
| const useCpuSort = false; | ||
| this.renderer.setCpuSortedRendering(); | ||
| this.destroyIntervalCompaction(useCpuSort); | ||
| this.destroyCompaction(useCpuSort); |
There was a problem hiding this comment.
The local useCpuSort constant is set to false but is named as if it indicates switching to CPU sorting; it's only used to suppress additional mode switches in the helper teardown calls. Consider renaming it to something like switchRendererToCpuSort / alreadySwitchedToCpuSort (or just pass false directly) to avoid confusion with the useCpuSort parameter name in the teardown methods.
| const useCpuSort = false; | |
| this.renderer.setCpuSortedRendering(); | |
| this.destroyIntervalCompaction(useCpuSort); | |
| this.destroyCompaction(useCpuSort); | |
| this.renderer.setCpuSortedRendering(); | |
| this.destroyIntervalCompaction(false); | |
| this.destroyCompaction(false); |
| return this._material; | ||
| } | ||
|
|
||
| onWorkBufferFormatChanged() { |
There was a problem hiding this comment.
onWorkBufferFormatChanged() triggers a full material reconfigure, but it doesn't update the inherited _workBufferFormatVersion cache to the new workBuffer.format.extraStreamsVersion. After a workBuffer swap, this makes _syncWithWorkBufferFormat() think the format changed again and perform another sync/update pass on the next frame. Consider updating _workBufferFormatVersion here (or calling super.onWorkBufferFormatChanged() if the base is updated to do it) to keep the cache consistent and avoid redundant work.
| onWorkBufferFormatChanged() { | |
| onWorkBufferFormatChanged() { | |
| super.onWorkBufferFormatChanged(); |
Refine the internal GSplatRenderer API to use clearer, more generic method names that better describe the rendering mode being configured rather than the implementation mechanism.
Changes:
configureMaterial()toonWorkBufferFormatChanged()to reflect its generic purposesetIndirectDraw()+updateIndirect()into a singlesetGpuSortedRendering()methoddisableIndirectDraw()tosetCpuSortedRendering()disableIndirectDrawparameter/variable touseCpuSort