GPU: once the BVH builder runs, its title-memory accesses miss host copies every frame, and 5552dac6a2b7a1fd writes 4 GiB above real buffers #3486

Open
opened 2026-11-27 08:04:42 +00:00 by ZeOs360 · 9 comments
ZeOs360 commented 2026-11-27 08:04:42 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by ZeOs360 on 2026-11-27T08:04:42Z.


A standalone issue, as suggested on #2118 for 5552dac6 problems. Not a blocker for #2118 itself.

Setup: RX 7800 XT, 16 GB RAM. main 63bcca4 with #2118 at 999a8f6, #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:

  • Most missed writes come from 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.
  • Others land about 4 GiB above a buffer in use (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.
  • Missing copies alone don't explain all of them: in another run, some +4 GiB writes from 5552dac6 came in frames where nothing else missed. Their cause is still open.

Two dead ends, to save others time:

  • Marking glc/dlc UAV accesses globally coherent and lowering s_waitcnt_vscnt / buffer_gl*_inv to UAV fences passes a synthetic cross-workgroup test, but changes none of the above in game.
  • Making copies of missed memory on demand lifts the withholding, but then the +4 GiB writes land on live title data and the title soon reads -1 (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 from 5552dac6 still need their own fix. Whether they relate to the 5552dac6 device 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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6642476302 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486). Originally posted by [ZeOs360](https://github.com/ZeOs360) on 2026-11-27T08:04:42Z. --- A standalone issue, as suggested on #2118 for `5552dac6` problems. Not a blocker for #2118 itself. **Setup:** RX 7800 XT, 16 GB RAM. `main` `63bcca4` with #2118 at `999a8f6`, #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:** - Most missed writes come from `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. - Others land about 4 GiB above a buffer in use (`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. - Missing copies alone don't explain all of them: in another run, some +4 GiB writes from `5552dac6` came in frames where nothing else missed. Their cause is still open. **Two dead ends, to save others time:** - Marking glc/dlc UAV accesses globally coherent and lowering `s_waitcnt_vscnt` / `buffer_gl*_inv` to UAV fences passes a synthetic cross-workgroup test, but changes none of the above in game. - Making copies of missed memory on demand lifts the withholding, but then the +4 GiB writes land on live title data and the title soon reads -1 (`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 from `5552dac6` still need their own fix. Whether they relate to the `5552dac6` device 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.
Ingenioeren commented 2026-11-27 09:41:28 +00:00 (Migrated from github.com)
Author
Contributor

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 63bcca4 placed different sentinels in separate buffers at 0x12_3450_0000 and 0x13_3450_0000, exactly 4 GiB apart. The RX 6750 XT and Windows WARP agreed in both runs.

Upper page Lower address read Upper address read
Mapped to its own buffer 0x11111111 0x44444444
Unmapped 0x11111111 Zero, with the upper region marked as missed

Both 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7214979119 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7214979119). Originally posted by [Ingenioeren](https://github.com/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 `63bcca4` placed different sentinels in separate buffers at `0x12_3450_0000` and `0x13_3450_0000`, exactly 4 GiB apart. The RX 6750 XT and Windows WARP agreed in both runs. | Upper page | Lower address read | Upper address read | | --- | --- | --- | | Mapped to its own buffer | `0x11111111` | `0x44444444` | | Unmapped | `0x11111111` | Zero, with the upper region marked as missed | Both 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](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-shader/src/emit/memory_tests.rs#L220-L322) · [Region index calculation](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-shader/src/emit/lower.rs#L4738-L4760) AI-assisted synthetic verification with OpenAI Codex.
ZeOs360 commented 2026-11-27 16:10:42 +00:00 (Migrated from github.com)
Author
Contributor

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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7222949230 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7222949230). Originally posted by [ZeOs360](https://github.com/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).
Slay326 commented 2026-11-27 16:42:06 +00:00 (Migrated from github.com)
Author
Contributor

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, caa78b8ca62bc3d6 and 28918b7150a7aad5, are the only DispatchX callers we see whose flags lack bit 0x8000 (flags 0x20; the two other callers, 4ddd6f97 and 5062bc7a, use 0x8020). For those two, x behaves like a thread count, not a group count (x ranged 1..1038 and 1..11632 in a 120 s run). Launching x groups of 64 lanes lets the surplus lanes run and write.

What we measured in the harness on the same capture:

  • Without a limit, lanes at or above x wrote 2961 bytes outside the expected range between two consecutive builder dispatches, and the root node of a rehydrated bottom level ended up as ffffffff x4.
  • With lanes >= x masked 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.
  • Same counts on the 3070 and the 4070.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7223569372 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7223569372). Originally posted by [Slay326](https://github.com/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, `caa78b8ca62bc3d6` and `28918b7150a7aad5`, are the only `DispatchX` callers we see whose flags lack bit `0x8000` (flags `0x20`; the two other callers, `4ddd6f97` and `5062bc7a`, use `0x8020`). For those two, `x` behaves like a **thread count**, not a group count (x ranged 1..1038 and 1..11632 in a 120 s run). Launching `x` groups of 64 lanes lets the surplus lanes run and write. What we measured in the harness on the same capture: - Without a limit, lanes at or above `x` wrote 2961 bytes outside the expected range between two consecutive builder dispatches, and the root node of a rehydrated bottom level ended up as `ffffffff` x4. - With lanes `>= x` masked 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. - Same counts on the 3070 and the 4070. 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.
ZeOs360 commented 2026-11-28 01:55:49 +00:00 (Migrated from github.com)
Author
Contributor

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, childrenList and parentInfoTable.

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 5552dac6 writes to after each list: 850 of 855 were sane. The other 5 came from one later list and were junk. For the parentInfoTable stores, the offsetToElements the shader used matches the final header exactly.

  • parentList and childrenList hold wrong values. Examples:

    • parentList entries one node below the element area, with type 7 (0x12b4f, 0x1285f);
    • small parentList values (0x347, 0x400, 0x7ff, 0x800, 0x7fff);
    • a negative parentList value (0xffff10b6);
    • small positive childrenList values (0x1f, 0x904, 0xd6b) where the reused-node path negates the entry.

    In the first list I checked, in which 5552dac6 builds 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 parentInfoTable stores are idxen (stride 4) through a descriptor whose dword 3 is 0x11014fac, which is OOB_SELECT 1: only the index is checked. With num_records = 0xFFFFFFFF, the console drops a store at index 0xFFFFFFFF. The translation has no range check for root views (lower.rs:9464-9476 on main), so that store lands at base + 4 GiB - 4. A local experiment drops those lanes. These index 0xFFFFFFFF stores 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):

  • #3584 applied on top (storing programs read through the UAV, glc coherent).
  • ffd93c8a dropped, with the rest of the builder still running.
  • Host copies of the builder's root ranges made before its first dispatch: apart from the stray writes themselves, nothing in that first list missed.
  • Pipeline-sync calls as UAV barriers: the builder's lists make none, and no UAV barrier was dropped.
  • @Slay326's DispatchX point: this stack has #2841, which treats flag 0x20 as 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 5552dac6 into 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7232012091 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7232012091). Originally posted by [ZeOs360](https://github.com/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`, `childrenList` and `parentInfoTable`. **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 `5552dac6` writes to after each list: 850 of 855 were sane. The other 5 came from one later list and were junk. For the `parentInfoTable` stores, the `offsetToElements` the shader used matches the final header exactly. - **`parentList` and `childrenList` hold wrong values.** Examples: - `parentList` entries one node below the element area, with type 7 (`0x12b4f`, `0x1285f`); - small `parentList` values (`0x347`, `0x400`, `0x7ff`, `0x800`, `0x7fff`); - a negative `parentList` value (`0xffff10b6`); - small positive `childrenList` values (`0x1f`, `0x904`, `0xd6b`) where the reused-node path negates the entry. In the first list I checked, in which `5552dac6` builds 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 `parentInfoTable` stores are `idxen` (stride 4) through a descriptor whose dword 3 is `0x11014fac`, which is OOB_SELECT 1: only the index is checked. With `num_records` = `0xFFFFFFFF`, the console drops a store at index `0xFFFFFFFF`. The translation has no range check for root views ([`lower.rs:9464-9476`](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-shader/src/emit/lower.rs#L9464-L9476) on `main`), so that store lands at `base + 4 GiB - 4`. A local experiment drops those lanes. These index `0xFFFFFFFF` stores 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):** - #3584 applied on top (storing programs read through the UAV, `glc` coherent). - `ffd93c8a` dropped, with the rest of the builder still running. - Host copies of the builder's root ranges made before its first dispatch: apart from the stray writes themselves, nothing in that first list missed. - Pipeline-sync calls as UAV barriers: the builder's lists make none, and no UAV barrier was dropped. - @Slay326's `DispatchX` point: this stack has #2841, which treats flag `0x20` as 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 `5552dac6` into 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.
Machad3x commented 2026-11-28 03:35:45 +00:00 (Migrated from github.com)
Author
Contributor

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7233201922 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7233201922). Originally posted by [Machad3x](https://github.com/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.
upipibi commented 2026-11-28 03:57:52 +00:00 (Migrated from github.com)
Author
Contributor

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's ResultDataMaxSizeInBytes for 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 main 63bcca4 and another tree's commit; a hypothesis, not measured on hardware). For an idxen root-view access, main forms index * stride as 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-recomp b9b57e21 (same title, its own translator) reasons that the hardware adds index * stride to 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's docs/buffer_bounds.md table only goes up to index 4.

