perf(shader): add DXIL folds, pure LICM, local/LDS forwarding, and barrier dedup #193

Closed
Vladimir-Human wants to merge 638 commits from upstream-pr/193 into main
Vladimir-Human commented 2026-11-27 07:47:46 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Vladimir-Human on 2026-11-27T07:47:46Z.


Summary

Extends crates/victory-shader/src/emit/bitcode/opt.rs with five independent, opt-in, semantics-preserving DXIL IR optimisation passes behind separate VICTORY_SHADER_OPT bits while keeping DEFAULT = 63 100% bit-identical to main and leaving TRANSLATOR_VERSION = 9 (crates/victory-shader/src/lib.rs) untouched so warm shader caches stay valid on the baseline control:

Bit Mask Pass Default Description
0..5 63 DEFAULT (DEAD|FOLD|REUSE|FACTS|LOADS|FIRST) ON Exact main control (bit-identical DXIL output; warm cache unchanged).
6 64 WIDE OFF Existing 4-dword wide console load lowering (main).
7 128 EXT_FOLD OFF (opt-in) Extended integer algebraic/bitwise/shift identities, constant reassociation, power-of-two mul/udiv/urem strength reduction, IEEE-754 NaN-safe compare negation (avoiding AMD fcmp one), undef-safe boolean select/zext folds, and canonical Key::Cmp/FACTS reuse.
8 256 MEM_FWD OFF (opt-in) Unbounded canonical GEP-path + escape analysis separating constant tables, thread-private addrspace(0) globals, shared addrspace(3) LDS, and DXIL resource memory for private-global forwarding, non-aliasing LDS load-to-load reuse, and intra-block overwritten-store DSE. Groupshared (addrspace(3)) store-to-load forwarding is disabled to preserve barrierless wave-ordered LDS exchange.
9 512 LICM OFF (opt-in) Conservative natural-loop LICM (guaranteed dominating blocks only): pure non-trapping hoisting to dominating preheaders (lazily splitting conditional entry edges), WriteKind::All (dx.op.discard) prefix guards, and explicit blocking of deriv*, wave*, quad*, and getDimensions calls.
10 1024 BARRIERS OFF (opt-in) Drops adjacent covered dx.op.barrier(80, mode) calls and coalesces bounded intra-block read-after-read barriers between non-escaping LDS read phases bounded by covering group+TGSM barriers (or Term::Ret when no UAV fence bits are set).
11 2048 SPEC_LICM OFF (opt-in) Opt-in speculative ALU, pure math allowlist, and provably in-bounds constant-table hoisting from conditional loop blocks (requires LICM; still blocks deriv*, wave*, quad*, getDimensions, traps, and resource reads).
  • Combined masks: VICTORY_SHADER_OPT=63 (or unset) = baseline main control; 63 + bit isolates any single pass (e.g. 191 = DEFAULT|EXT_FOLD, 319 = DEFAULT|MEM_FWD, 575 = DEFAULT|LICM, 1087 = DEFAULT|BARRIERS, 2623 = DEFAULT|LICM|SPEC_LICM); 4031 = ALL & !WIDE; 4095 = ALL.
  • Cache separation: victory-gpu's shader cache already hashes victory_shader::emit::shader_opt().to_le_bytes(), so DEFAULT = 63 stays warm on main's cache while every opt-in bitmask caches independently.
  • Switch & test harness (crates/victory-shader/src/emit/mod.rs): updates VICTORY_SHADER_OPT docs/tests and adds a test-only with_shader_opt thread-local override (translation_fingerprint() / VICTORY_SHADER_SWITCHES unchanged).

Visual impact

Zero visual change. DEFAULT = 63 emits bit-identical DXIL to main, and every opt-in pass is strictly semantics-preserving at the DXIL IR level (no fast-math flags, no float arithmetic reassociation, IEEE-754 NaN and undef semantics preserved, groupshared store-to-load forwarding disabled). Verified with dxil.dll validation, random-program interpreter equivalence across 400 seeds (including SPEC_LICM and LICM | SPEC_LICM), and bit-exact D3D12 hardware GPU + WARP parity.

