perf(shader): speed up control-flow structurisation #1013

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

@⁠matheusfrta on GitHub · 2026-11-24 15:02 UTC · original
matheusfrta:patch-1795532539 → main · +272 −80 · 1 files · 1 commits · open

Rebased onto main keeping all recent structurisation fixes (discards, spilled masks, bounded memo). Applies pure BDD implication checking, per-block forced-atom restriction, and dirty-block propagation in paths. Added trailing newline for cargo fmt.

**@⁠matheusfrta** on GitHub · 2026-11-24 15:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013) `matheusfrta:patch-1795532539` → `main` · +272 −80 · 1 files · 1 commits · open Rebased onto main keeping all recent structurisation fixes (discards, spilled masks, bounded memo). Applies pure BDD implication checking, per-block forced-atom restriction, and dirty-block propagation in paths. Added trailing newline for cargo fmt.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:17:04 +00:00
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 15:40 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at cbbb17e: cargo test -p victory-gpu -p victory-shader passes, 173 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 15:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7136421564) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at cbbb17e: `cargo test -p victory-gpu -p victory-shader` passes, 173 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:32 UTC · original · edited 2026-11-26 00:21 UTC

Automated triage for the maintainers.

Needs work. Rebased cleanly. The change is now only crates/victory-shader/src/structure.rs: a recursive Bools::implies that no longer builds and(a, not b), normalization and argument ordering in ite, an early contradiction check in the refutation path, and dirty-block propagation. This is a performance change to the code that decides lane masks for every shader, so it needs the two things asked for before. Neither needs game files:

  • Before/after numbers from crates/victory-shader/benches/guard_runs.rs, which is in main, to show the speed-up.
  • Evidence that the output is unchanged, for example the existing victory-shader tests plus a check that structured output (or emitted DXIL) is byte-identical on the synthetic programs in the test suite.

Also worth a sentence in the description: the new early return false when the sorted list holds the same Bool twice changes what that function returns. Say why that is equivalent.

On your reply: understood that you have no game dump. The benchmark and the test-suite comparison above don't need one. Until then there is no evidence of a speed-up, and the risk is a silent change in lane masks.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7148618752) · edited 2026-11-26 00:21 UTC <!-- victory-triage v1 head=ab9de6feae034cfc8686d27b6527985c31bb518c verdict=needs-work at=2026-11-26T00:21:44Z --> Automated triage for the maintainers. **Needs work.** Rebased cleanly. The change is now only `crates/victory-shader/src/structure.rs`: a recursive `Bools::implies` that no longer builds `and(a, not b)`, normalization and argument ordering in `ite`, an early contradiction check in the refutation path, and dirty-block propagation. This is a performance change to the code that decides lane masks for every shader, so it needs the two things asked for before. Neither needs game files: - Before/after numbers from `crates/victory-shader/benches/guard_runs.rs`, which is in `main`, to show the speed-up. - Evidence that the output is unchanged, for example the existing `victory-shader` tests plus a check that structured output (or emitted DXIL) is byte-identical on the synthetic programs in the test suite. Also worth a sentence in the description: the new early `return false` when the sorted list holds the same `Bool` twice changes what that function returns. Say why that is equivalent. On your reply: understood that you have no game dump. The benchmark and the test-suite comparison above don't need one. Until then there is no evidence of a speed-up, and the risk is a silent change in lane masks. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠matheusfrta on GitHub · 2026-11-25 01:21 UTC · original

Rebased onto main and dropped the pipeline/make.rs changes since main already prioritizes live draws ahead of early starts. All CI checks are passing now with no conflicts.

**@⁠matheusfrta** on GitHub · 2026-11-25 01:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7149468001) Rebased onto `main` and dropped the `pipeline/make.rs` changes since `main` already prioritizes live draws ahead of early starts. All CI checks are passing now with no conflicts.
Author
Owner

@⁠matheusfrta on GitHub · 2026-11-25 15:33 UTC · original

Fixed the trailing newline in crates/victory-shader/src/structure.rs.

I don't have a game dump available locally to run victory translate and compare real-world timings and DXIL hashes. If anyone following this PR with the game shaders handy (maybe @⁠Zipettte or @⁠pablogonz12 since it was tested/merged in Scarlight) could share a before/after victory translate run and check the output hashes, that would help verify the speedup on real title shaders.

**@⁠matheusfrta** on GitHub · 2026-11-25 15:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7167015799) Fixed the trailing newline in `crates/victory-shader/src/structure.rs`. I don't have a game dump available locally to run `victory translate` and compare real-world timings and DXIL hashes. If anyone following this PR with the game shaders handy (maybe @⁠Zipettte or @⁠pablogonz12 since it was tested/merged in Scarlight) could share a before/after `victory translate` run and check the output hashes, that would help verify the speedup on real title shaders.
Author
Owner

