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

Closed
github-bot wants to merge 1 commit from gh-pr/1886/head into gh-pr/1886/base
Owner

@⁠n-romanovich on GitHub · 2026-11-25 00:04 UTC · original
n-romanovich:fix/shader-ps-coverage → main · +42 −0 · 2 files · 1 commits · closed without merging

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).
**@⁠n-romanovich** on GitHub · 2026-11-25 00:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1886) `n-romanovich:fix/shader-ps-coverage` → `main` · +42 −0 · 2 files · 1 commits · closed without merging 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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:38 +00:00
github-bot closed this pull request 2026-11-26 04:47:38 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:19 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 08:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1886#issuecomment-7156878383) <!-- 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)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 11:46 UTC · original

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

**@⁠sinan-cmyk** on GitHub · 2026-11-25 11:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1886#issuecomment-7161487827) ### 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:03 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1886#issuecomment-7175883335) 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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1886
No description provided.