Verification

  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): 0 warnings
  • cargo run -p xtask --locked -- policy: asset policy: 313 files ok (opt.rs 321,857 B, emit/mod.rs 146,437 B)
  • cargo test -p xtask --locked: 11 passed; 0 failed
  • HW (VICTORY_D3D12_DEBUG=1, --test-threads=1, 0 D3D12 debug errors):
    • emit::bitcode::opt::tests (default and --all-features): 29 passed; 0 failed; 1 ignored (bench)
    • the_clean_up_switch_parses_or_runs_every_pass: 1 passed; 0 failed
    • VICTORY_SHADER_OPT=4031 (hw_tests, emit::tests, emit::wave64_tests, emit::size_tests, emit::waterfall_tests): 66 passed; 0 failed; 1 ignored
  • WARP (VICTORY_WARP=1, both with VICTORY_D3D12_DEBUG=1 and CI mode without it, default and --all-features):
    • emit::bitcode::opt::tests::hw_tests: 3 passed; 0 failed; 1 ignored (0 skips)
<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5523094092 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-27T07:47:46Z. --- ## Summary Extends `crates/victory-shader/src/emit/bitcode/opt.rs` with five independent, opt-in, semantics-preserving DXIL IR optimisation passes behind separate `VICTORY_SHADER_OPT` bits while keeping `DEFAULT = 63` **100% bit-identical to `main`** and leaving `TRANSLATOR_VERSION = 9` (`crates/victory-shader/src/lib.rs`) untouched so warm shader caches stay valid on the baseline control: | Bit | Mask | Pass | Default | Description | | --- | ---: | --- | --- | --- | | `0..5` | `63` | `DEFAULT` (`DEAD\|FOLD\|REUSE\|FACTS\|LOADS\|FIRST`) | **ON** | Exact `main` control (bit-identical DXIL output; warm cache unchanged). | | `6` | `64` | `WIDE` | OFF | Existing 4-dword wide console load lowering (`main`). | | `7` | `128` | `EXT_FOLD` | OFF (opt-in) | Extended integer algebraic/bitwise/shift identities, constant reassociation, power-of-two `mul`/`udiv`/`urem` strength reduction, IEEE-754 NaN-safe compare negation (avoiding AMD `fcmp one`), `undef`-safe boolean `select`/`zext` folds, and canonical `Key::Cmp`/`FACTS` reuse. | | `8` | `256` | `MEM_FWD` | OFF (opt-in) | Unbounded canonical GEP-path + escape analysis separating constant tables, thread-private `addrspace(0)` globals, shared `addrspace(3)` LDS, and DXIL resource memory for private-global forwarding, non-aliasing LDS load-to-load reuse, and intra-block overwritten-store DSE. **Groupshared (`addrspace(3)`) store-to-load forwarding is disabled** to preserve barrierless wave-ordered LDS exchange. | | `9` | `512` | `LICM` | OFF (opt-in) | Conservative natural-loop LICM (guaranteed dominating blocks only): pure non-trapping hoisting to dominating preheaders (lazily splitting conditional entry edges), `WriteKind::All` (`dx.op.discard`) prefix guards, and explicit blocking of `deriv*`, `wave*`, `quad*`, and `getDimensions` calls. | | `10` | `1024` | `BARRIERS` | OFF (opt-in) | Drops adjacent covered `dx.op.barrier(80, mode)` calls and coalesces bounded intra-block read-after-read barriers between non-escaping LDS read phases bounded by covering group+TGSM barriers (or `Term::Ret` when no UAV fence bits are set). | | `11` | `2048` | `SPEC_LICM` | OFF (opt-in) | Opt-in speculative ALU, pure math allowlist, and provably in-bounds constant-table hoisting from conditional loop blocks (requires `LICM`; still blocks `deriv*`, `wave*`, `quad*`, `getDimensions`, traps, and resource reads). | - **Combined masks:** `VICTORY_SHADER_OPT=63` (or unset) = baseline `main` control; `63 + bit` isolates any single pass (e.g. `191` = `DEFAULT|EXT_FOLD`, `319` = `DEFAULT|MEM_FWD`, `575` = `DEFAULT|LICM`, `1087` = `DEFAULT|BARRIERS`, `2623` = `DEFAULT|LICM|SPEC_LICM`); `4031` = `ALL & !WIDE`; `4095` = `ALL`. - **Cache separation:** `victory-gpu`'s shader cache already hashes `victory_shader::emit::shader_opt().to_le_bytes()`, so `DEFAULT = 63` stays warm on `main`'s cache while every opt-in bitmask caches independently. - **Switch & test harness (`crates/victory-shader/src/emit/mod.rs`):** updates `VICTORY_SHADER_OPT` docs/tests and adds a test-only `with_shader_opt` thread-local override (`translation_fingerprint()` / `VICTORY_SHADER_SWITCHES` unchanged). ## Visual impact **Zero visual change.** `DEFAULT = 63` emits bit-identical DXIL to `main`, and every opt-in pass is strictly semantics-preserving at the DXIL IR level (no fast-math flags, no float arithmetic reassociation, IEEE-754 NaN and `undef` semantics preserved, groupshared store-to-load forwarding disabled). Verified with `dxil.dll` validation, random-program interpreter equivalence across 400 seeds (including `SPEC_LICM` and `LICM | SPEC_LICM`), and bit-exact D3D12 hardware GPU + WARP parity. ## Verification - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): **0 warnings** - `cargo run -p xtask --locked -- policy`: **asset policy: 313 files ok** (`opt.rs` `321,857 B`, `emit/mod.rs` `146,437 B`) - `cargo test -p xtask --locked`: **11 passed; 0 failed** - HW (`VICTORY_D3D12_DEBUG=1`, `--test-threads=1`, `0` D3D12 debug errors): - `emit::bitcode::opt::tests` (default and `--all-features`): **29 passed; 0 failed; 1 ignored** (bench) - `the_clean_up_switch_parses_or_runs_every_pass`: **1 passed; 0 failed** - `VICTORY_SHADER_OPT=4031` (`hw_tests`, `emit::tests`, `emit::wave64_tests`, `emit::size_tests`, `emit::waterfall_tests`): **66 passed; 0 failed; 1 ignored** - WARP (`VICTORY_WARP=1`, both with `VICTORY_D3D12_DEBUG=1` and CI mode without it, default and `--all-features`): - `emit::bitcode::opt::tests::hw_tests`: **3 passed; 0 failed; 1 ignored** (`0` skips)
TaynanGT commented 2026-11-27 08:08:36 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T08:08:36Z.


