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

Open
Calvix2k wants to merge 3 commits from upstream-pr/1686 into main
Calvix2k commented 2026-11-24 20:45:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T20:45:11Z.


Implements #1530.

Ports the fix from @davi713albano-coder's fork (commit c0f6d69 by Davi713), applied unchanged onto ffe310e; the commit keeps its original author.

Summary

io::raise already lifted SPI_PS_INPUT_ADDR bit 14 to Input::SampleCoverage, but emit::lower refused it as "a pixel system input".

  • Input::SampleCoverage now lowers to DXIL dx.op.coverage.i32 (opcode 91, ReadNone).
  • SV_Coverage (kind == 14) is stripped from the pixel ISG1 before emission when a console container lists it there, since DXIL declares it NotInSig for pixel inputs.

Test

New synthetic pixel-shader test ps_sample_coverage_input_reads_coverage_mask: SPI input bit 14, ISG1 stripping, dxil.dll validation and container hash, plus a live D3D12 draw readback on a 1x target asserting the covered pixel reads the full mask.

Validation

  • cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests — passed (102 tests, 1 ignored).
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings — passed.
  • cargo xtask policy — passed (154 files).
  • Upstream fork CI ran the full workspace including the new WARP draw test: 343 passed, 0 failed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5480032886 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T20:45:11Z. --- Implements #1530. Ports the fix from [@davi713albano-coder's fork](https://github.com/Marvisak/VIctory/compare/main...davi713albano-coder:VIctory:shader/ps-coverage-input) (commit c0f6d69 by Davi713), applied unchanged onto `ffe310e`; the commit keeps its original author. ## Summary `io::raise` already lifted `SPI_PS_INPUT_ADDR` bit 14 to `Input::SampleCoverage`, but `emit::lower` refused it as "a pixel system input". - `Input::SampleCoverage` now lowers to DXIL `dx.op.coverage.i32` (opcode 91, `ReadNone`). - `SV_Coverage` (`kind == 14`) is stripped from the pixel `ISG1` before emission when a console container lists it there, since DXIL declares it `NotInSig` for pixel inputs. ## Test New synthetic pixel-shader test `ps_sample_coverage_input_reads_coverage_mask`: SPI input bit 14, `ISG1` stripping, dxil.dll validation and container hash, plus a live D3D12 draw readback on a 1x target asserting the covered pixel reads the full mask. ## Validation - `cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests` — passed (102 tests, 1 ignored). - `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings` — passed. - `cargo xtask policy` — passed (154 files). - Upstream fork CI ran the full workspace including the new WARP draw test: 343 passed, 0 failed.
catminou4 commented 2026-11-24 21:40:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:09Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.

PS SV_Coverage input lowered via dx.op.coverage: ps_sample_coverage_input_reads_coverage_mask renders and checks the coverage mask per sample.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047849148 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#pullrequestreview-6047849148). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:40:09Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests. PS SV_Coverage input lowered via dx.op.coverage: ps_sample_coverage_input_reads_coverage_mask renders and checks the coverage mask per sample.
Calvix2k commented 2026-11-24 22:02:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T21:39:46Z.


Hardware run on head of this PR, AMD RDNA3:

  • Windows 10 x64, Ryzen 7 5800X, Radeon RX 7800 XT (driver 32.0.32029.2010), Agility SDK 1.616 locally for SM 6.6.
  • cargo test -p victory-shader --locked ps_sample_coverage_input_reads_coverage_mask -- --test-threads=1 --nocapture — 1 passed, 0 failed on the hardware backend (the 1x coverage readback is correct). WARP skipped at SM 6.2 here.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7145225051 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#issuecomment-7145225051). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T21:39:46Z. --- Hardware run on head of this PR, AMD RDNA3: - Windows 10 x64, Ryzen 7 5800X, Radeon RX 7800 XT (driver 32.0.32029.2010), Agility SDK 1.616 locally for SM 6.6. - `cargo test -p victory-shader --locked ps_sample_coverage_input_reads_coverage_mask -- --test-threads=1 --nocapture` — **1 passed, 0 failed** on the hardware backend (the 1x coverage readback is correct). WARP skipped at SM 6.2 here.
Calvix2k commented 2026-11-24 23:05:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T22:15:02Z.


