Shaders: coherent UAV views and device fences for programs that order memory across groups #913
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/914"
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 fxceless/victory-fork. Originally posted by SpaghettiMaster545 on 2026-11-25T12:40:36Z.
What was wrong
The console keeps memory coherent between the groups of a dispatch where a program asks for it: cache-control bits (GLC, DLC, SLC) on a memory or scalar access, a memory atomic, or a cache invalidation. The translation gave every program plain UAVs and no fences, so on the host a group could read a stale copy of what another group of the same dispatch had written, and a thread's stores were not ordered for other groups before the atomic that announced them.
How it shows in game
The title's BVH builder (
XboxBvhBuilder.dll) does exactly this: atomics, then reads of what other groups wrote. With plain views it can read stale nodes. On the AMD Radeon iGPU we saw loads go through a read-only view of the written buffer, which a program gets when the metadata names no UAV.What the change does
wants_coherent) has every UAV globally coherent: resource properties bit 14 on heap handles and root UAVs, and the coherent flag in the root UAVs' metadata.s_waitcnt_vscnt) or drops its caches (buffer_gl0_inv,buffer_gl1_inv,s_gl1_inv,s_dcache_inv). The host orders a thread's accesses for other groups only at a fence.XboxBvhBuilder.dll: all 52 programs translate, validate and get host pipelines as before, and 14 of them now have coherent views.
How it was tested
coherent_views_follow_cache_bits_atomics_and_invalidations;cargo test --locked -p victory-shader --libpasses on this branch (216 passed, 3 ignored);cargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean. (A workspace-wide clippy fails onmainalready, invictory-gpu, which this change does not touch.)Developed with AI assistance (Claude Code).
Imported from fxceless/victory-fork. Originally posted by SpaghettiMaster545 on 2026-11-25T22:36:01Z.
Follow-up pushed:
93c64fc. The device fence this PR adds ats_waitcnt_vscntnever ran, becauseir.rsdropss_waitcnt_vscnttogether with the scheduling hints (the dropped list atir.rs:1145onmain). The commit keepss_waitcnt_vscntin the IR; the other waits are still dropped. A unit test checks that the wait reaches the lowering.We found it while tracing garbage top-level roots from the title's BVH builder. Its bottom-up build stores a node, waits for the store, then publishes it to other groups with
buffer_atomic_add. Without the fence, another group could see the counter before the node data.Tested on this branch: the new test and
coherent_views_follow_cache_bits_atomics_and_invalidationspass, and clippy reports nothing in the changed files. NVIDIA GeForce RTX 5070 Ti, driver 621.40, Windows 11.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.