@Vladimir-Human I bumped the translator cache version to 8 on this PR. An explicit pass mask can keep the same value while the revised folds emit different DXIL. The version bump makes those runs rebuild their translations. The local pass-mask test passed.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7213196810 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7213196810). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T08:08:36Z. --- @Vladimir-Human I bumped the translator cache version to 8 on this PR. An explicit pass mask can keep the same value while the revised folds emit different DXIL. The version bump makes those runs rebuild their translations. The local pass-mask test passed.
Vladimir-Human commented 2026-11-27 08:18:00 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Vladimir-Human on 2026-11-27T08:18:00Z.


Thanks @TaynanGT — bumping the translator cache version to 8 in 173bde0 makes total sense so runs with an explicit pass mask rebuild cached DXIL instead of reusing pre-opt entries. Everything on this PR is clean and ready on our side.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7213379161 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7213379161). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-27T08:18:00Z. --- Thanks @TaynanGT — bumping the translator cache version to 8 in `173bde0` makes total sense so runs with an explicit pass mask rebuild cached DXIL instead of reusing pre-opt entries. Everything on this PR is clean and ready on our side.
TaynanGT commented 2026-11-27 08:24:12 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T08:24:12Z.


@Vladimir-Human The CI run passed on 173bde0. The remaining runtime check is a matched capture on the default mask, with the same scene, upscaler and frame generation settings. The version bump will give that run a fresh set of translations.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7213498935 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7213498935). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T08:24:12Z. --- @Vladimir-Human The CI run passed on `173bde0`. The remaining runtime check is a matched capture on the default mask, with the same scene, upscaler and frame generation settings. The version bump will give that run a fresh set of translations.
Vladimir-Human commented 2026-11-27 08:35:37 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Vladimir-Human on 2026-11-27T08:35:37Z.


Great to hear CI is green on 173bde0 — standing by if anything comes up in the matched capture!

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7213703863 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7213703863). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-27T08:35:37Z. --- Great to hear CI is green on `173bde0` — standing by if anything comes up in the matched capture!
TaynanGT commented 2026-11-27 08:39:04 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T08:39:04Z.


@Vladimir-Human Thanks. I’ll post the matched-capture results here with the two build hashes and settings.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7213766580 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7213766580). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T08:39:04Z. --- @Vladimir-Human Thanks. I’ll post the matched-capture results here with the two build hashes and settings.
efsebayern commented 2026-11-27 10:42:07 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by efsebayern on 2026-11-27T10:42:07Z.

