dxil: opt-in barrier dedup (VICTORY_SHADER_OPT=512, default off) #164

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

@⁠SovietBearz0r on GitHub · 2026-12-05 19:31 UTC · original
SovietBearz0r:shader-opt-barriers → main · +425 −8 · 4 files · 1 commits · draft

Barrier dedup split out of #126, per the review there. Default off; existing output unchanged.

What

  • opt::BARRIERS = 512 in VICTORY_SHADER_OPT (e.g. =575 = defaults 63 + BARRIERS): an in-block barrier-state machine — adjacent covered barriers across pure ALU are merged, a group-only barrier is dropped between LDS read phases bounded by group+TGSM barriers/return, and a tail barrier before ret is dropped. Loads are classified by the translator's own pointer tracing.
  • DEFAULT stays 63; the opt-in mask is hashed in the shader-cache key, no version bump for default users and no extra switch.
  • Split cleanliness: only the pass-specific bookkeeping block (mask 767; union 1023 if merged with LICM) differs from the LICM branch — conflicts are constants/comments only. No dominator-tree change here.

Verification

  • cargo test -p victory-dxil 23 passed (21 + covered-barrier and LDS read-phase tests); cargo test -p victory-shader --lib 323 passed / 2 ignored, and 323 passed with VICTORY_SHADER_OPT=575; cargo check -p victory; policy 442 files; clippy -D warnings clean.
  • In-game A/B owed (riskiest pass — barrier elimination): LDS/barrier-heavy compute (GTAO/SSAO, particles, water/tile) and pixel shaders; soak longer, watch temporal flicker/races/hangs on AMD and NVIDIA, report barriers dropped per program and wave64/wave32 differences; ≥3 runs each with frame-time percentiles and GPU busy.

Source: MiniVI/sixmoon via longroad lineage.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 19:31 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/163) `SovietBearz0r:shader-opt-barriers` → `main` · +425 −8 · 4 files · 1 commits · draft Barrier dedup split out of #126, per the review there. Default off; existing output unchanged. ## What - `opt::BARRIERS = 512` in `VICTORY_SHADER_OPT` (e.g. `=575` = defaults 63 + BARRIERS): an in-block barrier-state machine — adjacent covered barriers across pure ALU are merged, a group-only barrier is dropped between LDS read phases bounded by group+TGSM barriers/return, and a tail barrier before `ret` is dropped. Loads are classified by the translator's own pointer tracing. - `DEFAULT` stays 63; the opt-in mask is hashed in the shader-cache key, no version bump for default users and no extra switch. - Split cleanliness: only the pass-specific bookkeeping block (mask 767; union 1023 if merged with LICM) differs from the LICM branch — conflicts are constants/comments only. No dominator-tree change here. ## Verification - `cargo test -p victory-dxil` **23 passed** (21 + covered-barrier and LDS read-phase tests); `cargo test -p victory-shader --lib` **323 passed / 2 ignored**, and **323 passed** with `VICTORY_SHADER_OPT=575`; `cargo check -p victory`; policy 442 files; clippy `-D warnings` clean. - **In-game A/B owed** (riskiest pass — barrier elimination): LDS/barrier-heavy compute (GTAO/SSAO, particles, water/tile) and pixel shaders; soak longer, watch temporal flicker/races/hangs on AMD and NVIDIA, report barriers dropped per program and wave64/wave32 differences; ≥3 runs each with frame-time percentiles and GPU busy. Source: MiniVI/sixmoon via longroad lineage.
Drops a dx.op.barrier whose mode bits an earlier barrier in the same
block already covers when nothing it orders ran between them (only pure
ALU keeps the adjacency: loads, effects and lane ops reset the state
machine), and a group-only barrier between two read phases of thread-group
memory (LDS, space 3) bounded by group+TGSM barriers (or a group+TGSM
barrier before the tail and a return after it). Loads are classified by
main's own pointer trace (through one getelementptr to a global's address
space); an untraced pointer is conservative. Ported from sixmoon 1.3.0
(same file, GPL-3.0-or-later).

Switch: VICTORY_SHADER_OPT bit 512 (opt::BARRIERS); VICTORY_SHADER_OPT=575
runs it with the established passes. DEFAULT stays 63 and a default run's
output, behaviour and cache keys are unchanged (the pass bit is already
part of the shader cache's key; there is no extra switch).

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

Tests: cargo test -p victory-dxil: 23 passed (new: covered barriers are
dropped across pure arithmetic but kept after an effect or where the
later barrier covers more; the group-only barrier between two LDS read
phases is dropped while the group+TGSM anchors stay). cargo test
-p victory-shader --lib: 323 passed, 2 ignored, and again 323 passed with
VICTORY_SHADER_OPT=575. 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:28 +00:00
Author
Owner

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

First in-game data point on this branch (AMD side). Machine: RX 9070 XT 16 GB (RDNA4, driver 32.0.32029.2010), Ryzen 9 9900X, Windows, diag build, bench.ps1 builtin:cruise route, -Gpu 0. Same binary for both sides; baseline = the play profile (VICTORY_SHADER_OPT=255 via -GpuOpt), on-side =767 (255 + BARRIERS). 2 runs per side, medians; 0 shaders translated during the measured spots in every run (the lap's cache lines showed translations only during loading).

spot base avg fps on avg fps delta base p99 ms on p99 ms base 1% low on 1% low
spawn_idle 32.80 32.75 -0.2% 48.6 48.5 20.6 20.7
cruise_out 32.52 32.01 -1.6% 47.2 49.6 21.3 20.3
cruise_back 29.95 29.75 -0.7% 103.8 111.0 9.7 9.1

So on this card/route the pass is neutral within noise (slightly worse p99/back spot, slightly better lows on the other two). This is not the full protocol from the PR body: one card, two runs, one route, no visual A/B. It needs the NVIDIA + RDNA3 data and a visual soak before this can be recommended, but nothing here blocks the review.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 20:20 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/163#issuecomment-7444741314) First in-game data point on this branch (AMD side). Machine: **RX 9070 XT 16 GB (RDNA4, driver 32.0.32029.2010)**, Ryzen 9 9900X, Windows, diag build, `bench.ps1` builtin:cruise route, `-Gpu 0`. Same binary for both sides; baseline = the play profile (`VICTORY_SHADER_OPT=255` via `-GpuOpt`), on-side `=767` (255 + BARRIERS). 2 runs per side, medians; **0 shaders translated during the measured spots** in every run (the lap's cache lines showed translations only during loading). | spot | base avg fps | on avg fps | delta | base p99 ms | on p99 ms | base 1% low | on 1% low | |---|---|---|---|---|---|---|---| | spawn_idle | 32.80 | 32.75 | -0.2% | 48.6 | 48.5 | 20.6 | 20.7 | | cruise_out | 32.52 | 32.01 | -1.6% | 47.2 | 49.6 | 21.3 | 20.3 | | cruise_back | 29.95 | 29.75 | -0.7% | 103.8 | 111.0 | 9.7 | 9.1 | So on this card/route the pass is neutral within noise (slightly worse p99/back spot, slightly better lows on the other two). This is **not** the full protocol from the PR body: one card, two runs, one route, no visual A/B. It needs the NVIDIA + RDNA3 data and a visual soak before this can be recommended, but nothing here blocks the review.
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/164/head:github-bot/gh-163'
git switch 'github-bot/gh-163'

Merge

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