shader/emit: mark the SLOT_STRIDES/VIEW_SIZES loads as pure reads #162

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

@⁠SovietBearz0r on GitHub · 2026-12-05 19:10 UTC · original
SovietBearz0r:pure-reads-slots → main · +38 −4 · 4 files · 1 commits · open

The default-on pure_reads fix split out of #122 so that PR can stay purely opt-in, per the review there.

What

The host's per-view tables (SLOT_STRIDES, VIEW_SIZES) are immutable for the whole shader invocation, so stores and barriers cannot invalidate those loads for CSE. Lower::slot_dword now marks the rawBufferLoad of those tables as pure reads:

if let V::Inst(id) = r { self.s.m.pure_reads.insert(id); }

TRANSLATOR_VERSION goes 20 → 21 because this changes default translation and the version is part of the shader-cache key (one-time cache invalidation).

Verification

  • cargo test -p victory-shader --lib: 324 passed, 0 failed, 2 ignored (main 323 + the new the_host_table_loads_are_marked_pure_reads; the test fails with the hunk removed and passes with it).
  • cargo check -p victory; cargo xtask policy 442 files; cargo clippy -p victory-shader --all-targets -- -D warnings.
  • Default-on/safe-by-construction: the tables are written once per invocation; the only reachable change is CSE across stores/barriers that cannot touch them.
  • Split from #122 (which keeps DEFAULT = 63 and an unchanged TRANSLATOR_VERSION; its memory.rs/lib.rs are now byte-identical to main).

Source: MiniVI 20be1548 (via the longroad/InstCombine lineage).

**@⁠SovietBearz0r** on GitHub · 2026-12-05 19:10 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/161) `SovietBearz0r:pure-reads-slots` → `main` · +38 −4 · 4 files · 1 commits · open The default-on `pure_reads` fix split out of #122 so that PR can stay purely opt-in, per the review there. ## What The host's per-view tables (`SLOT_STRIDES`, `VIEW_SIZES`) are immutable for the whole shader invocation, so stores and barriers cannot invalidate those loads for CSE. `Lower::slot_dword` now marks the `rawBufferLoad` of those tables as pure reads: ```rust if let V::Inst(id) = r { self.s.m.pure_reads.insert(id); } ``` `TRANSLATOR_VERSION` goes 20 → 21 because this changes default translation and the version is part of the shader-cache key (one-time cache invalidation). ## Verification - `cargo test -p victory-shader --lib`: **324 passed, 0 failed, 2 ignored** (main 323 + the new `the_host_table_loads_are_marked_pure_reads`; the test fails with the hunk removed and passes with it). - `cargo check -p victory`; `cargo xtask policy` 442 files; `cargo clippy -p victory-shader --all-targets -- -D warnings`. - Default-on/safe-by-construction: the tables are written once per invocation; the only reachable change is CSE across stores/barriers that cannot touch them. - Split from #122 (which keeps `DEFAULT = 63` and an unchanged `TRANSLATOR_VERSION`; its `memory.rs`/`lib.rs` are now byte-identical to main). Source: MiniVI `20be1548` (via the longroad/InstCombine lineage).
Lower::slot_dword reads the host's per-view tables through rawBufferLoad with Attr::ReadOnly, so the optimiser treats the load as reading memory: a store or barrier between two reads of the same view's stride/size stops it merging them (the strides cache only covers stride dwords, and only within one block). The tables are immutable for the whole shader invocation, so the loads can be marked in Module::pure_reads and CSE'd across stores and barriers.

The marking is default-on: it changes the translation of programs that read a view's stride or size, so TRANSLATOR_VERSION goes 20 -> 21 and the shader cache invalidates once (victory shaders says whether the bump was due). Adapted from GPL-3.0 Androtim/MiniVI 20be1548; split out of the opt-in VICTORY_SHADER_OPT=1024 PR at the maintainer's request.

Tests: size_tests asserts the VIEW_SIZES load is marked (the_host_table_loads_are_marked_pure_reads); the existing size tests exercise the marking end to end.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 19:13:43 +00:00
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/162/head:github-bot/gh-161'
git switch 'github-bot/gh-161'

Merge

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