Shaders: lower pixel SV_Coverage input via dx.op.coverage #1884

Closed
n-romanovich wants to merge 1 commit from upstream-pr/1886 into main
n-romanovich commented 2026-11-25 00:04:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-25T00:04:33Z.


Fixes #1530

Problem

io::raise already lifts SPI_PS_INPUT_ADDR bit 14 (sample_coverage) into Input::SampleCoverage, and io recognizes semantic kind 14, but emit::lower::input fell through to Val::Missing("a pixel system input"). In addition, console containers can list SV_Coverage (kind == 14) in ISG1, whereas DXIL expects pixel SV_Coverage inputs to be NotInSig and read via dx.op.coverage.

Fix

  • crates/victory-shader/src/emit/lower.rs: handle Input::SampleCoverage in Lower::input by emitting dx.op.coverage.i32 (opcode 91, Attr::ReadNone, no extra arguments) in the entry block.
  • crates/victory-shader/src/emit/mod.rs: strip signature elements with kind == 14 from pixel ISG1 (and the derived PSV0 input signature) in emit.
  • crates/victory-shader/src/emit/mod.rs: add emit::tests::pixel_sample_coverage_input_lowers_and_drops_from_isg1 to verify translation and ISG1 stripping on a synthetic pixel shader reading SPI_PS_INPUT_ADDR bit 14.

Verification

  • Ran cargo test -p victory-shader --locked -- pixel_sample_coverage_input_lowers_and_drops_from_isg1 on Windows 11 (NVIDIA RTX 5060 Ti): 1 passed, 0 failed.
  • Synthetic test only; no game files used.
  • AI-assisted (authored and verified with Antigravity).
<!-- greyfinch-sync:Marvisak/VIctory:issue:6593998790 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1886). Originally posted by [n-romanovich](https://github.com/n-romanovich) on 2026-11-25T00:04:33Z. --- Fixes #1530 ### Problem `io::raise` already lifts `SPI_PS_INPUT_ADDR` bit 14 (`sample_coverage`) into `Input::SampleCoverage`, and `io` recognizes semantic kind `14`, but `emit::lower::input` fell through to `Val::Missing("a pixel system input")`. In addition, console containers can list `SV_Coverage` (`kind == 14`) in `ISG1`, whereas DXIL expects pixel `SV_Coverage` inputs to be `NotInSig` and read via `dx.op.coverage`. ### Fix - `crates/victory-shader/src/emit/lower.rs`: handle `Input::SampleCoverage` in `Lower::input` by emitting `dx.op.coverage.i32` (opcode `91`, `Attr::ReadNone`, no extra arguments) in the entry block. - `crates/victory-shader/src/emit/mod.rs`: strip signature elements with `kind == 14` from pixel `ISG1` (and the derived `PSV0` input signature) in `emit`. - `crates/victory-shader/src/emit/mod.rs`: add `emit::tests::pixel_sample_coverage_input_lowers_and_drops_from_isg1` to verify translation and `ISG1` stripping on a synthetic pixel shader reading `SPI_PS_INPUT_ADDR` bit 14. ### Verification - Ran `cargo test -p victory-shader --locked -- pixel_sample_coverage_input_lowers_and_drops_from_isg1` on Windows 11 (NVIDIA RTX 5060 Ti): **1 passed, 0 failed**. - Synthetic test only; no game files used. - AI-assisted (authored and verified with Antigravity).
catminou4 commented 2026-11-25 03:02:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:17:13Z.

Review: APPROVED


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

145 passed / 0 failed / 2 ignored (+1 new test vs the 144 baseline). Pixel SV_Coverage input lowered via dx.op.coverage — clean addition, suite green.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050698096 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1886#pullrequestreview-6050698096). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:17:13Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 145 passed / 0 failed / 2 ignored (+1 new test vs the 144 baseline). Pixel SV_Coverage input lowered via dx.op.coverage — clean addition, suite green.
Marvisak commented 2026-11-25 09:06:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:19:11Z.


Automated triage for the maintainers.

Merge candidate.

io::raise on main already maps SPI_PS_INPUT_ADDR bit 14 to Input::SampleCoverage, but Lower::input (crates/victory-shader/src/emit/lower.rs) refused it as "a pixel system input". This PR reads it with dx.op.coverage.i32 (opcode 91, ReadNone) in the entry block. In emit (emit/mod.rs) it also drops pixel signature elements of kind 14, which is DXIL's Coverage semantic kind and matches how this file already uses 13 for IsFrontFace and 16 for Target, because DXIL does not put SV_Coverage in the input signature. I checked that the test helper emit_pixel runs the module through dxil.dll when one is present, so the new test also validates the coverage read, not only the empty ISG1.

Notes:

  • The test does not check the value read on a GPU. Issue #1530 describes a branch with a D3D12 draw-and-readback test for the same change. Bringing that test over would make this stronger.
  • Fixes #1530.

CI: no check runs on this head. The author reports the new test passing on Windows (RTX 5060 Ti).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156878383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1886#issuecomment-7156878383). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:19:11Z. --- <!-- victory-triage v1 head=77329c18dc8b2f8d2a60d6b7a2ec367d43fd34e0 verdict=merge-candidate at=2026-11-25T08:18:59Z --> Automated triage for the maintainers. **Merge candidate.** `io::raise` on main already maps `SPI_PS_INPUT_ADDR` bit 14 to `Input::SampleCoverage`, but `Lower::input` (`crates/victory-shader/src/emit/lower.rs`) refused it as "a pixel system input". This PR reads it with `dx.op.coverage.i32` (opcode 91, ReadNone) in the entry block. In `emit` (`emit/mod.rs`) it also drops pixel signature elements of kind 14, which is DXIL's Coverage semantic kind and matches how this file already uses 13 for IsFrontFace and 16 for Target, because DXIL does not put SV_Coverage in the input signature. I checked that the test helper `emit_pixel` runs the module through `dxil.dll` when one is present, so the new test also validates the coverage read, not only the empty ISG1. Notes: - The test does not check the value read on a GPU. Issue #1530 describes a branch with a D3D12 draw-and-readback test for the same change. Bringing that test over would make this stronger. - Fixes #1530. CI: no check runs on this head. The author reports the new test passing on Windows (RTX 5060 Ti). --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 12:03:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T11:46:45Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 77329c18 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161487827 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1886#issuecomment-7161487827). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T11:46:45Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 77329c18 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 22:04:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:03:36Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing as a duplicate of #1686, which makes the identical change in Lower::input and emit_with and adds a GPU draw-and-readback test of the value. The two conflict on the same lines. The change itself is right.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175883335 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1886#issuecomment-7175883335). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:03:36Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing as a duplicate of #1686, which makes the identical change in `Lower::input` and `emit_with` and adds a GPU draw-and-readback test of the value. The two conflict on the same lines. The change itself is right. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
upstream-sync closed this pull request 2026-11-25 23:03:19 +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!1884
No description provided.