Skip to content

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

Closed
n-romanovich wants to merge 1 commit into
Marvisak:mainfrom
n-romanovich:fix/shader-ps-coverage
Closed

n-romanovich wants to merge 1 commit into
Marvisak:mainfrom
n-romanovich:fix/shader-ps-coverage

Conversation

@n-romanovich

@n-romanovich n-romanovich commented Nov 25, 2026 •

Copy link
Copy Markdown

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, 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.

Copy link
Copy Markdown
Owner

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:

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


Generated by Claude Code

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 77329c1 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

Copy link
Copy Markdown
Owner

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 Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shaders: lower pixel shader SV_Coverage input via dx.op.coverage

4 participants