perf(shader): bound relative VGPR addressing before SSA expansion #646

Open
github-bot wants to merge 8 commits from github-bot/gh-646 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-05 22:52 UTC · original
tommiehansen:perf/bounded-relative-vgpr-20261205 → main · +638 −2 · 6 files · 8 commits · open

Why

M0-relative VGPR accesses can cause the shader translator to represent many possible registers even when the index is statically bounded. This inflates SSA construction and the work required to prepare shaders before pipeline creation. Reducing that work can help shader preparation during loading or streaming; it does not necessarily change the final GPU program.

What changes

Narrow literal M0 operands before SSA construction. For unresolved sites, reuse conservative SSA range proofs and keep the original lowering whenever the proof fails. The optimization is opt-in (VICTORY_BOUNDED_RELATIVE_VGPRS=1) with a separate v2 cache identity. An earlier double-SSA implementation increased IR build time by 63–138%; moving literal narrowing before SSA corrected that regression.

Benchmark results — Windows x64, shader preparation

CI 47585753406, head 60c334c. Eight paired blocks per shape, 128 exact arms. Times are medians of block medians; percentages are median within-block changes.

Guest wave / M0 Translation before After Time reduction Total preparation reduction
32 / phi 943.18 µs 822.30 µs 10.95% 24.27%
32 / literal 818.95 µs 726.58 µs 14.31% 5.75%
64 / phi 876.75 µs 755.90 µs 13.42% 18.44%
64 / literal 773.88 µs 673.53 µs 11.60% 3.76%

Total includes lowering, DXIL validation and WARP PSO creation (30/32 winning blocks); PSO cache reuse may affect timings. Phi DXIL shrinks from 6888 to 4692 bytes; literal DXIL remains 4620 bytes. Earlier offline ACO audit reports identical final ISA, allocation and occupancy on the matched fixture, including a derived GFX1200 compiler profile. No physical AMD execution or gameplay FPS result.

Why this should be merged

The measured benefit is CPU-side shader preparation across both guest wave widths. The conservative proof and original fallback limit the scope. It is suitable for opt-in testing without promising GPU acceleration.

Validation and compatibility

280 original exact WARP cases, 128 additional exact preparation arms, Linux shader suite and Windows GPU compilation passed. The unrelated descriptor PSO failure was reproduced on unchanged upstream (control); the scoped gate is not a full Windows-suite pass.

Reproduce on Windows: cargo test --locked --release -p victory-shader --lib bounded_relative_full_translation_cost -- --ignored --nocapture --test-threads=1. Please compare real title shader preparation/cache misses and physical RDNA compiler timings with the option off/on before considering default activation.

**@⁠tommiehansen** on GitHub · 2026-12-05 22:52 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/646) `tommiehansen:perf/bounded-relative-vgpr-20261205` → `main` · +638 −2 · 6 files · 8 commits · open ## Why M0-relative VGPR accesses can cause the shader translator to represent many possible registers even when the index is statically bounded. This inflates SSA construction and the work required to prepare shaders before pipeline creation. Reducing that work can help shader preparation during loading or streaming; it does not necessarily change the final GPU program. ## What changes Narrow literal M0 operands before SSA construction. For unresolved sites, reuse conservative SSA range proofs and keep the original lowering whenever the proof fails. The optimization is opt-in (`VICTORY_BOUNDED_RELATIVE_VGPRS=1`) with a separate v2 cache identity. An earlier double-SSA implementation increased IR build time by 63–138%; moving literal narrowing before SSA corrected that regression. ## Benchmark results — Windows x64, shader preparation [CI 47585753406](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47585753406), head `60c334c`. Eight paired blocks per shape, 128 exact arms. Times are medians of block medians; percentages are median within-block changes. | Guest wave / M0 | Translation before | After | Time reduction | Total preparation reduction | |---|---:|---:|---:|---:| | 32 / phi | 943.18 µs | 822.30 µs | 10.95% | 24.27% | | 32 / literal | 818.95 µs | 726.58 µs | 14.31% | 5.75% | | 64 / phi | 876.75 µs | 755.90 µs | 13.42% | 18.44% | | 64 / literal | 773.88 µs | 673.53 µs | 11.60% | 3.76% | Total includes lowering, DXIL validation and WARP PSO creation (30/32 winning blocks); PSO cache reuse may affect timings. Phi DXIL shrinks from 6888 to 4692 bytes; literal DXIL remains 4620 bytes. [Earlier offline ACO audit](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47581970446) reports identical final ISA, allocation and occupancy on the matched fixture, including a derived GFX1200 compiler profile. No physical AMD execution or gameplay FPS result. ## Why this should be merged The measured benefit is CPU-side shader preparation across both guest wave widths. The conservative proof and original fallback limit the scope. It is suitable for opt-in testing without promising GPU acceleration. ## Validation and compatibility 280 original exact WARP cases, 128 additional exact preparation arms, Linux shader suite and Windows GPU compilation passed. The unrelated descriptor PSO failure was reproduced on unchanged upstream ([control](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47577277910)); the scoped gate is not a full Windows-suite pass. Reproduce on Windows: `cargo test --locked --release -p victory-shader --lib bounded_relative_full_translation_cost -- --ignored --nocapture --test-threads=1`. Please compare real title shader preparation/cache misses and physical RDNA compiler timings with the option off/on before considering default activation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 22:56:46 +00:00
This pull request can be merged automatically.
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/646/head:github-bot/gh-646'
git switch 'github-bot/gh-646'

Merge

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