Review: COMMENTED


I reviewed 173bde0 against its base 70ac49d. I found one correctness concern; the other passes look right to me.

Groupshared store-to-load forwarding drops wave-ordered LDS exchange (crates/victory-shader/src/emit/bitcode/opt.rs ~1829-1856 for the load lookup, ~1930-1965 where a store records its value in shared_const / shared_dyn)

Within a block, store lds[p], v followed by load lds[p] with no barrier in between is replaced by v. The PR's own test does exactly this (per-lane v1 stored to lds0, then forwarded).

DXIL allows that, since a cross-thread race without a barrier is undefined there. But the console code relies on LDS being ordered within one wave, and the translator keeps that reliance: lower.rs (~1872 and ~1912) adds no barrier when the group is ≤ 32 threads, or when it runs natively as wave64 on a 64-lane host.

Failure scenario. The "elect a leader per bucket" idiom: lds[bucket] = laneId; if (lds[bucket] == laneId) { ... }.

  • Before: lanes that collide on a bucket read the winning lane's id, so exactly one lane wins.
  • After: every lane reads back its own value, so every lane wins. That means duplicate appends, double counting, and broken binning or culling.

The DXIL validator can't catch this, because the program stays valid.

Suggestion: don't forward a store to a later load in address space 3. Load-to-load reuse, the LDS dead-store elimination and private (space 0) forwarding are fine. Alternatively, forward only when the stored value is wave-uniform.

Also worth noting: the new passes are on by default (DEFAULT 63 → 447). Because FOLD, FACTS and LOADS changed too, VICTORY_SHADER_OPT=63 doesn't give back the old output. A switch that restores the old behaviour would make A/B checks of rendering regressions easier.

Checked, nothing found:

  • LICM: wave, quad and derivative ops, loads and resource reads are never hoisted. Divisions are hoisted only for a non-zero constant divisor, and SDiv also excludes −1.
  • Barrier dedup: the superset and anchor rules hold.
  • Integer folds: shifts ≥ the bit width, division by zero and MIN/−1 are left alone. The fcmp NaN handling and canonical_cmp are correct.
  • Pointer and escape analysis: no constant-expression GEPs.

Offline results:

  • cargo test -p victory-shader --lib: 334 passed, 0 failed, 5 ignored. Clippy is clean.
  • VICTORY_HOST_WAVE=32 victory translate --list --validate over the title's shaders gives identical validation results for base and PR: VS/PS 14262/14262, CS 2759/2761, MS 8694/8765, with the same failing programs.
  • The emitted DXIL differs for 22,044 programs, so only a matched runtime comparison can rule out the LDS issue.

AI-assisted review (Claude Code).

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review:6086894781 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#pullrequestreview-6086894781). Originally posted by [efsebayern](https://github.com/efsebayern) on 2026-11-27T10:42:07Z. **Review:** COMMENTED --- I reviewed 173bde0 against its base 70ac49d. I found one correctness concern; the other passes look right to me. **Groupshared store-to-load forwarding drops wave-ordered LDS exchange** (`crates/victory-shader/src/emit/bitcode/opt.rs` ~1829-1856 for the load lookup, ~1930-1965 where a store records its value in `shared_const` / `shared_dyn`) Within a block, `store lds[p], v` followed by `load lds[p]` with no barrier in between is replaced by `v`. The PR's own test does exactly this (per-lane `v1` stored to `lds0`, then forwarded). DXIL allows that, since a cross-thread race without a barrier is undefined there. But the console code relies on LDS being ordered within one wave, and the translator keeps that reliance: `lower.rs` (~1872 and ~1912) adds no barrier when the group is ≤ 32 threads, or when it runs natively as wave64 on a 64-lane host. **Failure scenario.** The "elect a leader per bucket" idiom: `lds[bucket] = laneId; if (lds[bucket] == laneId) { ... }`. - Before: lanes that collide on a bucket read the winning lane's id, so exactly one lane wins. - After: every lane reads back its own value, so every lane wins. That means duplicate appends, double counting, and broken binning or culling. The DXIL validator can't catch this, because the program stays valid. **Suggestion:** don't forward a store to a later load in address space 3. Load-to-load reuse, the LDS dead-store elimination and private (space 0) forwarding are fine. Alternatively, forward only when the stored value is wave-uniform. **Also worth noting:** the new passes are on by default (`DEFAULT` 63 → 447). Because FOLD, FACTS and LOADS changed too, `VICTORY_SHADER_OPT=63` doesn't give back the old output. A switch that restores the old behaviour would make A/B checks of rendering regressions easier. **Checked, nothing found:** - LICM: wave, quad and derivative ops, loads and resource reads are never hoisted. Divisions are hoisted only for a non-zero constant divisor, and SDiv also excludes −1. - Barrier dedup: the superset and anchor rules hold. - Integer folds: shifts ≥ the bit width, division by zero and MIN/−1 are left alone. The fcmp NaN handling and `canonical_cmp` are correct. - Pointer and escape analysis: no constant-expression GEPs. **Offline results:** - `cargo test -p victory-shader --lib`: 334 passed, 0 failed, 5 ignored. Clippy is clean. - `VICTORY_HOST_WAVE=32 victory translate --list --validate` over the title's shaders gives identical validation results for base and PR: VS/PS 14262/14262, CS 2759/2761, MS 8694/8765, with the same failing programs. - The emitted DXIL differs for 22,044 programs, so only a matched runtime comparison can rule out the LDS issue. *AI-assisted review (Claude Code).*
Vladimir-Human commented 2026-11-27 12:27:32 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Vladimir-Human on 2026-11-27T12:27:32Z.


