DispatchX with USE_THREAD_DIMENSIONS (flag 0x20) runs threads, not groups: the BVH builder's rehydration overran its structures (#16) #840
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!840
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/840/head"
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?
@Yorivel on GitHub · 2026-11-25 10:04 UTC · original
Yorivel:fix/dispatch-thread-dims→main· +100 −5 · 7 files · 1 commits · closed without mergingProblem
XboxBvhBuilderlaunches its in-place rehydration stagecaa78b8ca62bc3d6throughDispatchX(x, 1, 1, 0x20). The inline form of the same call (XboxBvhBuilder.dll0x1536a) writes DISPATCH_DIRECT's five dwords,0x4003cc00, x, 1, 1, 0x20. The initiator0x20isUSE_THREAD_DIMENSIONS: x is a number of threads.list.rsdispatch_xdrops the flags and launches x groups of 64.Every lane of that program stores a 64-byte node at
root2 + c[0] + (group << 12) + tid × 64, unbounded, with no early exit (the launch exec mask is saved at0x2b4and restored before the stores). So the extra lanes wrote up to 64× the node area, over neighbouring structures and title objects. This is the source of the all-ones pointers and empty-box bounds in #16's crashes.Evidence (RTX 4090; 648 rehydrated structures in 41 batches, each paired with its own dispatches):
ceil(x/64)groups, no lane limit)3,913 of 3,918 dispatches have an x that isn't a multiple of 64. On the console the lanes past x don't run, so both halves of the fix below are needed.
Change (opt-in:
VICTORY_THREAD_DIMS=1)list.rs:dispatch_xwithflags & 0x20runsceil(x / numthreads.x)(and y, z) groups (dispatch_threads).pipeline.rs:compute_threads(pipeline), the group size from the native program (ComputeIo.threads), cached per pipeline.shader.rs,lower.rs: a host-computed user-data dwordUSER_THREAD_LIMIT(0x104, next toUSER_VIEW_BIAS). With the switch, every compute program starts withthreadId.x < limit, otherwise it branches to the existing abort exit.draw.rs: the dword is x during a thread-dimension dispatch and all ones otherwise (State::thread_limit).shader_cache.rs: the cache key covers the switch.The default behaviour is unchanged. All 52 builder programs translate, validate (
dxil.dll) and create pipelines with the guard on a 32-lane host.caa78b8c,28918b71and4ddd6f97have nos_barrier, so the early exit can't stall a barrier in them.Results (RTX 4090,
VICTORY_BVH_BUILDER=1, otherwise the settings from #16)caa78b8cgroups per dispatch0xffffffffffffffffbuilder runsto the crashEach rehydration's stages now fill one contiguous layout: the decoder
5e687674up to the header's size, then28918b71(128-byte nodes) andcaa78b8c(64-byte nodes) alternating. Checked on three structures from three runs.Not fixed by this: a remaining single crash per run. It comes from a few stray builder writes some KB past a structure's end, which none of the four programs' node ranges reaches; the data-driven parent-link stores are the likely path (details in #16). That is a separate defect.
Diagnostics used (logs of dispatch roots and callers, write-backs with their bytes, physical views, the title's builder calls) are on
diag/bvh-aliasin Yorivel/victory-fork, not in this PR.🤖 Generated with Claude Code
@Yorivel on GitHub · 2026-11-25 10:07 UTC · original
Closing in favour of #646 (@mynzjerko): it's the same fix (thread counts for
DispatchXwithUSE_THREAD_DIMENSIONS, plus masking the lanes past the count), on by default, and it was opened first. Curry-976's run on #646 (builder 4+ min, no crash) and the 5070 bisection in #16 cover it on three cards now. The measurements in this PR's description still apply to #646 if they're useful for review.Pull request closed