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:06:11 +00:00 by github-bot · 3 comments
Owner

@⁠ZeOs360 on GitHub · 2026-11-27 08:04 UTC · original

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.

**@⁠ZeOs360** on GitHub · 2026-11-27 08:04 UTC · [original](https://github.com/Marvisak/VIctory/issues/3486) 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 08:06:17 +00:00
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-27 09:41 UTC · original

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.

**@⁠Ingenioeren** on GitHub · 2026-11-27 09:41 UTC · [original](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7214979119) 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.
Author
Owner

@⁠ZeOs360 on GitHub · 2026-11-27 16:10 UTC · original

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

**@⁠ZeOs360** on GitHub · 2026-11-27 16:10 UTC · [original](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7222949230) 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).
Author
Owner

@⁠Slay326 on GitHub · 2026-11-27 16:42 UTC · original

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.

**@⁠Slay326** on GitHub · 2026-11-27 16:42 UTC · [original](https://github.com/Marvisak/VIctory/issues/3486#issuecomment-7223569372) 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.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#3486
No description provided.