Thank you @efsebayern for catching the groupshared (space 3) store-to-load forwarding bug and validating the full shader set offline — pushed ef78e6c atop 173bde0:

  • Removed space-3 (PtrRoot::SharedGlobal) store-to-load forwarding in crates/victory-shader/src/emit/bitcode/opt.rs (Op::Store: shared_const.remove(&slot) on constant stores instead of inserting val, and omitted shared_dyn.insert(slot, val) on dynamic stores), preserving barrierless wave-ordered LDS exchange (group <= 32 or native wave64). Space-3 load-to-load reuse across non-aliasing writes, LDS overwritten-store DSE, and space-0 thread-private forwarding are preserved.
  • Regression tests: Updated local_and_shared_memory_forwarding_non_aliasing_and_dse and the scalar_lds alias check, and added both IR unit test shared_store_to_load_not_forwarded_wave_leader_election (dynamic bucket + constant slot invalidation/reuse) and D3D12 HW/WARP + dxil.dll test wave_ordered_lds_leader_election_preserved (verifying both Op::Load instructions remain under DEFAULT and 1-winner-per-bucket/constant-slot parity on hardware).
  • A/B switch note: VICTORY_SHADER_OPT=0 disables all module passes, 63 disables LICM+BARRIERS, and 47 disables LOADS too; @TaynanGT, if you also want the new FOLD/FACTS/LOADS refinements split behind separate opt-in bits so 63 is bit-identical to main, happy to add that cleanly.
  • Verification (VICTORY_D3D12_DEBUG=1): clippy -p victory-shader --all-targets --locked -- -D warnings (default & --all-features) 0 warnings; xtask policy 303 files ok; HW full victory-shader 336/336 passed (5 ignored); HW --all-features opt::tests 26/26 passed (1 ignored); WARP opt::tests::hw_tests 3/3 passed (1 ignored).
<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7218266503 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7218266503). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-27T12:27:32Z. --- Thank you @efsebayern for catching the groupshared (`space 3`) store-to-load forwarding bug and validating the full shader set offline — pushed `ef78e6c` atop `173bde0`: - **Removed space-3 (`PtrRoot::SharedGlobal`) store-to-load forwarding** in `crates/victory-shader/src/emit/bitcode/opt.rs` (`Op::Store`: `shared_const.remove(&slot)` on constant stores instead of inserting `val`, and omitted `shared_dyn.insert(slot, val)` on dynamic stores), preserving barrierless wave-ordered LDS exchange (`group <= 32` or native wave64). Space-3 load-to-load reuse across non-aliasing writes, LDS overwritten-store DSE, and space-0 thread-private forwarding are preserved. - **Regression tests:** Updated `local_and_shared_memory_forwarding_non_aliasing_and_dse` and the `scalar_lds` alias check, and added both IR unit test `shared_store_to_load_not_forwarded_wave_leader_election` (dynamic bucket + constant slot invalidation/reuse) and D3D12 HW/WARP + `dxil.dll` test `wave_ordered_lds_leader_election_preserved` (verifying both `Op::Load` instructions remain under `DEFAULT` and 1-winner-per-bucket/constant-slot parity on hardware). - **A/B switch note:** `VICTORY_SHADER_OPT=0` disables all module passes, `63` disables `LICM`+`BARRIERS`, and `47` disables `LOADS` too; @TaynanGT, if you also want the new `FOLD`/`FACTS`/`LOADS` refinements split behind separate opt-in bits so `63` is bit-identical to `main`, happy to add that cleanly. - **Verification (`VICTORY_D3D12_DEBUG=1`):** `clippy -p victory-shader --all-targets --locked -- -D warnings` (default & `--all-features`) 0 warnings; `xtask policy` 303 files ok; HW full `victory-shader` 336/336 passed (5 ignored); HW `--all-features` `opt::tests` 26/26 passed (1 ignored); WARP `opt::tests::hw_tests` 3/3 passed (1 ignored).
TaynanGT commented 2026-11-27 12:32:26 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T12:32:26Z.


