Shaders: a program that stores reads title memory through the UAVs it writes; glc accesses are coherent #3584
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3584"
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 lhnizdo on 2026-11-27T19:07:11Z.
What
Title memory was read through each page's raw SRV and written through its UAV. A read through the SRV doesn't have to see this dispatch's writes. On an RTX 2080, a load after the program's own store to the same address returned the value from before the dispatch. On the console, a program reads the same memory it writes, and a
glcaccess passes the compute unit's cache, so it sees what this wave and other groups stored.Lower::writes_memory) also reads title memory through the page's UAV. Read-only programs still read through the SRV.glcaccess (SMEM, MUBUF or FLAT) gets a globally coherent handle.lower.rsgrows by 1,114 bytes, to 521,677.Where it showed
GTA VI's console BVH builder (
XboxBvhBuilder.dll), on an RTX 2080. Its treelet-optimization pass,ffd93c8a, works like this:glc.The boxes came back as they were before the dispatch, mostly zero. So treelet formation stopped after its first step, and nodes rewired by other groups were also read stale. The trees came out broken: in one 23,011-leaf tree, about 2,300 children no longer pointed back to their parents and 150 nodes formed cycles. The refit after it then never reached the root, and the device was removed.
Measured
A captured dispatch of
ffd93c8a, with the exact inputs the game gave it, replayed on the 2080. The input tree is valid every time.glc)A lockstep wave32 reference interpreter of the program (a CPU model of the console's wave) agrees: with one group, the GPU's output is byte-identical to the interpreter's with this change, and differs without it.
Other things I ruled out on the same capture first. With SRV reads kept, none of these helped:
In the game (RTX 2080, Windows 10, my dump, on my stack with #2920): the BVH builder now runs with
ffd93c8ain and the refit on, with no caps and no builder program dropped. It ran for 6 minutes without a device loss: all 53 builder programs run, about 5,200 draws a frame, 23,002 instances and 57,253 BVH nodes at the stop. Before this change the device was lost in the builder's first frame unlessffd93c8awas dropped. The scene's remaining artefacts (a green cast, blocky patches at the bottom) were there withffd93c8adropped too.Test
memory_tests::a_program_reads_back_what_it_stored_to_title_memory:glc, and store what they read.7, 4103, …instead of8, 4104, …). With it, all of them read their own store.Whole
victory-shader --lib --features hostsuite: 299 passed, 4 failed, the same 4 asmainon this card.cargo clippy -p victory-shader --all-targets --all-features -- -D warningsis clean.AI-assisted (Claude Code). Synthetic tests only, no game data in the tree.
🤖 Generated with Claude Code
https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-27T19:31:30Z.
Matched Wine/NVIDIA verification: the synthetic store/readback fixture passes on both production head
0c1e615ee5and parent63bcca43c6. This does not reproduce the reported native-Windows RTX 2080 stale-read result on this stack.Linux 6.17, i7-13620H/16 GiB, RTX 4060 Laptop 8 GiB/NVIDIA 590.48.1, Wine 11.0, diagnostic-relaxed-vtable vkd3d-proton 2576c0b4adfae4a+ (not stock certification), DXVK NVIDIA masking disabled. Both worktrees carry the identical test-only strengthened fixture; production unchanged. SDK DXIL validator, non-software physical NVIDIA adapter and dedicated VRAM are mandatory, without WARP fallback or silent skips.
Command on each source: cargo-victory-wine.sh test -p victory-shader --features host --lib a_program_reads_back_what_it_stored_to_title_memory -- --nocapture --test-threads=1. Fresh intended-worktree Compiling lines: parent 5.93 s, head 5.81 s. Parent 1/1 pass in 0.77 s; head 1/1 pass in 0.76 s; zero ignored. Each executes the owner's original 64-thread, one-group instruction sequence and compares every word of both returned UAVs: 512 memory words and 256 write-mark words, 768 total, zero mismatches including untouched sentinels.
Local evidence directories under .compat-runtime/logs/:
Each retains console.log, result.json, command and resource samples. Sampled GPU peak <=164 MiB, available RAM >=11230 MiB, disk >=12.144 GiB; unchanged safety limits.
This single-group fixture does not establish cross-group glc ordering, the captured treelet program's integrity, or gameplay. No original BVH dispatched or title launched. A small publishable, non-spinning multi-wave/tree-integrity regression that distinguishes this parent on Wine would be the most useful next gate; retaining the same source-container identity and translation mode would help compare it with our local title corpus. The independent scalar/lane-loop backend promotion block remains separate.
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T19:37:35Z.
Hardware run, head
0c1e615: Windows 11, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1.a_program_reads_back_what_it_stored_to_title_memory: passes, 0/5 failures over 5 runs.cargo test -p victory-shaderon the 780M: 303 passed, 0 failed.AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T19:58:35Z.
Before/after on the same 780M: with this PR's test file on main
63bcca4,a_program_reads_back_what_it_stored_to_title_memoryfails on hardware: every dword read back is one less than stored ([7, 4103, 8199, ...], want[8, 4104, 8200, ...]); with the PR it passes (0/5 failures above).AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by JurajSimicevic on 2026-11-27T20:37:58Z.
Native Windows, RTX 5080 (Blackwell, driver 617.42): the test fails without the change and passes with it, also on a large stack.
a_program_reads_back_what_it_stored_to_title_memorywithout this PR'slower.rschange reads back[7, 4103, 8199, …]instead of[8, 4104, 8200, …]. That is the same failure as on the RTX 2080 and the 780M. With0c1e615it passes.63bcca4+ #2098, #2626, #2464, #2118, #439, #2121, #2958, #3312, then this PR.lower.rsmerges cleanly. The new test only needs thePartsfields the other PRs add (target,console_cf,per_lane_only).victory-shader --lib --features host, run serially on the 5080: the same two tests fail with and without this PR (a_heap_buffer_read_by_element_takes_the_views_strideandgathers_at_a_level_match_the_hardware). One more test,heap_direct_texture_reads_mark_their_heap_index, crashes the run on this tree either way, so I left it out of both runs.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by lhnizdo on 2026-11-28T21:52:28Z.
Thanks @kilolimaVI, @JurajSimicevic and @pickles976 for the runs.
With these,
a_program_reads_back_what_it_stored_to_title_memorynow fails without the change and passes with it on three architectures:Each fails the same way, every dword reading back one less than stored. The Wine/vkd3d-proton setup doesn't show the stale read even on
main, which I take as that stack resolving the SRV/UAV aliasing differently, not as a counter-example.AI-assisted (Claude Code).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.