GPU, shaders: shaders mark the pages they write by address; landings look there only #229
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/229"
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 DexNom/VIctory. Originally posted by murillojndem on 2026-11-29T17:10:37Z.
When a shader writes title memory by address and the host cannot bound where (
Writes::Allindraw.rs), every visible host copy is declared written: snapshotted at submission and compared after it. In a run on an RX 7900 XT with the ray-tracing builder running (one such writer is InitHeaders), the log shows:relay_wait), and that landing was 1.0 to 2.0 s a frame of compares.Upstream's
27c3dc9had shaders mark the 64 KiB pages they write in a bitmap per list, and looked only at those pages after the run. This repository's570a941removed that bitmap; the directory design that replaced it declares every copy instead.Change, in two halves:
emit): withwith_write_marks, every raw-address store and atomic (memory_flat) that runs on a page with a copy sets, in a new root UAVu251(SLOT_MARKS), the bits of the directory pages of its first and last byte. Lanes EXEC leaves out and pages without a copy set none. Without the option a translation is byte for byte as before.VICTORY_WRITE_MARKS=0(part of the cache key).u251(HostList::marks). A list that cannot get one binds a sink, and its submission looks through every range whole.Writes::Alldeclares are flagged. Pending state and snapshots are as before.VICTORY_MARKS_VERIFY=1looks through everything as before and counts the pieces that differ in parts no shader marked; there should be none.Why it is exact: a marking shader cannot write a byte of a page with a copy without marking that page, since both ends of every store are marked. Atomics mark too, and writes to pages without a copy are dropped by the shader. A range left out is therefore one that no marking shader of those submissions wrote. Other writers' ranges are declared plainly and looked through whole, except where the host guesses that a shader does not write (see Limits).
Relation to #153: same symptom (InitHeaders is one
Writes::Allwriter), different mechanism. Nothing is replayed after the copy-back, and the declarations and the order of the landing are unchanged.Tests:
emit::intersect_tests::warp_write_marks_name_the_pages_raw_stores_and_atomics_writecovers:It fails under each of four mutants: marking only the first byte, ignoring whether the page has a copy, not marking atomics, and marking outside EXEC. Without the option, the DXIL of stores, an atomic and a load is byte for byte the same as on main.
host::relay_tests::declared_ranges_for_marking_shaders_are_looked_through_at_marked_pageswrites two pages of a copy and the bitmap with copies on the card, as a shader would. It checks three things, on the waited path and with the relay:host::marked_compare_tests(cutting ranges to pages, the directory's last page, plain ranges never left out) andhost::raw_copy_coverage_tests(a shader that does not mark, after marked declarations of the same copies, still gets a plain declaration).victory-gpu --lib: 224 passed, 0 failed, 4 ignored on WARP, with and withoutVICTORY_RELAY=1, and on the RX 7900 XT (main: 219, 0, 4).victory-shader --libon WARP: 235 passed, 5 failed, 4 ignored (main: 234, 5, 4; the same five fail). Clippy with-D warnings, with and without--all-features, andcargo xtask policypass. The touched files are not rustfmt-formatted on main (victory-gpu has 1,156 rustfmt differences there), so the new code follows the style around it rather than rustfmt.Limits:
VICTORY_WRITE_MARKS=0against the default gives the A/B;VICTORY_MARKS_VERIFY=1checks that nothing is left out that a shader wrote.Writes::Allused to look through, by chance, writes the host does not declare (thewrite_skipguesses indraw.rs) when they fell in a declared copy. Those are no longer looked for unless their pages are marked;VICTORY_MARKS_VERIFY=1counts them.VICTORY_WRITE_MARKS=0avoids it.memory.rs(both change howreadydeclares), with #149 inshader_cache.rs(both add to the translation's cache key) and with #153 inemit/mod.rs(both add translation options next to the raw-store probe). Of the other open PRs that touch these files, those that do not merge already conflict with main.Generated with Claude Code
Imported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-30T22:10:37Z.
Pushed
65cb797d.VICTORY_MARKS_VERIFY=1now says how much it checked.Before, the verify branch of
marked_compareadded nothing to the counters the frame-rate line prints, and that line was printed only when a count was not zero. A run whose check found no difference therefore printed nothing, which cannot be told from a run where no submission had a range for marking shaders. A run of this branch on an RX 7900 XT with the switch on had exactly that.With the switch on, the frame-rate line now gives, for the frames since the last line and zeros included, the submissions checked, the MB of unmarked declared ranges looked through, and the pieces that differed there. These are counts, not per-frame rates (one piece a second would read 0.0 a frame). They are exact with
VICTORY_RELAY=0; with the relay, a flight still in the air can add or hide a piece, which the line and the doc ofmarks_verifynow state.The test turns the check on for its own landing through a thread key that exists only in tests, and asserts the whole look-through and the three counts. With the new counters taken out it fails at "the checked submission is counted"; with the key ignored it fails at "checked, the page nothing marked is looked through too". It now also fails, instead of returning, when no D3D12 device opens.
Checks:
victory-gpulibrary tests on the RX 7900 XT: 224 passed, 0 failed, 4 ignored. This was the tree before the last review fixes, which changed only the log line's format, a doc comment and anexpectmessage; no test reads those.--features diagnostics: 244 passed, 0 failed, 4 ignored.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, with and without--all-features: clean.Imported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-30T22:50:34Z.
The pushed tree (
65cb797d) on the RX 7900 XT as well:victory-gpulibrary tests 224 passed, 0 failed, 4 ignored.Imported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-30T23:10:10Z.
A coverage check of this change in a game run on an RX 7900 XT: a diagnostics build of main
4ad86927with this branch and #228 merged, ray tracing on,VICTORY_MARKS_VERIFY=1andVICTORY_RELAY=0(so the counts are exact).Over about 5.5 minutes of play from the start of the story, 96 submissions were checked. 342,566 MB of declared ranges in pages no shader marked were looked through whole, 1,380 to 4,512 MB per submission. 0 pieces differed there, and the "pages they did not mark" warning never appeared. In that stretch, every write the check could see landed in a marked page.
That is one stretch of one title, not every scene, and the run was not a frame-rate measurement (verification on and the relay off make frames slower by design).
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.