Recompiler: export SV_Coverage from exp mrtz in direct DXIL pixel shaders #3252
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3252"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T01:05:06Z.
What is in it
Exports
SV_Coverage(SemKind::Coverage, system value 66) fromexp mrtz(tgt == 8) channel 2 in the direct DXIL pixel shader lowerer (crates/xcl/src/gpu/dxil/lower_gfx.rs), matching the existing IR-path behavior (emit.rs). Handles both uncompressed (VSRC2) and compressed (VSRC1[15:0])mrtzexports, lazily declares theSV_Coverageoutput signature element only when the pixel shader actually writes sample mask (preserving early-Z for shaders that do not), and default-initializes the mask to0xFFFFFFFFif a path does not write it. Adds a unit + DXC-validation + GPU-draw test incrates/xcl/src/gpu/dxil/core_tests.rs.Tested
cargo test -p xcl --lib direct_pixel_shader_exports_sv_coverage_from_mrtzpassed (validates generated DXIL with DXC1.9.2609.5and executes a real D3D12 draw on NVIDIA GeForce RTX 5070 Ti comparing against HLSL reference for bothmask = 0andmask = 0xFFFFFFFF).xcl-smokeregression run below on NVIDIA GeForce RTX 5070 Ti (0device removals,0crashes).Regression run
Baseline (
mainancestorf0e8fdd5c3942ddd399d5ee11384c8595c5aacff):PR branch (
638368431945303a576a8eea067f21767aa630f3):Not tested
MSAA > 1x) partial bitmask values (e.g.0b0101on 4x MSAA) in a GPU render test; only0x0and0xFFFFFFFFwere verified on 1x RTV.ea3b5e4d.AI use
Drafted, implemented, and tested with an AI coding agent; reviewed and verified by hand against DXC validation, GPU draw comparison, and 150 s smoke logs.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T12:09:16Z.
Ran the
SV_Coveragedirect-DXIL export test atddcd7563on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
The test passes here:
SV_Coverageis exported fromexp mrtzin the direct DXIL pixel-shader path, with DXC validation and a real D3D12 draw. The thread already reports an RTX 5070 Ti run from the author; this adds an independent run on driver 32.0.16.2140. I did not repeat the smoke run.Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T14:57:00Z.
Note: since this run the PR conflicts with main (
3b6a91ed). The result above is for this head merged onto the base named above.Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s
scripts/smoke.ps1run of a retail title against main on the same machine. The 4fuzz_validate_and_gpu_*failures happen on main on this machine too.Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T15:42:41Z.
Re-ran the
SV_Coverageexport test at63836843after the head moved fromddcd7563; this is a new response in the same thread, not an edit of my earlier report: https://github.com/xcl-dev/xcl/pull/3252#issuecomment-7255604967Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
The test still passes at the new head:
SV_Coverageis exported fromexp mrtzin the direct DXIL pixel-shader path, with DXC validation and a real D3D12 draw. This adds the new head and driver 32.0.16.2140 as dimensions. Synthetic draw only, no title run.Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:43:38Z.
merge-check
base:
d0832e614fhead:
6383684319merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: re-review (my earlier merge-check was on
ddcd7563). Since then the PR was only rebased (fa204595->24d21a41); the changed lines are identical. It changes the default direct DXIL path: a PS whose signature declares output 66 and writes mrtz channel 2 now outputs SV_Coverage (all ones by default, written only in active lanes), the dummy SV_Target7 always writes 0, andexp mrt7no longer reaches it, a faithful copy of the HLSL path (emit.rs ~2418-2424, ~5601-5611); the compressedVSRC1[15:0]form matches Mesa's layout. Findings: (1) it conflicts with #3296 (SV_StencilRef), which edits the sameany/ dummy-target lines and mrtz arm; whichever merges second needsstencil_ref.is_none()in the dummy-target condition (lower_gfx.rs ~276). (2) #2358 is an older draft duplicate that no longer merges. (3) The compressed mrtz case is only checked through the signature, and the draw covers only masks 0 and all ones at 1x MSAA. (4) AI use names no model; Tested has no suite counts. Fine: the unit asserts fail on main without a GPU, the draw part goes throughdraw_ready()/skip_test, and nothing is#[ignore]d.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (d237bd56): 1516 -> 1457 frames shown (96 %; last presents per 2 s: 60 61 60), peak commit 18133 -> 16444 MB, 0 device removals, 0 crashes.verdict: safe to merge (whichever of this and #3296 lands second needs stencil_ref.is_none() in the dummy-target condition; #2358 is an older duplicate)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by cj-tomlin on 2026-12-01T19:17:42Z.
merge-check claim
head:
6383684319Imported from ivall/xcl. Originally posted by cj-tomlin on 2026-12-01T19:23:08Z.
merge-check
base:
6bfb5c5153head:
6383684319merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2904 passed, 1 failed, 51 ignored; SKIPPED: 27 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll); failing:
gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs, which fails on the base too on this machine (6 of 6 runs alone onmain6bfb5c51today); this PR does not touch that path. The newdirect_pixel_shader_exports_sv_coverage_from_mrtzpasses with its DXC validation and GPU draws (also withXCL_REQUIRE_GPU=wave64, so the draw part did not skip), and fails at its first signature assertion withmain'slower_gfx.rs.review: none blocking, after reading the whole diff (+130/-9,
lower_gfx.rs,core_tests.rs). A PS whose signature declares output 66 now outputsSV_Coveragefromexp mrtzchannel 2 (VSRC2, orVSRC1[15:0]compressed), all ones until written, and declares it only when the shader writes the mask; the dummySV_Target7moves to the end of the shader and is added only when there is no target, no depth and no mask, always 0, soexp mrt7no longer reaches it. That matches the HLSL path. It changes the default direct DXIL translation of such shaders. Not blocking: (1) it conflicts with open #3296 (SV_StencilRef) on the same lines: whichever lands second needsstencil_ref.is_none()in the dummy-target condition; (2) the draw covers masks 0 and all ones at 1x MSAA only, and the compressed form is checked through the signature only; (3) the PR's AI use names no model and Tested has no full-suite counts. Ran on NVIDIA (wave32) only: AMD's native wave64 path is not covered here, though the change is in signature and export handling, not in wave-size code.performance: no measured run. By default one more temporary per PS and an
SV_Coveragestore only in shaders that write the mask; shaders that do not keep early-Z (reasoned).verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB, driver 621.40, AMD Ryzen 7 7800X3D, Windows 11 build 26300, debug build / Claude Code (Claude Opus 5.5) merged, built, ran the suite, read the diff and drafted this; I checked it.