fix(webgpu): reshape wavefront TRACE/SHADE to 2-D to survive >4.19M rays #12
No reviewers
Labels
No labels
claude:done
claude:in-progress
claude:ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-11"
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?
Summary
The WebGPU wavefront ray tracer renders a black screen (only non-RT passes survive) once the render surface exceeds ~4K (≈8.3M pixels), while 1080p renders fine.
Root cause: the
TRACE/SHADEstages were dispatched as a 1-D indirect dispatch ofceil(W·H/64)workgroups, which overflowsmaxComputeWorkgroupsPerDimension(65535 on Dawn/Firefox) past ~4.19M rays (~2560×1640). Per the WebGPU spec, an indirect dispatch exceeding the per-dimension limit is silently skipped — no validation error — so the world is never traced.Found while triaging 3DForts issue #35. 3DForts consumes this wavefront path and has no control over the dispatch shape, so the fix belongs here.
Fix
_wfPrep()(additional/dom-webgpu.js) now spreads the workgroups across a 2-D grid:gx = min(wg, 65535),gy = ceil(wg/65535)(= 1 below the threshold, so 1080p is byte-identical).wfTrace/wfShadeentry points (implementations/Crafter.Graphics-PipelineRTWebGPU.cpp) rebuild the linear ray index from(global_invocation_id, num_workgroups):i = gid.y · nwg.x · 64 + gid.x. This is a contiguous bijection onto[0, gx·gy·64); the existingi >= _wfCurCount()guard absorbs the grid overshoot.GENERATE/RESOLVEalready use a 2-D tile dispatch — unchanged.Verification
No automated test suite exists (
crafter-build test→ "No tests matched"), so verified by exercising the real renderer. Ranexamples/RTStressin Firefox/WebGPU and forced the surface to 3449×1739 = 5,997,811 rays → 93,716 workgroups (well over the 65535 cap, the regime that black-screened on master). The full cube grid renders correctly with no validation errors andTRACEtime scales with the larger ray count.Screenshots
Resolves #11
🤖 Generated with Claude Code