shader: opt-in structure mask recipes (VICTORY_MASK_RECIPES=1, default off) #165

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

@⁠SovietBearz0r on GitHub · 2026-12-05 19:31 UTC · original
SovietBearz0r:shader-opt-mask-recipes → main · +344 −12 · 5 files · 1 commits · draft

Structure mask recipes split out of #126, per the review there. Default off; existing output unchanged.

What

  • VICTORY_MASK_RECIPES=1 (off): lane-mask/EXEC structure recipes are recorded and reused by boolean lowering, with cost/decision accounting and a cfg(test) equivalence assertion. Does not change VICTORY_SHADER_OPT; the switch is appended to the shader-cache key when on.
  • Split cleanliness: lower/structure.rs + lower/operands.rs changes are independent of the DXIL pass branches; only the shared emit/mod.rs/cache-key anchor is adjacent (merge conflict is textual).

Verification

  • cargo test -p victory-dxil 21 passed; cargo test -p victory-shader --lib 324 passed / 2 ignored (323 + recipe/equivalence test), and 324 passed with VICTORY_MASK_RECIPES=1; cargo check -p victory; policy 442 files; clippy -D warnings clean.
  • In-game A/B owed: mask/EXEC-heavy shaders (foliage/alpha-test, edge AA), report emitted i1-instruction deltas and FPS/frame-time delta; boolean equivalence is already asserted in tests but visual equality needs a run.

Source: MiniVI/sixmoon via longroad lineage.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 19:31 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/164) `SovietBearz0r:shader-opt-mask-recipes` → `main` · +344 −12 · 5 files · 1 commits · draft Structure mask recipes split out of #126, per the review there. Default off; existing output unchanged. ## What - `VICTORY_MASK_RECIPES=1` (off): lane-mask/EXEC structure recipes are recorded and reused by boolean lowering, with cost/decision accounting and a `cfg(test)` equivalence assertion. Does not change `VICTORY_SHADER_OPT`; the switch is appended to the shader-cache key when on. - Split cleanliness: `lower/structure.rs` + `lower/operands.rs` changes are independent of the DXIL pass branches; only the shared `emit/mod.rs`/cache-key anchor is adjacent (merge conflict is textual). ## Verification - `cargo test -p victory-dxil` **21 passed**; `cargo test -p victory-shader --lib` **324 passed / 2 ignored** (323 + recipe/equivalence test), and **324 passed** with `VICTORY_MASK_RECIPES=1`; `cargo check -p victory`; policy 442 files; clippy `-D warnings` clean. - **In-game A/B owed**: mask/EXEC-heavy shaders (foliage/alpha-test, edge AA), report emitted i1-instruction deltas and FPS/frame-time delta; boolean equivalence is already asserted in tests but visual equality needs a run. Source: MiniVI/sixmoon via longroad lineage.
The structured mask code records how each lane boolean was first made
(and/or/xor/not/ite) and the lowering may build it by that recipe in one
i1 operation over the operands where that takes fewer operations than one
per decision node (only where the operands test no variable the boolean
does not). Cost/decision accounting and a cfg(test) equivalence assertion
(the recipe given the known facts equals the decision nodes) keep it
exact: the same boolean function either way. Ported from sixmoon 1.3.0
(Darner d3fa32bd1a, GPL-3.0-or-later).

Switch: VICTORY_MASK_RECIPES=1 (default off). A default run's output,
behaviour and cache keys are unchanged; when on, the switch is appended to
the shader cache's key.

Split out of draft #125 into one pass per PR. VICTORY_LEGACY_FINITE
(unsound) is dropped, not shipped.

Tests: cargo test -p victory-shader --lib: 324 passed, 2 ignored (new: a
recipe is the function its decision nodes were made from, plus the
cfg(test) equivalence assertion on every given() call), and again 324
passed with VICTORY_MASK_RECIPES=1. cargo test -p victory-dxil: 21 passed.
cargo check -p victory; cargo xtask policy (442 files ok); clippy
-p victory-shader -p victory-dxil -p victory-gpu --all-targets -- -D
warnings; git diff --check: clean.

Still needs in-game A/B on the target cards before any promotion to
default (see the PR description).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 19:35:41 +00:00
Author
Owner

@⁠staticman256 on GitHub · 2026-12-05 19:40 UTC · original · edited 2026-12-05 19:41 UTC

I just have to ask - why port all these things default off? And no testing in game? Who's going to use them? As in, if they're beneficial, why not make them default so that users without technical expertise and knowledge about them could benefit?

**@⁠staticman256** on GitHub · 2026-12-05 19:40 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/164#issuecomment-7444174463) · edited 2026-12-05 19:41 UTC I just have to ask - why port all these things default off? And no testing in game? Who's going to use them? As in, if they're beneficial, why not make them default so that users without technical expertise and knowledge about them could benefit?
Author
Owner

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

Fair question — and the answer is: because default-on is exactly how you ship a regression silently, and we now have a concrete example of it.

