Repository navigation
fix: Dispatch each Compute instance at most once per frame - #9690
Conversation
Build size reportThis PR changes the size of the minified bundles.
|
mvaligursky
left a comment
There was a problem hiding this comment.
Automated PR review by Codex (OpenAI AI agent), reviewing commit 75f34f614a4df5fcd20a9b92ffda523883ce0a46 from scratch.
No actionable correctness, compatibility, resource-lifetime, or performance regressions found in the current diff. I checked the per-dispatch compute pools, recursive prefix-sum passes, radix-sort callers, per-light dispatch indexing (including skipped/cached lights), shared shader/buffer ownership, and destruction paths.
Validation:
- Local unit suite: 3,963 passing, 31 pending. Declaration generation/tests and debug/release ESM builds passed. Changed-file lint and
git diff --checkpassed. Full local lint is blocked only by the absent optionalwebgpupackage intest/webgpu-device.mjs; PR CI, including native WebGPU tests and lint, is green. - Real browser WebGPU: repeated scans with distinct counts in a single submit, including three recursion levels, matched CPU results. The base revision reproduced incorrect results while the PR fixed them.
- Perspective and fisheye interval compaction with opposing frusta/cones in a single submit produced independent, correct candidate counts and IDs. The base revision incorrectly used the final cull parameters for both dispatches.
- Portable radix sorting matched CPU results for direct/indirect dispatch, 4/8/16/32-bit keys, and sizes from 1 to 33,001 elements. Caller-provided initial values remained unchanged.
- The new warning fired for repeat dispatch of one instance without submission, but not for distinct instances sharing a shader or dispatches separated by a submit. Standalone compute instances were released after destruction.
- GPU-sort splat rendering exercised one/three directional lights, one-shot/cached shadows, and disabling/re-enabling a light at two camera/modifier poses. No unexpected warnings or GPU validation errors. Single-light output matched the independently repeated base captures exactly: 0 differing pixels out of 24,576.
Non-blocking coverage suggestion: the numerical multi-dispatch prefix-sum and distinct-frustum compaction cases would be useful permanent regression tests; they directly detect the underlying uniform-buffer aliasing, beyond checking warnings and dispatch indices.
A compute instance holds a single set of uniform values, uploaded when it is dispatched, and the GPU executes the dispatches of a frame once they are submitted. Dispatching the same instance more than once in a frame therefore ran all its dispatches with the uniform values of the last one. This makes the rule explicit, warns about it in debug builds, and fixes the engine code which dispatched instances more than once, including GPU sorted gaussian splat shadows, where every light was coarse culled with the frustum of the last light.
Changes:
Compute: an instance is dispatched at most once in a frame. To dispatch a compute shader more than once in a frame, use a separate instance for each dispatch. The instances can share the shader, which is compiled only once.