Rebased onto 70564ae. Conflicts were in the test module only: upstream added its own tests/helpers, and HostShader gained six fields (root_uavs, memory, memory_writes, view_addresses, heap, heap_writes). The test's VS literal now fills them with empty/false; cargo check -p victory-shader --tests passes.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145994815 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#issuecomment-7145994815). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T22:15:02Z. --- Rebased onto 70564ae. Conflicts were in the test module only: upstream added its own tests/helpers, and `HostShader` gained six fields (`root_uavs`, `memory`, `memory_writes`, `view_addresses`, `heap`, `heap_writes`). The test's VS literal now fills them with empty/false; cargo check -p victory-shader --tests passes.
upipibi commented 2026-11-24 23:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:52:00Z.


NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 14ca121 (on main 70564ae). ps_sample_coverage_input_reads_coverage_mask passes on the hardware adapter.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146735695 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#issuecomment-7146735695). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T22:52:00Z. --- NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `14ca121` (on `main` `70564ae`). `ps_sample_coverage_input_reads_coverage_mask` passes on the hardware adapter. AI-assisted (Claude Code). Synthetic tests only.
Marvisak commented 2026-11-25 04:06:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:33:37Z.


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152027649 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#issuecomment-7152027649). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:33:37Z. --- <!-- victory-triage v1 head=16ce8f33c55944aba31f9a370b78b07a897e376b verdict=needs-rebase at=2026-11-25T22:28:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/valu_tests.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
StExpeditus commented 2026-11-25 10:07:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:16:05Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 16ce8f3. cargo test --workspace --locked --no-fail-fast -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158100090 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#issuecomment-7158100090). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T09:16:05Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `16ce8f3`. `cargo test --workspace --locked --no-fail-fast` -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
Calvix2k commented 2026-11-25 11:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T10:14:51Z.


Hardware run on an RX 7800 XT (RDNA3), Windows 10 19045, SM 6.6 through the Agility runtime staged for the test binaries (#486): the whole victory-shader lib suite — 248 passed, 0 failed, 3 ignored — including the coverage lowering and its pixel readback. So the dx.op.coverage path is exercised on the card here, not only on CI's device.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159432963 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#issuecomment-7159432963). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T10:14:51Z. --- Hardware run on an **RX 7800 XT (RDNA3), Windows 10 19045**, SM 6.6 through the Agility runtime staged for the test binaries (#486): the whole `victory-shader` lib suite — **248 passed, 0 failed, 3 ignored** — including the coverage lowering and its pixel readback. So the `dx.op.coverage` path is exercised on the card here, not only on CI's device.
andrewpozdnakov7-jpg commented 2026-11-27 14:40:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T14:40:06Z.


The red check on 0bbde51 stops at Clippy because ps_sample_coverage_input_reads_coverage_mask is missing its #[test] attribute. Commit 3a71a1f adds that one line and fast-forwards this exact PR head.

I ran the same draw fixture on current main (63bcca4) and the follow-up. Main refuses to emit a pixel system input. The follow-up validates with DXIL 1.9.2609.5 and reads back four pixels with coverage mask 1 on app-local WARP 1.0.22. All 36 VALU tests passed, along with strict shader Clippy and the asset policy.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7221073065 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1686#issuecomment-7221073065). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T14:40:06Z. --- The [red check](https://github.com/Marvisak/VIctory/actions/runs/45833426341/job/139955876230) on `0bbde51` stops at Clippy because `ps_sample_coverage_input_reads_coverage_mask` is missing its `#[test]` attribute. [Commit `3a71a1f`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3a71a1f7ad301454803dcbb3ffaeef7d3981d440) adds that one line and fast-forwards this exact PR head. I ran the same draw fixture on current `main` (`63bcca4`) and the follow-up. Main refuses to emit `a pixel system input`. The follow-up validates with DXIL 1.9.2609.5 and reads back four pixels with coverage mask 1 on app-local WARP 1.0.22. All 36 VALU tests passed, along with strict shader Clippy and the asset policy.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1686:upstream-pr/1686'
git switch 'upstream-pr/1686'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1686'
git switch 'upstream-pr/1686'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1686'
git switch 'upstream-pr/1686'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1686'
git switch 'main'
git merge --squash 'upstream-pr/1686'
git switch 'main'
git merge --ff-only 'upstream-pr/1686'
git switch 'main'
git merge 'upstream-pr/1686'
git push origin 'main'
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!1685
No description provided.