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

Open
matheusfrta wants to merge 1 commit from upstream-pr/1013 into main
matheusfrta commented 2026-11-24 15:02:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by matheusfrta on 2026-11-24T15:02:24Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584773898 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013). Originally posted by [matheusfrta](https://github.com/matheusfrta) on 2026-11-24T15:02:24Z. --- 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.
Zipettte commented 2026-11-24 16:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:27Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136421564 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7136421564). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:27Z. --- 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)._
Marvisak commented 2026-11-25 01:08:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32: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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148618752 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7148618752). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:32:44Z. --- <!-- 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)_
upstream-sync changed title from [PR #1013] speed up shader structurisation and prioritize live pipeline compiles to [PR #1013] perf(shader): speed up control-flow structurisation 2026-11-25 02:03:21 +00:00
matheusfrta commented 2026-11-25 02:05:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by matheusfrta on 2026-11-25T01:21:44Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149468001 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7149468001). Originally posted by [matheusfrta](https://github.com/matheusfrta) on 2026-11-25T01:21:44Z. --- 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.
catminou4 commented 2026-11-25 04:04:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:56:32Z.

Review: APPROVED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051643536 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013#pullrequestreview-6051643536). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:56:32Z. **Review:** APPROVED --- 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.
matheusfrta commented 2026-11-25 16:09:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by matheusfrta on 2026-11-25T15:33:01Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167015799 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7167015799). Originally posted by [matheusfrta](https://github.com/matheusfrta) on 2026-11-25T15:33:01Z. --- 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 commented 2026-11-26 00:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by matheusfrta on 2026-11-25T23:10:47Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177234658 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7177234658). Originally posted by [matheusfrta](https://github.com/matheusfrta) on 2026-11-25T23:10:47Z. --- Rebased onto `main` (keeping the recent `discards`/`kill_exit` changes) and ensured the trailing newline in `crates/victory-shader/src/structure.rs`.
smaxxey commented 2026-11-26 11:04:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by smaxxey on 2026-11-26T10:23:36Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189304944 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1013#issuecomment-7189304944). Originally posted by [smaxxey](https://github.com/smaxxey) on 2026-11-26T10:23:36Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1013:upstream-pr/1013'
git switch 'upstream-pr/1013'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1013'
git switch 'upstream-pr/1013'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1013'
git switch 'upstream-pr/1013'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1013'
git switch 'main'
git merge --squash 'upstream-pr/1013'
git switch 'main'
git merge --ff-only 'upstream-pr/1013'
git switch 'main'
git merge 'upstream-pr/1013'
git push origin 'main'
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
Marvisak/VIctory!1013
No description provided.