feat(webgpu-rt): atomic pixel accumulator + raysPerPixel — >1 ray per pixel per bounce (#30) #31
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!31
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-30"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #30.
What
Lifts the wavefront tracer's one-ray-per-pixel-per-bounce cap, both halves of it:
wfAccumis nowarray<atomic<u32>>(4 slots/pixel, RGBA as f32 bit patterns; same 16 B/pixel footprint).rtAccumulatedoes a per-channel f32 add via anatomicCompareExchangeWeakloop, exactly as sketched in the issue. GENERATE clears withatomicStore(…, 0u)(bitcast<u32>(0.0) == 0u), RESOLVEatomicLoads + bitcasts thevec4<f32>it handsrunResolve.rtEmitRaysilently drops pastrayCapacity, so N shadow rays/pixel would mostly be discarded before they could ever race. NewRTPass::raysPerPixel(default 1) scales those buffers to raysPerPixel·W·H rays per bounce. The accumulator stays per-pixel.Flag-gating question from the issue: not needed
Measured rather than guessed: RTStress (≤1 ray/pixel/bounce) SHADE is ~0.99 ms on this branch vs the ~1.0 ms documented baseline, and a master-vs-branch screenshot of RTStress is byte-identical (
magick compare -metric AE= 0). Uncontended, the weak CAS succeeds first try; a plain-add fallback would buy nothing, so no flag.Test: examples/RTMultiShadow
Five pillars, four colored point lights; the closest-hit emits one shadow ray per light from the same invocation (
raysPerPixel = 4,maxDepth = 2), so up to four rays per pixelrtAccumulatein one SHADE pass — the 3DForts #153 shape. Each pillar casts four separable colored shadows; a race or a capacity drop shows as flickering dark noise / a missing shadow color. Two frames captured a second apart differ by 2 px out of 1.85 M (last-ulp CAS-ordering rounding), i.e. no lost updates.crafter-build test(native): 1 passed.Screenshots