Skip to content

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

Open
Calvix2k wants to merge 2 commits into
Marvisak:mainfrom
Calvix2k:codex/shader-ps-coverage-1530
Open

Calvix2k wants to merge 2 commits into
Marvisak:mainfrom
Calvix2k:codex/shader-ps-coverage-1530

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

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.

@Calvix2k

Copy link
Copy Markdown
Contributor Author

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.

@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 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

Copy link
Copy Markdown
Contributor Author

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

upipibi commented Nov 24, 2026

Copy link
Copy Markdown

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.

@Calvix2k
Calvix2k force-pushed the codex/shader-ps-coverage-1530 branch from 14ca121 to 16ce8f3 Compare November 25, 2026 02:24

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@StExpeditus

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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.

kilvynsilveira-tech added a commit to kilvynsilveira-tech/VIctory that referenced this pull request Nov 26, 2026
Model the full COMPUTE_PGM_RSRC2.TG_SIZE_EN layout ({first_wavefront, 14'b0, wave_id[10:0], wave_count[5:0]}), lower s_get_waveid_in_workgroup in compute and mesh stages, and share wave_id() with MergedWaveInfo. Drop SampleCoverage in favour of Marvisak#1686.
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.

6 participants