We just ran the first in-game A/B on these splits (RX 9070 XT, RDNA4, 2 runs/side, same binary, play-profile baseline VICTORY_SHADER_OPT=255 vs 255+bit, measured spot windows checked for shader translations = 0):

  • LICM (#163): −17% / −45% / −48% on the three route spots. Consistently slow on both on-runs, parity runs back at ~32 fps. If that had been default-on, every RDNA4 user would have paid for it.
  • Barrier dedup (#164): within noise (−0.2%/−1.6%/−0.7%) — no win to justify taking barrier-elimination risk on by default yet.
  • InstCombine (#122): small positive (+0.5%/+0.9%/+3.7%, better p99 on one spot) — the one that might earn a default later, after more data.

Why default-off in general:

  1. Upstream policy requested exactly this: the #122/#125 reviews said "keep main clear of large unverified default-off compiler passes", "hot main clear of … without in-game A/B data". We split them and kept them off because the maintainer asked; flipping defaults before data would just get them closed.
  2. A default-on change alters shader translation and the cache key for everyone (one-time full recompile), so a bug or a card-specific regression is paid by users who can't A/B or switch it off.
  3. Default-off is what lets each pass be evaluated separately; that's how LICM's AMD regression was found before merge instead of after.

Who uses them now: testers/benchmarkers (and forks), with documented switches; once a pass has clean data on RDNA3/4 and NVIDIA plus a visual soak, the plan is to flip the default (or ship it in a per-adapter launcher profile) so nobody needs to know the env var.

If you can run a session, independent data would be genuinely useful — the caveat that bit us: play.ps1 -GpuOpt sets VICTORY_SHADER_OPT=255, so the isolation values are 511 (LICM), 767 (barriers), 1279 (InstCombine), not the PR-literal 319/575/1087. The numbers above are posted in #163/#163/#121. NVIDIA data for #125 remains missing entirely.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 20:21 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/164#issuecomment-7444744527) Fair question — and the answer is: because default-on is exactly how you ship a regression silently, and we now have a concrete example of it. We just ran the first in-game A/B on these splits (RX 9070 XT, RDNA4, 2 runs/side, same binary, play-profile baseline `VICTORY_SHADER_OPT=255` vs `255+bit`, measured spot windows checked for shader translations = 0): - **LICM (#163): −17% / −45% / −48%** on the three route spots. Consistently slow on both on-runs, parity runs back at ~32 fps. If that had been default-on, every RDNA4 user would have paid for it. - **Barrier dedup (#164): within noise** (−0.2%/−1.6%/−0.7%) — no win to justify taking barrier-elimination risk on by default yet. - **InstCombine (#122): small positive** (+0.5%/+0.9%/+3.7%, better p99 on one spot) — the one that might earn a default later, after more data. Why default-off in general: 1. Upstream policy requested exactly this: the #122/#125 reviews said "keep `main` clear of large unverified default-off compiler passes", "hot main clear of … without in-game A/B data". We split them and kept them off *because* the maintainer asked; flipping defaults before data would just get them closed. 2. A default-on change alters shader translation and the cache key for **everyone** (one-time full recompile), so a bug or a card-specific regression is paid by users who can't A/B or switch it off. 3. Default-off is what lets each pass be evaluated separately; that's how LICM's AMD regression was found before merge instead of after. Who uses them now: testers/benchmarkers (and forks), with documented switches; once a pass has clean data on RDNA3/4 *and* NVIDIA plus a visual soak, the plan is to flip the default (or ship it in a per-adapter launcher profile) so nobody needs to know the env var. If you can run a session, independent data would be genuinely useful — the caveat that bit us: `play.ps1 -GpuOpt` sets `VICTORY_SHADER_OPT=255`, so the isolation values are `511` (LICM), `767` (barriers), `1279` (InstCombine), not the PR-literal 319/575/1087. The numbers above are posted in #163/#163/#121. NVIDIA data for #125 remains missing entirely.
Author
Owner

@⁠staticman256 on GitHub · 2026-12-05 20:29 UTC · original

The point was "test your changes as if you're rolling them out to real users before submitting them as a PR and don't ship dead code behind switches users will never know to turn on", not a naive reading of the question. But an AI response to a question is certainly something else.

**@⁠staticman256** on GitHub · 2026-12-05 20:29 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/164#issuecomment-7444870000) The point was "test your changes as if you're rolling them out to real users before submitting them as a PR and don't ship dead code behind switches users will never know to turn on", not a naive reading of the question. But an AI response to a question is certainly something else.
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 23:40 UTC · original

Fair point on the ordering: opening the code for review before the in-game data existed is backwards, and that part is on us.

Status on this box (RX 9070 XT, 9900X): LICM #163 came out a clear AMD regression (kept off), barrier dedup #164 is noise, InstCombine #122 is a small win - those numbers are on those PRs. #165 is the one still missing a run, so I'm running it now: same binary both sides, play-profile baseline vs VICTORY_MASK_RECIPES=1, spot windows checked for zero shader translations. I'll post the per-spot delta here whatever it says, negative included. If it's clean and someone with an NVIDIA card can repeat it, the next step is proposing default-on with the data attached, not leaving it opt-in forever.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 23:40 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/164#issuecomment-7447748750) Fair point on the ordering: opening the code for review before the in-game data existed is backwards, and that part is on us. Status on this box (RX 9070 XT, 9900X): LICM #163 came out a clear AMD regression (kept off), barrier dedup #164 is noise, InstCombine #122 is a small win - those numbers are on those PRs. #165 is the one still missing a run, so I'm running it now: same binary both sides, play-profile baseline vs `VICTORY_MASK_RECIPES=1`, spot windows checked for zero shader translations. I'll post the per-spot delta here whatever it says, negative included. If it's clean and someone with an NVIDIA card can repeat it, the next step is proposing default-on with the data attached, not leaving it opt-in forever.
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 23:51 UTC · original

In-game data for this pass from the machine in the thread (RX 9070 XT, RDNA4, Ryzen 9 9900X, diag build, -Gpu 0). Same binary both sides (\ ictory-mask-recipes.exe\ @ 145ec1c3, sha256 9C412AEA...29B1F5), only \VICTORY_MASK_RECIPES=1\ differs. Route is pinned (same 3 spots/10-15-15 s timings as builtin:cruise, glide endpoints+heading fixed so both sides fly the same camera path); 2 measured runs per side plus one discard lap.

| spot | base avg fps | on avg fps | delta | base p50 | on p50 | base p95 | on p95 | base p99 | on p99 | base 1% low | on 1% low |
|---|---|---|---|---|---|---|---|---|---|---|---|| spawn_idle | 46.95 | 38.8 | -17.4% | 21.175 | 25.9 | 24 | 41.85 | 33.175 | 46.3 | 30.175 | 21.6 |
| cruise_out | 42.91 | 38.565 | -10.1% | 22.45 | 25.2 | 27.15 | 40.15 | 40.95 | 49 | 24.4 | 20.4 |
| cruise_back | 41.475 | 35.555 | -14.3% | 23.3 | 25.15 | 27.05 | 42.25 | 39.35 | 51.25 | 25.45 | 19.6 |

(spawn_idle: one on-side sample was a loading transition and is excluded; the two cruise spots are the measured ones.)

Cache/misses: baseline hits 3902, misses 0-2; on laps misses 46 and 83 of ~4000. The on-side cache key includes \VICTORY_MASK_RECIPES=1, so it re-translates the title's runtime shaders (they stream from a >2 GB archive the offline \ ictory shaders\ scan skips; the discard lap translated 3003).

So: I'm not claiming the -10%/-14% as a pass regression. The on-side p95/p99 (40-42 ms vs 27 ms baseline) is the cold-cache compile stalls, and this is not a steady-state A/B. What it honestly shows is that the in-game check is being run; a warm on-key cache measurement and the visual equality check (foliage/alpha-test, edge AA) are still owed before anyone proposes a default flip. All runs clean: exit 0x0, 0 ERROR/device-removed/BENCH_ERROR/panic.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 23:51 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/164#issuecomment-7447893673) In-game data for this pass from the machine in the thread (RX 9070 XT, RDNA4, Ryzen 9 9900X, diag build, -Gpu 0). Same binary both sides (\ ictory-mask-recipes.exe\ @ 145ec1c3, sha256 9C412AEA...29B1F5), only \VICTORY_MASK_RECIPES=1\ differs. Route is pinned (same 3 spots/10-15-15 s timings as builtin:cruise, glide endpoints+heading fixed so both sides fly the same camera path); 2 measured runs per side plus one discard lap. | spot | base avg fps | on avg fps | delta | base p50 | on p50 | base p95 | on p95 | base p99 | on p99 | base 1% low | on 1% low | |---|---|---|---|---|---|---|---|---|---|---|---|| spawn_idle | 46.95 | 38.8 | -17.4% | 21.175 | 25.9 | 24 | 41.85 | 33.175 | 46.3 | 30.175 | 21.6 | | cruise_out | 42.91 | 38.565 | -10.1% | 22.45 | 25.2 | 27.15 | 40.15 | 40.95 | 49 | 24.4 | 20.4 | | cruise_back | 41.475 | 35.555 | -14.3% | 23.3 | 25.15 | 27.05 | 42.25 | 39.35 | 51.25 | 25.45 | 19.6 | (spawn_idle: one on-side sample was a loading transition and is excluded; the two cruise spots are the measured ones.) Cache/misses: baseline hits 3902, misses 0-2; on laps misses 46 and 83 of ~4000. The on-side cache key includes \VICTORY_MASK_RECIPES=1\, so it re-translates the title's runtime shaders (they stream from a >2 GB archive the offline \ ictory shaders\ scan skips; the discard lap translated 3003). So: I'm **not** claiming the -10%/-14% as a pass regression. The on-side p95/p99 (40-42 ms vs 27 ms baseline) is the cold-cache compile stalls, and this is not a steady-state A/B. What it honestly shows is that the in-game check is being run; a warm on-key cache measurement and the visual equality check (foliage/alpha-test, edge AA) are still owed before anyone proposes a default flip. All runs clean: exit 0x0, 0 ERROR/device-removed/BENCH_ERROR/panic.
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/165/head:github-bot/gh-164'
git switch 'github-bot/gh-164'

Merge

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