DispatchX: dispatches by thread count run that many threads (the ray-tracing builder ran 64 times too many) #1292
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!1292
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1292"
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?
@KyleS98 on GitHub · 2026-11-26 11:24 UTC · original
KyleS98:fix/dispatchx-thread-dimensions→main· +221 −7 · 8 files · 1 commits · closed without mergingWhat was wrong
DispatchX(x, y, z, flags)passed its flags over ("which the host has no use for"). They are the console card's own dispatch bits, and bit 5 (0x20, "use thread dimensions") changes whatx,y,zmean: counts of threads, not of thread groups. The card runs the groups that hold them and, in the last group, only the threads below the count.The ray-tracing structure builder dispatches its in-place stages this way:
28918b7150a7aad50x20caa78b8ca62bc3d60x204ddd6f9702fab2a70x80205062bc7a48e842f80x8020(
0x8000is the card's 32-lane-waves bit; those two programs are wave32.) Every other builder program comes through plainDispatch.Taken as groups, a stage of 64 threads a group ran 64 times the threads it was asked for and made its nodes from whatever lay behind the level's records, megabytes past the structure's end. This is what stores bounding boxes over the title's own objects within a second of the first build.
How I know the counts are threads
I traced every builder dispatch with its root arguments. For one structure, 25
DispatchXcalls in a row, alternating the two tree stages; each asks forxand the next stage's records begin exactlyxtimes the node size further on:The stages' code agrees:
28918b71reads one header dword per lane atoffset + group * 8192 + lane * 4and stores one 128-byte node per lane atoffset + group * 8192 + lane * 128, so a group of 64 threads is 64 nodes, and it counts its wave's lanes withs_bcnt1_i32_b64 execto find where the child lists begin.Switching those two programs off (
VICTORY_SKIP_PIPELINES) took the stray write-backs away and the crash with them; switching others off did not.The change
DispatchXwith bit 5 set: the counts become group counts by the program's group size (rounded up), and the host notes the thread count along x for that dispatch.USER_THREAD_LIMIT;u32::MAXfor a dispatch by groups).VICTORY_DISPATCH_THREADS=0andVICTORY_THREAD_LIMIT=0give the old behaviour.Not done: counts along y and z are only rounded up to groups (every dispatch I saw has 1 there).
Tested
RTX 3090 Ti (32-lane waves), on
main06702feplus this commit.lanes_past_a_dispatchs_thread_count_start_outside_exec): one console wave of 64 run as two host waves, every lane stores the number of lanes in EXEC at its own dword. For 64, 63, 33, 32, 31, 6 and 1 threads the lanes below the count store the count and the others store nothing.VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1, Series X, 300 s): the builder started at 11:15:12 and was still running when the run ended at 11:18:07. No exception in the title, no device loss. Before, the title died within seconds of the first builder submission on every run of mine.cargo clippyon both crates: clean.What this does not do
The builder is still not usable on
mainwith this alone. In that run a frame took 4 to 7 seconds, the log hasno number left for another copy; its pages read zeros COPIES=1023and several hundred pages touched without a copy, and I did not check the picture.On my integration branch, with two more changes I will send separately (root views of the builder's programs reached by address, since a bound view ends at its 4 MiB window and structures cross them; and root views that lie in the builder library's own memory, above the directory's 128 GiB), the prologue cell comes out lit through its window with the figure's shadow on the wall. That is one frame at about 4 s a frame, and the title still died later in that run, so I am not claiming more than that here.
AI-assisted (Claude Code, Claude Fable 5.2).
@HLVM04 on GitHub · 2026-11-26 11:27 UTC · original
For overlap: fork PR #994 (stacked on #854 and #993) already handles the same
USE_THREAD_DIMENSIONSbit (0x20 / 0x8020) inDispatchX, with a thread-limited translated form and aUSER_THREAD_LIMITword. It also covers the upload-memory addresses that the builder's header stage reads. That sounds close to the two follow-ups you plan to send.Our data with it, RTX 5070 Ti (32-lane), Windows, Series S profile, on our own integration stack plus #993/#994 (
c9ca6b2+55f0043+51700c6), not on06702fe:VICTORY_BVH_BUILDER=1ran steady at 70-77 ms a frame in the first window scene. There was no crash in 2 runs of 380 s, and interiors were much better lit.These are few runs on a different tree, and we did not run this PR's code. Details are in the #994 thread.
@KyleS98 on GitHub · 2026-11-26 13:02 UTC · original
@HLVM04 thanks, you are right, and it goes further than #994: this is a duplicate. I did not search before opening it.
DispatchXwithUSE_THREAD_DIMENSIONStakes the counts as threads, and the lanes past the count are masked. It also handles y and z, which this PR does not, and it has been run on four cards.The analysis in #16 had the cause before any of us. I reached it separately from my own traces, which is a confirmation and nothing more.
Closing in favour of #646. I will post what is useful from here on #646: the RTX 3090 Ti results and a note on why it no longer merges onto
main.AI-assisted (Claude Code, Claude Fable 5.2).
Pull request closed