@⁠matheusfrta on GitHub · 2026-11-25 23:10 UTC · original

Rebased onto main (keeping the recent discards/kill_exit changes) and ensured the trailing newline in crates/victory-shader/src/structure.rs.

**@⁠matheusfrta** on GitHub · 2026-11-25 23:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7177234658) Rebased onto `main` (keeping the recent `discards`/`kill_exit` changes) and ensured the trailing newline in `crates/victory-shader/src/structure.rs`.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 03:56 UTC · original · approved these changes

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

146 passed / 0 failed / 2 ignored. Control-flow structurisation speedup (+2 tests) — perf work on the structurizer; suite green.

**@⁠catminou4** on GitHub · 2026-11-25 03:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013#pullrequestreview-6051643536) · **approved these changes** Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 146 passed / 0 failed / 2 ignored. Control-flow structurisation speedup (+2 tests) — perf work on the structurizer; suite green.
Author
Owner

@⁠smaxxey on GitHub · 2026-11-26 10:23 UTC · original

Numbers for the two things the triage asked for, neither of which needs game files. Laptop with an i7-13620H, Windows 11 26300, Rust 1.98.1. Head ab9de6f merged locally onto main 63bcca4.

benches/guard_runs.rs, median per program, three rounds alternating main and this PR:

program main this PR
unmasked 16.0 / 17.2 / 15.9 µs 17.1 / 16.1 / 15.3 µs
short runs 10.9 / 11.1 / 10.9 µs 6.1 / 5.8 / 5.6 µs
long runs 25.7 / 27.0 / 25.8 µs 30.0 / 19.0 / 26.4 µs

About 1.9× faster on short runs and no change on unmasked; long runs stay within this laptop's noise.

Output unchanged. A local example (not part of this PR) put 312 synthetic compute programs through range::build → resource::track → io::raise → emit::emit: wave32 and wave64; 0–12 v_cmpx narrowings; runs of 1, 2, 7 and 64 adds; three shapes (each narrowing followed by its run, the same with s_cbranch_execz over each run, and all narrowings first). All 312 DXIL containers are byte-identical between main and this PR, and none is refused on either.

Tests. cargo test -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index (that test kills the process on main here, #2571): 300 passed, 3 failed. The 3 are the same NVIDIA failures main has on this card (#1835); the 2 more passing are this PR's new tests.

Tested with Claude Code's help.

**@⁠smaxxey** on GitHub · 2026-11-26 10:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7189304944) Numbers for the two things the triage asked for, neither of which needs game files. Laptop with an i7-13620H, Windows 11 26300, Rust 1.98.1. Head `ab9de6f` merged locally onto `main` 63bcca4. **`benches/guard_runs.rs`**, median per program, three rounds alternating `main` and this PR: | program | `main` | this PR | |---|---|---| | unmasked | 16.0 / 17.2 / 15.9 µs | 17.1 / 16.1 / 15.3 µs | | short runs | 10.9 / 11.1 / 10.9 µs | 6.1 / 5.8 / 5.6 µs | | long runs | 25.7 / 27.0 / 25.8 µs | 30.0 / 19.0 / 26.4 µs | About 1.9× faster on short runs and no change on unmasked; long runs stay within this laptop's noise. **Output unchanged.** A local example (not part of this PR) put 312 synthetic compute programs through `range::build` → `resource::track` → `io::raise` → `emit::emit`: wave32 and wave64; 0–12 `v_cmpx` narrowings; runs of 1, 2, 7 and 64 adds; three shapes (each narrowing followed by its run, the same with `s_cbranch_execz` over each run, and all narrowings first). All 312 DXIL containers are byte-identical between `main` and this PR, and none is refused on either. **Tests.** `cargo test -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index` (that test kills the process on `main` here, #2571): 300 passed, 3 failed. The 3 are the same NVIDIA failures `main` has on this card (#1835); the 2 more passing are this PR's new tests. Tested with Claude Code's help.
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/1013/head:github-bot/gh-1013'
git switch 'github-bot/gh-1013'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1013'
git switch 'github-bot/gh-1013'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1013'
git switch 'github-bot/gh-1013'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1013'
git switch 'main'
git merge --squash 'github-bot/gh-1013'
git switch 'main'
git merge --ff-only 'github-bot/gh-1013'
git switch 'main'
git merge 'github-bot/gh-1013'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1013
No description provided.