shader/dxil: mark the title-memory page-directory load as a pure read #169

Open
github-bot wants to merge 1 commit from github-bot/gh-168 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 20:50 UTC · original
SovietBearz0r:pure-page-dir-loads → main · +123 −19 · 6 files · 1 commits · open

xmem #167: the title-memory page-directory (SLOT_MEMORY) entry load is host-owned memory that no shader store can alias, so it should be marked as a pure read and reused across stores, barriers and loops.

What

  • victory-dxil/src/bitcode.rs: widened pure_reads doc + mark_pure(); opt.rs already treats pure_reads call instructions as Effect::Pure.
  • victory-shader/src/emit/lower/memory.rs: mark_pure(entry) on the SLOT_MEMORY directory entry load; a test asserts the lowering marks it.
  • TRANSLATOR_VERSION 20 -> 21 (the marking changes default translations; one-time cache invalidation).

Not covered by default passes: main's pure_reads only gets constant-buffer raw reads, and the existing DOM_LOADS reuse is opt-in (DEFAULT = ALL & !(WIDE | DOM_LOADS)). Verified empirically: with the marking removed, the intersect test program reports pure_reads == 0.

Verification

  • cargo test -p victory-dxil --lib: 22 passed; cargo test -p victory-shader --lib: 324 passed, 2 ignored; clippy for victory-dxil/victory-shader clean; cargo check -p victory; policy 442 files.
  • Needs in-game: victory shaders should report the changed translations once; rendering unchanged except fewer directory loads.
  • Risk: safety rests on the directory being a host-owned root SRV no shader store can alias; only effect is fewer loads. Note this branch and #162 (pure-reads-slots) both bump TRANSLATOR_VERSION 20->21 from the same base — merging both needs the second bump to 22 and a trivial conflict in lower/mod.rs/lib.rs.
**@⁠SovietBearz0r** on GitHub · 2026-12-05 20:50 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/168) `SovietBearz0r:pure-page-dir-loads` → `main` · +123 −19 · 6 files · 1 commits · open xmem #167: the title-memory page-directory (`SLOT_MEMORY`) entry load is host-owned memory that no shader store can alias, so it should be marked as a pure read and reused across stores, barriers and loops. ## What - `victory-dxil/src/bitcode.rs`: widened `pure_reads` doc + `mark_pure()`; opt.rs already treats `pure_reads` call instructions as `Effect::Pure`. - `victory-shader/src/emit/lower/memory.rs`: `mark_pure(entry)` on the `SLOT_MEMORY` directory entry load; a test asserts the lowering marks it. - `TRANSLATOR_VERSION` 20 -> 21 (the marking changes default translations; one-time cache invalidation). **Not covered by default passes**: main's `pure_reads` only gets constant-buffer raw reads, and the existing `DOM_LOADS` reuse is opt-in (`DEFAULT = ALL & !(WIDE | DOM_LOADS)`). Verified empirically: with the marking removed, the intersect test program reports `pure_reads == 0`. ## Verification - `cargo test -p victory-dxil --lib`: **22 passed**; `cargo test -p victory-shader --lib`: **324 passed, 2 ignored**; clippy for `victory-dxil`/`victory-shader` clean; `cargo check -p victory`; policy 442 files. - **Needs in-game**: `victory shaders` should report the changed translations once; rendering unchanged except fewer directory loads. - Risk: safety rests on the directory being a host-owned root SRV no shader store can alias; only effect is fewer loads. Note this branch and #162 (`pure-reads-slots`) both bump `TRANSLATOR_VERSION` 20->21 from the same base — merging both needs the second bump to 22 and a trivial conflict in `lower/mod.rs`/`lib.rs`.
Lower::memory_lookup reads the host's directory of title-memory copies
(SLOT_MEMORY) through rawBufferLoad with Attr::ReadOnly, so the optimiser
treats the read as depending on memory: the fault note record_memory_fault
stores a page into a per-lane slot between one lookup and the next, and that
store parts the reads. On the console the directory is host memory that no
store a shader makes can reach; the host's copy on the card changes only by
copies ahead of a submission, so an entry reads the same all through a
dispatch. The loads are marked in Module::pure_reads (mark_pure) and reused
across stores, barriers and loops.

The marking is default-on: it changes the translation of programs that touch
title memory by address, so TRANSLATOR_VERSION goes 20 -> 21 and the shader
cache invalidates once (victory shaders says whether the bump was due).
Adapted from lobomfz/VIctory-xmem #166, via the closed xmem-windows-ports
branch (its tip adapted #166, #202 and others to Windows).

Tests: opt_tests marks a read pure and asserts one lookup serves the next
past a store on a branch (a_read_marked_pure_is_reused_past_a_store_on_a_branch);
intersect_tests asserts the lowering marks the directory entry for both BVH
forms (the_memory_directory_entry_is_a_pure_read), which fails without it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 20:53:20 +00:00
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 21:48 UTC · original

In-game pass done (RX 9070 XT 16 GB, diag build, builtin:cruise): clean run, 0 errors / 0 device-removed / 0 bench errors, shaders from the cache … hits=3886 misses=0 after the first-use cache build (the TRANSLATOR_VERSION bump translated during loading on this lap; no translation during the measured spots), frame pacing normal (cruise 37.4/40.4 fps in that lap). The new pure-read tests also pass in the full CI runs (Default 1895 / Diagnostics 1906). Log: data\ingame-verify\logs\pureloads.log.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 21:48 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/168#issuecomment-7446016359) In-game pass done (RX 9070 XT 16 GB, diag build, builtin:cruise): clean run, **0 errors / 0 device-removed / 0 bench errors**, `shaders from the cache … hits=3886 misses=0` after the first-use cache build (the `TRANSLATOR_VERSION` bump translated during loading on this lap; no translation during the measured spots), frame pacing normal (cruise 37.4/40.4 fps in that lap). The new pure-read tests also pass in the full CI runs (Default 1895 / Diagnostics 1906). Log: `data\ingame-verify\logs\pureloads.log`.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/169/head:github-bot/gh-168'
git switch 'github-bot/gh-168'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-168'
git switch 'github-bot/gh-168'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-168'
git switch 'github-bot/gh-168'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-168'
git switch 'main'
git merge --squash 'github-bot/gh-168'
git switch 'main'
git merge --ff-only 'github-bot/gh-168'
git switch 'main'
git merge 'github-bot/gh-168'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.