Fix black renders after engine 2.19 upgrade by constructing ComputeRadixSort in indirect mode#259
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the GPU splat rasterizer to restore correct output and performance after the PlayCanvas 2.19 engine upgrade by ensuring the radix sort is constructed in indirect mode (as required by the updated ComputeRadixSort API).
Changes:
- Construct
ComputeRadixSortwith{ indirect: true }sosortIndirect()performs an indirect dispatch based on GPUtotalPairs. - Add an explanatory comment documenting the PlayCanvas 2.19 API change and the failure mode when indirect mode is not enabled.
💡 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.
Problem
Since the dependency update in #252 (PlayCanvas 2.18.2 → 2.19.2), the GPU rasterizer produces uniform black/background-only images, and rendering got slower. All three render-golden tests fail with 46–82 byte WebP outputs.
Cause
PlayCanvas 2.19 refactored
ComputeRadixSort(adding the OneSweep backend) and changed how indirect mode is enabled:sortIndirect()recreated the shaders/bind groups for indirect dispatch on the fly.new ComputeRadixSort(device, { indirect: true })), and the execute path only checks that flag.The rasterizer constructed the sort without the flag, so its
sortIndirect()call silently fell back to a direct dispatch sized bymaxElementCount— the full pair-buffer capacity (chunkCap × maxCoveragePerSplat) — instead of reading the GPU-sidetotalPairscount:totalPairssorted as zero keys to the front, sofindBoundariessaw all-zero sorted tile keys and left every tile slice empty except tile 0 — nothing composited, and finalize wrote pure background.No validation errors fired because every API call was valid, just semantically wrong.
Fix
Construct the sort in indirect mode:
This is the only
ComputeRadixSortsite in the repo. The hand-written prepare-indirect shader (1 slot, 2048 elements/workgroup) still matches the portable multipass backend's granularity, which is unchanged in 2.19.Verification
shoe.plyrenders 59.2 KB of real image content (was 82 B black); rasterization time dropped 0.138 s → 0.042 s.