@Vladimir-Human Yes, please put the new FOLD, FACTS, and LOADS refinements behind separate opt-in bits. That gives us a byte-identical main control for the warm-cache A/B and keeps LICM and barrier dedup independently testable. The LDS leader-election regression covers the behaviour that the forwarding change must preserve.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7218362132 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7218362132). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T12:32:26Z. --- @Vladimir-Human Yes, please put the new FOLD, FACTS, and LOADS refinements behind separate opt-in bits. That gives us a byte-identical main control for the warm-cache A/B and keeps LICM and barrier dedup independently testable. The LDS leader-election regression covers the behaviour that the forwarding change must preserve.
Vladimir-Human commented 2026-11-27 14:01:10 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Vladimir-Human on 2026-11-27T14:01:10Z.


@TaynanGT Done — rebased onto main (ac9923d) and split all new refinements behind separate opt-in VICTORY_SHADER_OPT bits while keeping DEFAULT = 63 bit-identical to main and TRANSLATOR_VERSION = 9 (lib.rs) untouched so warm caches stay valid on the baseline control (victory-gpu's shader cache keys on shader_opt().to_le_bytes()):

Mask Bit(s) Purpose
63 (unset) DEFAULT (1|2|4|8|16|32) Byte-identical main control (opt.rs:L98)
191 (+128) DEFAULT | EXT_FOLD Extended folds, undef-safe select, canonical Cmp/FACTS (opt.rs:L80)
319 (+256) DEFAULT | MEM_FWD Private-global forwarding, non-aliasing LDS load reuse, DSE — no space-3 store-to-load forwarding (opt.rs:L83)
575 (+512) DEFAULT | LICM Conservative pure LICM, guaranteed blocks only, blocking deriv*/wave*/quad*/getDimensions (opt.rs:L85, L2506)
1087 (+1024) DEFAULT | BARRIERS Adjacent covered & bounded read-after-read barrier dedup (opt.rs:L87)
2623 (+512+2048) DEFAULT | LICM | SPEC_LICM Adds opt-in speculative ALU/math/in-bounds const-table hoisting from conditional loop blocks (opt.rs:L90)
4031 / 4095 ALL & !WIDE / ALL All passes without / with WIDE (64) (opt.rs:L95, emit/mod.rs:L217)
  • Key tests (crates/victory-shader/src/emit/bitcode/opt.rs, emit/mod.rs):
    • DEFAULT = 63 invariance: default_63_leaves_ext_fold_off (L4384), default_63_leaves_all_opt_in_passes_off (L5756), the_clean_up_switch_parses_or_runs_every_pass (emit/mod.rs:L1399)
    • Groupshared (space 3) leader-election preservation: shared_store_to_load_not_forwarded_wave_leader_election (L4597), wave_ordered_lds_leader_election_preserved (L7288)
    • Per-pass unit, random-fuzz, and HW/WARP parity: every_pass_leaves_what_random_programs_store (L4026), select_bool_fold_skips_undef_operands (L4328), local_and_shared_memory_forwarding_non_aliasing_and_dse (L4511), licm_hoists_pure_invariants_splits_cond_entry_and_respects_traps (L4927), licm_negative_controls_speculative_resources_uniformity_discard_and_signed_const_gep (L5046), adjacent_redundant_barrier_elimination_and_negative_controls (L5396), read_after_read_barrier_coalescing_and_soundness_negatives (L5460), dxil_opt_hw_gpu_bit_exact_parity_and_validation (L6512), split_lds_wave32_read_after_read_barrier_coalescing_and_parity (L6728)
  • Status: CI is 4/4 green (Clippy, Default tests, Diagnostics tests, check), MERGEABLE / CLEAN.
<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7220229960 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7220229960). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-27T14:01:10Z. --- @TaynanGT Done — rebased onto `main` (`ac9923d`) and split all new refinements behind separate opt-in `VICTORY_SHADER_OPT` bits while keeping `DEFAULT = 63` bit-identical to `main` and `TRANSLATOR_VERSION = 9` (`lib.rs`) untouched so warm caches stay valid on the baseline control (`victory-gpu`'s shader cache keys on `shader_opt().to_le_bytes()`): | Mask | Bit(s) | Purpose | | ---: | --- | --- | | `63` (unset) | `DEFAULT` (`1\|2\|4\|8\|16\|32`) | Byte-identical `main` control (`opt.rs:L98`) | | `191` (`+128`) | `DEFAULT \| EXT_FOLD` | Extended folds, `undef`-safe `select`, canonical `Cmp`/`FACTS` (`opt.rs:L80`) | | `319` (`+256`) | `DEFAULT \| MEM_FWD` | Private-global forwarding, non-aliasing LDS load reuse, DSE — no space-3 store-to-load forwarding (`opt.rs:L83`) | | `575` (`+512`) | `DEFAULT \| LICM` | Conservative pure LICM, guaranteed blocks only, blocking `deriv*`/`wave*`/`quad*`/`getDimensions` (`opt.rs:L85`, `L2506`) | | `1087` (`+1024`) | `DEFAULT \| BARRIERS` | Adjacent covered & bounded read-after-read barrier dedup (`opt.rs:L87`) | | `2623` (`+512+2048`) | `DEFAULT \| LICM \| SPEC_LICM` | Adds opt-in speculative ALU/math/in-bounds const-table hoisting from conditional loop blocks (`opt.rs:L90`) | | `4031` / `4095` | `ALL & !WIDE` / `ALL` | All passes without / with `WIDE` (`64`) (`opt.rs:L95`, `emit/mod.rs:L217`) | - **Key tests (`crates/victory-shader/src/emit/bitcode/opt.rs`, `emit/mod.rs`):** - `DEFAULT = 63` invariance: `default_63_leaves_ext_fold_off` (`L4384`), `default_63_leaves_all_opt_in_passes_off` (`L5756`), `the_clean_up_switch_parses_or_runs_every_pass` (`emit/mod.rs:L1399`) - Groupshared (`space 3`) leader-election preservation: `shared_store_to_load_not_forwarded_wave_leader_election` (`L4597`), `wave_ordered_lds_leader_election_preserved` (`L7288`) - Per-pass unit, random-fuzz, and HW/WARP parity: `every_pass_leaves_what_random_programs_store` (`L4026`), `select_bool_fold_skips_undef_operands` (`L4328`), `local_and_shared_memory_forwarding_non_aliasing_and_dse` (`L4511`), `licm_hoists_pure_invariants_splits_cond_entry_and_respects_traps` (`L4927`), `licm_negative_controls_speculative_resources_uniformity_discard_and_signed_const_gep` (`L5046`), `adjacent_redundant_barrier_elimination_and_negative_controls` (`L5396`), `read_after_read_barrier_coalescing_and_soundness_negatives` (`L5460`), `dxil_opt_hw_gpu_bit_exact_parity_and_validation` (`L6512`), `split_lds_wave32_read_after_read_barrier_coalescing_and_parity` (`L6728`) - **Status:** CI is 4/4 green (`Clippy`, `Default tests`, `Diagnostics tests`, `check`), `MERGEABLE` / `CLEAN`.
TaynanGT commented 2026-11-27 14:12:18 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T14:12:18Z.


@Vladimir-Human The split switches give us a clean way to measure the passes one at a time. I moved DATAFLOW to bit 4096 in #281 so LICM keeps bit 512 here. Start the 63 vs 575 run in a fresh cache directory if you used the earlier dataflow branch with 575. The LDS leader-election tests cover the forwarding guard we needed.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7220484219 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7220484219). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T14:12:18Z. --- @Vladimir-Human The split switches give us a clean way to measure the passes one at a time. I moved DATAFLOW to bit 4096 in #281 so LICM keeps bit 512 here. Start the `63` vs `575` run in a fresh cache directory if you used the earlier dataflow branch with `575`. The LDS leader-election tests cover the forwarding guard we needed.
Smoodie7 commented 2026-11-27 21:23:43 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Smoodie7 on 2026-11-27T21:23:43Z.


I tried this PR merged on top of main 1d830857 (the head I fetched earlier today had two small conflicts with main; I kept main's clamp and getDimensions exclusions in opt.rs and took this PR's test override in emit/mod.rs) with VICTORY_SHADER_OPT=4031, on an RTX 4070 Ti SUPER 16 GB / Ryzen 7 7700, Series S, DLSS Quality + frame generation.

Shaders: 25,790 cached, no new translation failures. warm --used: 3,987 pipelines made, 0 failed.

In game it was unplayable in a dialogue cutscene: 3.5 FPS (one sample at 0.2), 224 draws a frame dropped without a host pipeline, and the "being made" count sat at about 1,550 and stopped going down (1,548 → 1,543 in 40 s). The same build without this PR and without VICTORY_SHADER_OPT had about half as many pipelines in flight at the same point and became playable once they were done. The picture showed white blown-out faces, rectangular stale tiles and ghosting, which matches the dropped passes.

The run also had four copy-related opt-ins on (VICTORY_WATCH_XMEM_ALLOC, VICTORY_WATCH_HEAP, VICTORY_PLACED_FILL_REDIRECT, VICTORY_INPLACE=2), so this does not prove the cause. My guess is that the new translation key leaves the driver's pipeline cache cold for every pipeline outside the warm set, and the different DXIL takes longer to compile. Full report with the screenshot: https://github.com/TaynanGT/Vice-Tay/issues/212#issuecomment-7228383950. I'll rerun with VICTORY_SHADER_OPT=4031 alone on the same cutscene.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7228404916 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7228404916). Originally posted by [Smoodie7](https://github.com/Smoodie7) on 2026-11-27T21:23:43Z. --- I tried this PR merged on top of `main` `1d830857` (the head I fetched earlier today had two small conflicts with `main`; I kept main's clamp and `getDimensions` exclusions in `opt.rs` and took this PR's test override in `emit/mod.rs`) with `VICTORY_SHADER_OPT=4031`, on an RTX 4070 Ti SUPER 16 GB / Ryzen 7 7700, Series S, DLSS Quality + frame generation. Shaders: 25,790 cached, no new translation failures. `warm --used`: 3,987 pipelines made, 0 failed. In game it was unplayable in a dialogue cutscene: 3.5 FPS (one sample at 0.2), 224 draws a frame dropped without a host pipeline, and the "being made" count sat at about 1,550 and stopped going down (1,548 → 1,543 in 40 s). The same build without this PR and without `VICTORY_SHADER_OPT` had about half as many pipelines in flight at the same point and became playable once they were done. The picture showed white blown-out faces, rectangular stale tiles and ghosting, which matches the dropped passes. The run also had four copy-related opt-ins on (`VICTORY_WATCH_XMEM_ALLOC`, `VICTORY_WATCH_HEAP`, `VICTORY_PLACED_FILL_REDIRECT`, `VICTORY_INPLACE=2`), so this does not prove the cause. My guess is that the new translation key leaves the driver's pipeline cache cold for every pipeline outside the warm set, and the different DXIL takes longer to compile. Full report with the screenshot: https://github.com/TaynanGT/Vice-Tay/issues/212#issuecomment-7228383950. I'll rerun with `VICTORY_SHADER_OPT=4031` alone on the same cutscene.
TaynanGT commented 2026-11-29 11:24:03 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T11:24:03Z.


Thanks for the detailed cutscene regression report. The stalled pipeline queue and dropped draws make this a correctness issue as well as a performance one. The combined run isn't proof against #193 alone. Let's compare the same build, scene and cache preparation with just the shader optimization toggle changed.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7255086025 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7255086025). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T11:24:03Z. --- Thanks for the detailed cutscene regression report. The stalled pipeline queue and dropped draws make this a correctness issue as well as a performance one. The combined run isn't proof against #193 alone. Let's compare the same build, scene and cache preparation with just the shader optimization toggle changed.
TaynanGT commented 2026-11-30 17:16:09 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:16:09Z.


main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285992879 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/193#issuecomment-7285992879). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-30T17:16:09Z. --- `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
TaynanGT/Vice-Tay!193
No description provided.