GPU: once the BVH builder runs, its title-memory accesses miss host copies every frame, and 5552dac6a2b7a1fd writes 4 GiB above real buffers #3486
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from Marvisak/VIctory. Originally posted by ZeOs360 on 2026-11-27T08:04:42Z.
A standalone issue, as suggested on #2118 for
5552dac6problems. Not a blocker for #2118 itself.Setup: RX 7800 XT, 16 GB RAM.
main63bcca4with #2118 at999a8f6, #2098, #2703, #2841, #2810, #2501, plus a few unrelated open PRs and a local memory-placement change. All 53 builder pipelines are made, none dropped, and the builder runs; no device hang in a 15-minute run.What happens: from the frame the builder starts, nearly every frame's title-memory work misses memory that has no host copy (722 of 723 frames in one 15-minute run; 81 of 658 in a run of the same build without the RT PRs). So the builder's writes are withheld every frame, and its results never reach title memory.
main's withholding does its job: no crash, but no usable BVH either.What we found:
5552dac6a2b7a1fd(42 of 96 distinct shader/program-offset sites in one run, logged with a local diagnostic that records the shader, program offset and address of missed writes). Some go into the builder's own buffers, which have no host copy yet when it runs: nothing tells us the build's destination and scratch ranges before the dispatch, so copies only appear later, from views.real address + 4 GiB - X). The same program offsets write both the real buffers and the +4 GiB addresses, so this looks like a bad value (for example a node pointer read back as 0 or stale, giving a 32-bit index that underflows) rather than one mistranslated instruction. In one run with on-demand copies (below), 107 of the last 512 pages written back were exactly 4 GiB above a 90 MiB buffer that had a host copy.5552dac6came in frames where nothing else missed. Their cause is still open.Two dead ends, to save others time:
s_waitcnt_vscnt/buffer_gl*_invto UAV fences passes a synthetic cross-workgroup test, but changes none of the above in game.image+0x4de96dd,+0x4dd64ec,+0x4debfde).So the build's destination and scratch ranges probably need host copies before its first dispatch to get past
main's withholding, and the +4 GiB writes from5552dac6still need their own fix. Whether they relate to the5552dac6device hang reported on #2118 (RTX 4090) is not known.AI-assisted: found with Claude Code (Claude Opus 5.5) and Gemini 4 Neon. I ran the builds and the in-game tests on my machine.
Imported from Marvisak/VIctory. Originally posted by Ingenioeren on 2026-11-27T09:41:28Z.
I checked whether the upstream title-memory lookup can confuse two addresses with the same low dword. A synthetic extension of the existing memory test on
63bcca4placed different sentinels in separate buffers at0x12_3450_0000and0x13_3450_0000, exactly 4 GiB apart. The RX 6750 XT and Windows WARP agreed in both runs.0x111111110x444444440x11111111Both tests kept the second backing buffer intact. This verifies lookup and miss tracking for addresses the shader already computed. The builder's address calculation and the patch stack in the report are outside this test. For the next diagnostic, the low and high dwords fed into the memory instruction would distinguish a high address already computed by the shader from a discrepancy later in the lookup. Synthetic test base · Region index calculation
AI-assisted synthetic verification with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by ZeOs360 on 2026-11-27T16:10:42Z.
Thanks for testing this. It rules out the lookup: the +4 GiB address must already be in the 64-bit value the shader hands to the memory instruction, which fits the "bad value" reading above (a pointer or index read back wrong and underflowing), not the region mapping. Logging the low and high dwords there is the right next step. Ray tracing is parked on my side for now, so I can't say when I'll get to it.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Slay326 on 2026-11-27T16:42:06Z.
A data point that may fit the "bad pointer/index" direction, from our fork (RTX 3070 and RTX 4070, Windows, offline harness replaying captured builder submissions):
Two of the BVH builder programs,
caa78b8ca62bc3d6and28918b7150a7aad5, are the onlyDispatchXcallers we see whose flags lack bit0x8000(flags0x20; the two other callers,4ddd6f97and5062bc7a, use0x8020). For those two,xbehaves like a thread count, not a group count (x ranged 1..1038 and 1..11632 in a 120 s run). Launchingxgroups of 64 lanes lets the surplus lanes run and write.What we measured in the harness on the same capture:
xwrote 2961 bytes outside the expected range between two consecutive builder dispatches, and the root node of a rehydrated bottom level ended up asffffffffx4.>= xmasked off (exec limited to global id < x, ceil(x / group size) groups), 0 bytes outside, the root kept its children, and valid rehydrated bottom levels went from 0/47 to 67/87.If your builds launch these two programs the same way, masking lanes
>= x(or dispatching ceil(x / group size) groups with the tail masked) might be worth a try against the out-of-range writes you see. We have not tested AMD hardware and cannot say whether it explains your 4 GiB writes.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by ZeOs360 on 2026-11-28T01:55:49Z.
An update on the +4 GiB writes from
5552dac6(5552dac6a2b7a1fd, the pass that builds the BVH4 nodes). I logged the parts of the address as @Ingenioeren suggested. Result: the offset is what wraps, and in most cases it is computed from wrong values the shader reads from the builder's own scratch lists. One case is instead a range check the translation skips.Setup: as in the report, on an RX 7800 XT, plus a local diagnostic. For each missed write it records the base, the 32-bit offset, and the load whose value fed the offset: its address, its value, and whether it found a host copy. The runs are 10 minutes each. The scratch-list names below are my reading of the root views u2, u3 and u4:
parentList,childrenListandparentInfoTable.What the diagnostic shows (8 runs, 348 sites where
5552dac6's 32-bit offset wrapped; most land just under base + 4 GiB):The offset is what wraps. All eight root views are buffer descriptors with
num_records=0xFFFFFFFF, and the translation adds the zero-extended 32-bit offset to the 48-bit base. In every site I checked, the base was the view's own root base.The values come from real reads. In all 348 sites, the load or atomic that fed the offset found a host copy (none missed). So this is not a missed read returning 0. 281 of them are reads of the scratch lists below. The other 67 are fed by allocation-counter atomics.
The header is mostly fine. I dumped the 64-byte header at the base
5552dac6writes to after each list: 850 of 855 were sane. The other 5 came from one later list and were junk. For theparentInfoTablestores, theoffsetToElementsthe shader used matches the final header exactly.parentListandchildrenListhold wrong values. Examples:parentListentries one node below the element area, with type 7 (0x12b4f,0x1285f);parentListvalues (0x347,0x400,0x7ff,0x800,0x7fff);parentListvalue (0xffff10b6);childrenListvalues (0x1f,0x904,0xd6b) where the reused-node path negates the entry.In the first list I checked, in which
5552dac6builds the nodes of about 300 trees, each value came from that tree's own scratch range.It starts at once. The first such writes come in the first frame the builder runs, before anything was ever withheld. So withholding doesn't start this. Whether it makes later frames worse is still open.
One translation difference, and it is not the main cause: the
parentInfoTablestores areidxen(stride 4) through a descriptor whose dword 3 is0x11014fac, which is OOB_SELECT 1: only the index is checked. Withnum_records=0xFFFFFFFF, the console drops a store at index0xFFFFFFFF. The translation has no range check for root views (lower.rs:9464-9476onmain), so that store lands atbase + 4 GiB - 4. A local experiment drops those lanes. These index0xFFFFFFFFstores were in all eight earlier runs (5 to 8 each) and in neither experiment run. Both experiment runs lasted about 4 minutes, and one ended in the crash below, but these stores show up within a minute of the builder starting. The same instructions still wrap with other negative indices, and the other stray writes remain: 40 wrap sites in the 4-minute run. A real fix would also check OOB_SELECT, return 0 from an out-of-range atomic, and read 0 for an out-of-range load.Ruled out in game (+4 GiB writes still there in each case):
glccoherent).ffd93c8adropped, with the rest of the builder still running.DispatchXpoint: this stack has #2841, which treats flag0x20as thread dimensions and masks the surplus lanes.So I now think a pass earlier in the same list writes these lists wrongly here. The next step is to snapshot one tree's lists after each builder pass, to find the first one whose output is wrong.
A separate problem: a root view's base gets one 4 MiB window (the aligned window containing it), so the correct writes of
5552dac6into its node area past that window miss. Those offsets run up to about 5 MiB here, and more in some runs. That alone withholds the list. Making copies of the builder's ranges before the dispatch avoids it.One run of the experiment died at
+0x23cf683(write to 0x0). That is the title fault @borosf mentioned on #2703, which he sees without these changes too.AI-assisted: written by Claude Code (Claude Opus 5.5) and reviewed by Gemini 4 Neon; the GPU tests and in-game runs were made on my machine.
Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-28T03:35:45Z.
We hit this on an NVIDIA base (RTX 3080 Ti) and fixed it in the lowering. For OOB_SELECT 1 with idxen, lanes whose index is at or past num_records go to the null address: loads read 0 and stores are dropped. Offsets stay signed. Details and results: trustno1-coder/VIctory-NVIDIA#690. In a 240 s run with ray tracing on, nothing regressed: 0 refused shaders and the picture is unchanged.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T03:57:52Z.
On the open question of whether later frames get worse: another tree has measured a race that would make them worse, though it can't explain the first-frame writes (read from that tree's notes and issue; not run here).
trustno1-coder/VIctory-NVIDIA (
docs/fork-ray-tracing.md, "Known gaps") found that the title asks for a new dynamic structure's compacted size and reads the slot one or two frames later without checking that the size has arrived. It then takes memory of that size and has the structure copied into it. With the emulated builder, the size lands up to two frames late. So the title reads another structure's old size, and the copy writes over its neighbours. In their dumps only 8 of 65 dynamic structures were intact in one run, and 48 of 275 in another. On an RTX 5080 their trace saw each size arrive one frame after it was asked (0x0 -> 0x21300,docs/findings.md).That fits the junk you saw from later lists: 5 of 855 headers bad, all from one later list. A structure overwritten that way would also hand the next refit wrong parent and child entries.
Waiting for the submissions that ask (
VICTORY_BVH_SIZES_WAIT=1) didn't fix it there and cost about 20 ms a frame, because the title asks every frame. What they run now (trustno1-coder/VIctory-NVIDIA#689) answers the compacted-size slot at the call with the builder'sResultDataMaxSizeInBytesfor that input shape. Before and after the real batched-build call it writes that value into the postbuild slot (desc kind 0), and it keeps the builder's later store off the slot. They report 75.2 to 66.8 ms a frame and the card going from 19.4 to 6.1 ms (RTX 3080 Ti, in a batch with three smaller changes). Their known risk is that the 8 bytes stay protected until the title asks for another kind of postbuild info there.Your snapshot-per-pass plan would show it: a structure whose copy used a stale size would already be wrong at the copy, before any refit.
A second point, about where the wrapped writes land (read from
main63bcca4and another tree's commit; a hypothesis, not measured on hardware). For anidxenroot-view access,mainformsindex * strideas a 32-bit product (lower.rs:9475), adds it to the 32-bit offset, and then adds that sum zero-extended to the 48-bit base (lower.rs:1805-1806). So index -1 at stride 4 lands at base + 4 GiB - 4, which is your parentInfoTable case, and any small negative index lands just under base + 4 GiB. ThatRecompDev/five-star-recompb9b57e21(same title, its own translator) reasons that the hardware addsindex * strideto the base without wrapping, so index -1 lands far beyond any 32-bit range rather than just under base + 4 GiB, and they treat any access whose product reaches 4 GiB as out of range in every mode. That fixed 20-byte records at index -1 landing inside a whole-pool raw view there. Their evidence is a WARP case and the fault going away, not a hardware measurement. Leonida'sdocs/buffer_bounds.mdtable only goes up to index 4.That matters for reading your 348 sites. Splitting them into
idxenandoffenwould show how many come from the 32-bit product rather than from an offset the shader computes. If most areidxenwith negative indices, some of the "wrong" list values may be ones the title uses on the console too (you noted the reused-node path negates its entries), and the translation's wrap is the difference.AI-assisted (Claude Code, Claude Opus 5.5 read that tree's docs and #689, main's lowering and five-star's commit).
Imported from Marvisak/VIctory. Originally posted by lhnizdo on 2026-11-28T07:23:43Z.
@ZeOs360, this looks like what I chased on an RTX 2080: builder lists that come out wrong, and a refit that then misbehaves. Here's what found it for me, in case it helps narrow down the first wrong pass on your card.
On my side there were two causes, both on 32-lane NVIDIA:
28918b71/caa78b8cnever ended (#2920);ffd93c8aread the boxes its own climb had just written, stale through the SRV (#3584).With both fixed, the trees are valid and the refit finishes. Your card is wave64, so neither bug would bite there. That fits your finding that #3584 plus dropping
ffd93c8adidn't help: on your side another pass writes the lists wrongly.The method that worked, after DRED and barrier breadcrumbs had misled me twice:
WriteBufferImmediatemarker goes into system memory and is read back after the loss. That says exactly which dispatch didn't finish.ffd93c8a: a perfect 23,011-leaf tree in, about 2,300 bad links out, every time.The code: steps 1, 2 and 4 (plus the probe) are diagnostics on
lhnizdo:diag/bvh-builder(0a4d0c7). They're switches namedVICTORY_BUILDER_*,VICTORY_REPLAY_*andVICTORY_SHADER_PROBE, described in their commit messages.The tree check and the interpreter are small Python scripts that the repo's asset policy doesn't take. I'm happy to share them some other way if they'd help.
AI-assisted (Claude Code). No game data.
Imported from Marvisak/VIctory. Originally posted by ZeOs360 on 2026-11-28T12:09:49Z.
Root cause of the consistent early +4 GiB writes found: a wave64 lane mask set by halves, in the
builder's radix sort. #3023 fixes it.
Snapshots of one list's buffers between builder passes (local diagnostic) narrowed it down:
first list. After the scatter (
e63d22c4) the keys are no longer a permutation of its input.matched a CPU scatter fed with the dumped scan. The upper digits collide with the lower ones and
overwrite them. Which key wins depends on the order of the GPU's writes, hence the run-to-run
variation.
f6eb6498409ca974(wave64, 64 threads, 4 digits per lane). It adds lane 31's sum tolanes 32..63 with
s_mov_b32 s6, 0; s_mov_b32 s7, -1; v_readlane_b32 s8, v1, 31; v_cndmask_b32 v6, 0, s8, s[6:7]. Onmaina mask whose dwords two instructions write is keptas its low dword only (
Atom::Opaque(lo),pair_highfinds no high dword), so lanes 32..63tested s6 = 0. That is #2780; the masks before it in the same scan (0xaaaaaaaa, …, 0xffff0000)
have equal dwords and were right by chance.
f28a33a8builds broken trees from the unsorted keys;5552dac6a2b7a1fdreads parent and child indices that don't fit the tree;10-minute runs, wrapped-offset sites of
5552dac6a2b7a1fd:Notes on those runs:
two runs translate the game as #3023 does.
+0x23cf683fault, after frame 2035, past the burstwindow.
So the change removes the wraps that started within about 20 s of the builder starting, in every run
without it. The burst in one run about 4 minutes in is intermittent and probably has another cause;
@upipibi's compacted-size race would fit a later-frame one.
Side notes:
v_cndmask_b32lookup bylow dword; no game shader hits it).
off=0xfffffffc) are a separate translation gap: the idxen range check, now#3670 (the same check as trustno1-coder/VIctory-NVIDIA#690, for OOB_SELECT 1). Their four
stores had 5-8 sites per run in the runs without #3023 or the check, and 0 with the check.
AI-assisted: written by Claude Code (Claude Opus 5.5) and reviewed by Gemini 4 Neon;
the GPU tests and in-game runs were made on my machine.
Imported from Marvisak/VIctory. Originally posted by ZeOs360 on 2026-11-28T12:15:57Z.
@lhnizdo thanks, that's close to what found it here: per-pass snapshots of one list, a tree check, and CPU references for the sort passes (histogram, digit scan, scatter). The first wrong output was the digit scan
f6eb6498, a wave64-only bug, which fits your card not hitting it.@upipibi on the split: with the mask fix (#3023 plus the select change, or our own version) the list-read wraps were gone in all three runs, so those list values were wrong, not console values the translation wraps. #3023 alone moved them to one burst about 4 minutes in, which I take to have another cause. The
idxensites were 5-8 per run and 0 with #3670, so this pass's stores range-check their index (OOB_SELECT 0 or 1). Whether the console wraps the 32-bitindex * stridein modes 2 and 3 I haven't measured.AI-assisted (Claude Code, Claude Opus 5.5).