Shaders: recompute ISG1 input usage and barycentrics flag after bitcode opt #122

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

@⁠davi713albano-coder on GitHub · 2026-11-24 21:39 UTC · original
davi713albano-coder:shader/sync-isg1-usage-after-opt → main · +65 −0 · 3 files · 1 commits · open

Summary

In Shader::finish() (crates/victory-shader/src/emit/shader.rs), self.m.optimise(passes) runs dead-code elimination (opt::DEAD) before writing dx.entryPoints and ISG1. Because dx.op.loadInput.* and dx.op.attributeAtVertex.* are declared Attr::ReadNone (Effect::Pure), dead input reads can be eliminated during clean-up. Previously Shader::finish() recomputed self.flags via self.m.usage(), but left self.inputs[id].usage (and flags::BARYCENTRICS) at their pre-optimization values, so ISG1 could still mark eliminated channels as read (see #53).

Changes

  • crates/victory-shader/src/emit/bitcode/opt.rs:
    • Track barycentrics (dx.op.attributeAtVertex.*) in Module::usage().
    • Add Module::input_usage(count) to compute the surviving per-element read bitmask from reachable dx.op.loadInput.* and dx.op.attributeAtVertex.* calls.
  • crates/victory-shader/src/emit/shader.rs:
    • After self.m.optimise(passes), refresh self.inputs[id].usage from self.m.input_usage(...) and clear flags::BARYCENTRICS if neither attributeAtVertex nor an SV_Barycentrics (kind == 28) input remains.
  • crates/victory-shader/src/emit/mod.rs:
    • Add synthetic pixel-shader test dead_input_read_is_cleared_from_isg1_after_opt verifying that an unused interpolated channel is cleared from ISG1's ReadWriteMask and passes dxil.dll validation.

Verification

  • Fork CI (windows-latest): https://github.com/davi713albano-coder/victory-fork/actions/runs/45491513609
    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed
    • cargo test --workspace --locked (including xtask asset-policy check and dxil.dll validation): 497 passed, 0 failed (emit::barycentric_tests::dead_input_read_is_cleared_from_isg1_after_opt ... ok)

(No title data used. AI-assisted.)

**@⁠davi713albano-coder** on GitHub · 2026-11-24 21:39 UTC · [original](https://github.com/fxceless/victory-fork/pull/122) `davi713albano-coder:shader/sync-isg1-usage-after-opt` → `main` · +65 −0 · 3 files · 1 commits · open ### Summary In `Shader::finish()` (`crates/victory-shader/src/emit/shader.rs`), `self.m.optimise(passes)` runs dead-code elimination (`opt::DEAD`) before writing `dx.entryPoints` and `ISG1`. Because `dx.op.loadInput.*` and `dx.op.attributeAtVertex.*` are declared `Attr::ReadNone` (`Effect::Pure`), dead input reads can be eliminated during clean-up. Previously `Shader::finish()` recomputed `self.flags` via `self.m.usage()`, but left `self.inputs[id].usage` (and `flags::BARYCENTRICS`) at their pre-optimization values, so `ISG1` could still mark eliminated channels as read (see #53). ### Changes - `crates/victory-shader/src/emit/bitcode/opt.rs`: - Track `barycentrics` (`dx.op.attributeAtVertex.*`) in `Module::usage()`. - Add `Module::input_usage(count)` to compute the surviving per-element read bitmask from reachable `dx.op.loadInput.*` and `dx.op.attributeAtVertex.*` calls. - `crates/victory-shader/src/emit/shader.rs`: - After `self.m.optimise(passes)`, refresh `self.inputs[id].usage` from `self.m.input_usage(...)` and clear `flags::BARYCENTRICS` if neither `attributeAtVertex` nor an `SV_Barycentrics` (`kind == 28`) input remains. - `crates/victory-shader/src/emit/mod.rs`: - Add synthetic pixel-shader test `dead_input_read_is_cleared_from_isg1_after_opt` verifying that an unused interpolated channel is cleared from `ISG1`'s `ReadWriteMask` and passes `dxil.dll` validation. ### Verification - Fork CI (`windows-latest`): https://github.com/davi713albano-coder/victory-fork/actions/runs/45491513609 - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed - `cargo test --workspace --locked` (including `xtask` asset-policy check and `dxil.dll` validation): 497 passed, 0 failed (`emit::barycentric_tests::dead_input_read_is_cleared_from_isg1_after_opt ... ok`) *(No title data used. AI-assisted.)*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:31 +00:00
Author
Owner

@⁠adriaespii on GitHub · 2026-11-24 21:52 UTC · original

Independent test run on commit 442d7c2 (AMD RDNA4):

  • Hardware: AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (x86_64-pc-windows-msvc)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo test --workspace: 497 passed, 0 failed, 7 ignored (victory-shader: 211 passed, 0 failed, 2 ignored; victory-gpu: 110 passed, 0 failed, 1 ignored)
  • Not tested: retail shader pack / live game run (no game files on this machine)

AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.

**@⁠adriaespii** on GitHub · 2026-11-24 21:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/122#issuecomment-7145493858) Independent test run on commit `442d7c2` (AMD RDNA4): - **Hardware:** AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (`x86_64-pc-windows-msvc`) - `cargo clippy --workspace --all-targets -- -D warnings`: 0 warnings - `cargo test --workspace`: 497 passed, 0 failed, 7 ignored (`victory-shader`: 211 passed, 0 failed, 2 ignored; `victory-gpu`: 110 passed, 0 failed, 1 ignored) - **Not tested:** retail shader pack / live game run (no game files on this machine) *AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.*
Author
Owner

@⁠arminkhaleghirod on GitHub · 2026-11-24 22:23 UTC · original

Merged onto main 90228a7 and ran victory translate --validate over the full title (26,148 programs) on Windows 11 / RTX 4080.

No change: every failure count matches main, and no new reason appears. What it changes at run time isn't covered by this check.

**@⁠arminkhaleghirod** on GitHub · 2026-11-24 22:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/122#issuecomment-7146178166) Merged onto main 90228a7 and ran `victory translate --validate` over the full title (26,148 programs) on Windows 11 / RTX 4080. No change: every failure count matches main, and no new reason appears. What it changes at run time isn't covered by this check.
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/122/head:github-bot/gh-122'
git switch 'github-bot/gh-122'

Merge

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