That matters for reading your 348 sites. Splitting them into idxen and offen would show how many come from the 32-bit product rather than from an offset the shader computes. If most are idxen with 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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7233552992 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7233552992). Originally posted by [upipibi](https://github.com/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's `ResultDataMaxSizeInBytes` for 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 `main` `63bcca4` and another tree's commit; a hypothesis, not measured on hardware). For an `idxen` root-view access, `main` forms `index * stride` as 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-recomp `b9b57e21` (same title, its own translator) reasons that the hardware adds `index * stride` to 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's `docs/buffer_bounds.md` table only goes up to index 4. That matters for reading your 348 sites. Splitting them into `idxen` and `offen` would show how many come from the 32-bit product rather than from an offset the shader computes. If most are `idxen` with 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).
lhnizdo commented 2026-11-28 07:23:43 +00:00 (Migrated from github.com)
Author
Contributor

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:

  • the waterfall loops of 28918b71/caa78b8c never ended (#2920);
  • ffd93c8a read 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 ffd93c8a didn't help: on your side another pass writes the lists wrongly.

The method that worked, after DRED and barrier breadcrumbs had misled me twice:

  1. Our own breadcrumbs. After every builder dispatch, a WriteBufferImmediate marker goes into system memory and is read back after the loss. That says exactly which dispatch didn't finish.
  2. Capture and stop. This captures one dispatch's inputs (every view and root constant, including title addresses held in constants) and stops the frame's builder before that dispatch runs. The capture is then exactly what the dispatch sees.
  3. A tree check on the captured parents/children: self-parents, nodes that don't reach the root, children that don't point back, nodes listed twice or never. Run it on the inputs of each pass in order. The first pass whose input is fine and whose output is broken is the culprit. For me that was ffd93c8a: a perfect 23,011-leaf tree in, about 2,300 bad links out, every time.
  4. Replay alone. A test replays the captured dispatch on the hardware with its exact inputs, about 30 s a try with no game run. You can cut the group count (1, 2, 4… groups) until the smallest case that breaks.
  5. A reference. For the culprit I wrote a small lockstep wave32 interpreter of the program (CPU, over its disassembly). Its output for one group, compared with the GPU's through a translation probe (each lane logs what chosen instructions read), pointed at the first wrong value.

The code: steps 1, 2 and 4 (plus the probe) are diagnostics on lhnizdo:diag/bvh-builder (0a4d0c7). They're switches named VICTORY_BUILDER_*, VICTORY_REPLAY_* and VICTORY_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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7235910742 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7235910742). Originally posted by [lhnizdo](https://github.com/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: - the waterfall loops of `28918b71`/`caa78b8c` never ended (#2920); - `ffd93c8a` read 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 `ffd93c8a` didn't help: on your side another pass writes the lists wrongly. **The method that worked**, after DRED and barrier breadcrumbs had misled me twice: 1. **Our own breadcrumbs.** After every builder dispatch, a `WriteBufferImmediate` marker goes into system memory and is read back after the loss. That says exactly which dispatch didn't finish. 2. **Capture and stop.** This captures one dispatch's inputs (every view and root constant, including title addresses held in constants) and stops the frame's builder before that dispatch runs. The capture is then exactly what the dispatch sees. 3. **A tree check** on the captured parents/children: self-parents, nodes that don't reach the root, children that don't point back, nodes listed twice or never. Run it on the inputs of each pass in order. The first pass whose input is fine and whose output is broken is the culprit. For me that was `ffd93c8a`: a perfect 23,011-leaf tree in, about 2,300 bad links out, every time. 4. **Replay alone.** A test replays the captured dispatch on the hardware with its exact inputs, about 30 s a try with no game run. You can cut the group count (1, 2, 4… groups) until the smallest case that breaks. 5. **A reference.** For the culprit I wrote a small lockstep wave32 interpreter of the program (CPU, over its disassembly). Its output for one group, compared with the GPU's through a translation probe (each lane logs what chosen instructions read), pointed at the first wrong value. **The code:** steps 1, 2 and 4 (plus the probe) are diagnostics on [`lhnizdo:diag/bvh-builder`](https://github.com/lhnizdo/VIctory/tree/diag/bvh-builder) (`0a4d0c7`). They're switches named `VICTORY_BUILDER_*`, `VICTORY_REPLAY_*` and `VICTORY_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.
ZeOs360 commented 2026-11-28 12:09:49 +00:00 (Migrated from github.com)
Author
Contributor

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:

  1. The LBVH radix sort is already wrong in its first round, in all three LBVH trees of the builder's
    first list. After the scatter (e63d22c4) the keys are no longer a permutation of its input.
  2. Its inputs show why:
    • the per-block histogram matches a CPU count exactly;
    • the 256-digit scan is exact for digits 0..127;
    • digits 128..255 are off by exactly the total of digits 0..127.
  3. The scatter itself is right given that scan: in the tree checked, every single-writer position
    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.
  4. The scan is f6eb6498409ca974 (wave64, 64 threads, 4 digits per lane). It adds lane 31's sum to
    lanes 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]. On main a mask whose dwords two instructions write is kept
    as its low dword only (Atom::Opaque(lo), pair_high finds no high dword), so lanes 32..63
    tested s6 = 0. That is #2780; the masks before it in the same scan (0xaaaaaaaa, …, 0xffff0000)
    have equal dwords and were right by chance.
  5. From there:
    • f28a33a8 builds broken trees from the unsorted keys;
    • 5552dac6a2b7a1fd reads parent and child indices that don't fit the tree;
    • its 32-bit offsets wrap: the +4 GiB writes.

10-minute runs, wrapped-offset sites of 5552dac6a2b7a1fd:

tree sites first one after the builder starts
RT stack, 2 runs 54, 44 21 s, 21 s
RT stack + a global UAV barrier before every builder dispatch 63 19 s
RT stack + #3023 (which carries #2836's change) 70, all in frames 2017-2031 3 min 52 s
RT stack + #3023 + a select change that alters no game shader, 2 runs 0, 0 none
RT stack + our own version of #2836's change (without #3023's branch commits), snapshots on 0 none

Notes on those runs:

  • The select change made no difference to any game shader in a check over all containers, so those
    two runs translate the game as #3023 does.
  • One of them ended at 5 minutes at the known +0x23cf683 fault, after frame 2035, past the burst
    window.
  • In the snapshot run, the sort's keys stay a permutation in every round and come out sorted.

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:

  • The barrier run rules out a race between builder passes for the first-frame writes.
  • I posted the in-game numbers on #3023, with one latent gap there (the v_cndmask_b32 lookup by
    low dword; no game shader hits it).
  • The index -1 stores (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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7239036544 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7239036544). Originally posted by [ZeOs360](https://github.com/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: 1. The LBVH radix sort is already wrong in its first round, in all three LBVH trees of the builder's first list. After the scatter (`e63d22c4`) the keys are no longer a permutation of its input. 2. Its inputs show why: - the per-block histogram matches a CPU count exactly; - the 256-digit scan is exact for digits 0..127; - digits 128..255 are off by exactly the total of digits 0..127. 3. The scatter itself is right given that scan: in the tree checked, every single-writer position 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. 4. The scan is `f6eb6498409ca974` (wave64, 64 threads, 4 digits per lane). It adds lane 31's sum to lanes 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]`. On `main` a mask whose dwords two instructions write is kept as its low dword only (`Atom::Opaque(lo)`, `pair_high` finds no high dword), so lanes 32..63 tested s6 = 0. That is #2780; the masks before it in the same scan (0xaaaaaaaa, …, 0xffff0000) have equal dwords and were right by chance. 5. From there: - `f28a33a8` builds broken trees from the unsorted keys; - `5552dac6a2b7a1fd` reads parent and child indices that don't fit the tree; - its 32-bit offsets wrap: the +4 GiB writes. 10-minute runs, wrapped-offset sites of `5552dac6a2b7a1fd`: | tree | sites | first one after the builder starts | |---|---|---| | RT stack, 2 runs | 54, 44 | 21 s, 21 s | | RT stack + a global UAV barrier before every builder dispatch | 63 | 19 s | | RT stack + #3023 (which carries #2836's change) | 70, all in frames 2017-2031 | 3 min 52 s | | RT stack + #3023 + a select change that alters no game shader, 2 runs | 0, 0 | none | | RT stack + our own version of #2836's change (without #3023's branch commits), snapshots on | 0 | none | Notes on those runs: - The select change made no difference to any game shader in a check over all containers, so those two runs translate the game as #3023 does. - One of them ended at 5 minutes at the known `+0x23cf683` fault, after frame 2035, past the burst window. - In the snapshot run, the sort's keys stay a permutation in every round and come out sorted. 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: - The barrier run rules out a race between builder passes for the first-frame writes. - I posted the in-game numbers on #3023, with one latent gap there (the `v_cndmask_b32` lookup by low dword; no game shader hits it). - The index -1 stores (`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.
ZeOs360 commented 2026-11-28 12:15:57 +00:00 (Migrated from github.com)
Author
Contributor

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 idxen sites 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-bit index * stride in modes 2 and 3 I haven't measured.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7239107445 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7239107445). Originally posted by [ZeOs360](https://github.com/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 `idxen` sites 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-bit `index * stride` in modes 2 and 3 I haven't measured. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory#3486
No description provided.