Shaders: index interpolation halves on demand #179

Closed
TG0000 wants to merge 2 commits from upstream-pr/179 into main
TG0000 commented 2026-11-24 01:10:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-24T01:10:45Z.


Summary

  • Build the SSA definition and phi maps only when a second interpolation instruction needs to trace its first half. All pairs in a shader reuse those maps.
  • Recognize packed interpolation by its decoded attribute operand so the I/O pass can skip opcode-name lookups for ordinary ALU instructions.
  • Cover branch-merged first halves, vertex sampling, packed f16 interpolation, and unsupported packed forms with hand-written synthetic inputs.

Benchmark

Median of seven release samples on a Ryzen 9 5900X with Windows MSVC. The harness builds synthetic SSA before timing and measures only I/O raising.

Synthetic shader ALU instructions Before (ns) After (ns) Before/after
Compute 64 4678.4 124.6 37.55x
Compute 512 30949.8 1063.5 29.10x
Compute 4096 414438.9 9949.0 41.66x
Pixel vertex sample 64 5867.9 301.6 19.46x
Pixel vertex sample 512 41911.7 1253.4 33.44x
Pixel vertex sample 4096 373081.8 10494.5 35.55x
Pixel interpolation pair 64 6226.4 4210.6 1.48x
Pixel interpolation pair 512 36562.0 27506.3 1.33x
Pixel interpolation pair 4096 314436.7 317615.4 0.99x

Run the same harness at the benchmark-only commit f5f4ad9 and at the PR head:

cargo +stable-x86_64-pc-windows-msvc test --release -p victory-shader --lib io::tests::bench_raise_io -- --ignored --nocapture --test-threads=1

Verification

  • MSVC workspace tests passed (267 passed, 5 ignored).
  • MSVC Clippy passed with existing warnings outside the changed file.
  • cargo xtask policy, targeted rustfmt --check, and git diff --check passed.
  • AI-assisted. All benchmark and regression inputs are synthetic. The retail game was not launched, so the timings do not measure frame rate.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6572302348 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/179). Originally posted by [TG0000](https://github.com/TG0000) on 2026-11-24T01:10:45Z. --- ## Summary - Build the SSA definition and phi maps only when a second interpolation instruction needs to trace its first half. All pairs in a shader reuse those maps. - Recognize packed interpolation by its decoded attribute operand so the I/O pass can skip opcode-name lookups for ordinary ALU instructions. - Cover branch-merged first halves, vertex sampling, packed f16 interpolation, and unsupported packed forms with hand-written synthetic inputs. ## Benchmark Median of seven release samples on a Ryzen 9 5900X with Windows MSVC. The harness builds synthetic SSA before timing and measures only I/O raising. | Synthetic shader | ALU instructions | Before (ns) | After (ns) | Before/after | | --- | ---: | ---: | ---: | ---: | | Compute | 64 | 4678.4 | 124.6 | 37.55x | | Compute | 512 | 30949.8 | 1063.5 | 29.10x | | Compute | 4096 | 414438.9 | 9949.0 | 41.66x | | Pixel vertex sample | 64 | 5867.9 | 301.6 | 19.46x | | Pixel vertex sample | 512 | 41911.7 | 1253.4 | 33.44x | | Pixel vertex sample | 4096 | 373081.8 | 10494.5 | 35.55x | | Pixel interpolation pair | 64 | 6226.4 | 4210.6 | 1.48x | | Pixel interpolation pair | 512 | 36562.0 | 27506.3 | 1.33x | | Pixel interpolation pair | 4096 | 314436.7 | 317615.4 | 0.99x | Run the same harness at the benchmark-only commit `f5f4ad9` and at the PR head: ```powershell cargo +stable-x86_64-pc-windows-msvc test --release -p victory-shader --lib io::tests::bench_raise_io -- --ignored --nocapture --test-threads=1 ``` ## Verification - MSVC workspace tests passed (267 passed, 5 ignored). - MSVC Clippy passed with existing warnings outside the changed file. - `cargo xtask policy`, targeted `rustfmt --check`, and `git diff --check` passed. - AI-assisted. All benchmark and regression inputs are synthetic. The retail game was not launched, so the timings do not measure frame rate.
DaviTostes commented 2026-11-24 06:54:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:19:38Z.


Tested 3248948 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test -p victory-shader: 59 passed, 0 failed, 1 ignored (2 test binaries), including the 4 tests this PR adds.
  • The ignored test is io::tests::bench_raise_io (benchmark).
  • The full workspace still needs #112 for the victory-gpu E0425.

No game data used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7118989606 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/179#issuecomment-7118989606). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T01:19:38Z. --- Tested `3248948` on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test -p victory-shader`: **59 passed, 0 failed, 1 ignored** (2 test binaries), including the 4 tests this PR adds. - The ignored test is `io::tests::bench_raise_io` (benchmark). - The full workspace still needs #112 for the `victory-gpu` E0425. No game data used.
upstream-sync closed this pull request 2026-11-24 09:05:05 +00:00

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
Marvisak/VIctory!179
No description provided.