Recompiler: a PS sample mask from exp mrtz is written to SV_Coverage #1342
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1352"
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 emirduran707 on 2026-11-24T15:08:42Z.
A pixel shader's
exp mrtzwas translated only for depth. A sample mask exported in it (z, enable bit 0x4) was dropped, andXclOutnever declaredSV_Coverage, so every covered sample was written. Mesa'semit_ps_mrtz_export(ac_nir_lower_ps_late.c) gives the layout: depth in x, stencil in y, sample mask in z for the 32-bit Z formats; for the compressed format, stencil in VSRC0 [31:16] and the mask in VSRC1.When the output signature has
SV_Coverage(system value 66) and anexp mrtzactually enables component 2,XclOutdeclaresSV_Coverage,maininitialisesxo.xcl_mask = 0xFFFFFFFFu, and the mrtz export writes component 2 into it throughexp_comp(so the compressed form givesVSRC1 & 0xFFFF; a mask fits in 16 bits). If the signature hasSV_Coveragewithout an export writing it,SV_Coverageis not declared so samples are not zeroed out.What is in it
crates/xcl/src/gpu/recomp/emit.rs: trackps_writes_maskonexp mrtz, declareSV_Coverageonly when written, omitxcl_unusedwhenSV_Coverageis the only output, and initialisexo.xcl_mask = 0xFFFFFFFFu.crates/xcl/src/gpu/recomp/tests.rs:ps_mrtz_sample_mask_writes_sv_coverage, which compiles through DXC when present. It covers uncompressed and compressed exports,SV_Coveragein the signature without anmrtzmask write, a coverage-only PS, a PS withoutSV_Coverage, and a depth-only PS.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on6dbae61(rebased ontomain2aa2d1a): 1136 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record)gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) fail identically on unmodifiedmain2aa2d1aon this GPU (seeds 722 and 1599).ps_mrtz_sample_mask_writes_sv_coveragefailed before theps_writes_mask/0xFFFFFFFFufix; passes afterRegression run
main:
this PR:
Not tested
SV_StencilRef(y of the same export) is still not written: it needsPSSpecifiedStencilRefSupported, which XCL does not query yet, and declaring it unconditionally could stop pipelines on adapters without it.AI use
SV_Coveragereview finding, extended the unit test, ran the updated test suite and smoke run, and updated this description.main2aa2d1a(a conflict incrates/xcl/src/gpu/recomp/emit.rs; main's newhas_ps_vmfield and this PR'sps_writes_maskboth kept) and reran the suite and smoke runs above.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:15:41Z.
Full-suite run, since this PR has no test report yet. Tested exact head
8bb3f12(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.ps_mrtz_sample_mask_writes_sv_coverage.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:18:00Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (One run showed a single flaky failure / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by kacper-serewis on 2026-11-24T20:18:52Z.
Per-sample GPU readback for this PR, plus one case that fails on
8bb3f12:SV_Coveragein the signature but not written by the export drops every sample.Tested: RTX 5070, driver 32.0.16.1656, Windows 11, debug. Wrong pixels out of 256:
930e8b48bb3f12exp mrtzz, uncompressedSV_Coveragein the signatureSV_Coveragein the signature, mrtz EN=0x1 (mask channel not written)Cause of the last row:
xcl_mask : SV_Coverageis declared whenever the signature has it, andXclOut xo = (XclOut)0leaves it 0. Suggested: declare it only when a mask write is emitted, and start it at all ones, so a live path around the export keeps its samples:With it on
8bb3f12all five rows are 0. (The path around the export is not among the draws.)Fixture: one full-target triangle into a 16x16 R8G8B8A8_UNORM target with 4 samples, cleared to 0. The PS exports 1.0 to target 0 and, through mrtz, a mask equal to the pixel's x (0-15), with -1 in the other mrtz sources. A compute shader reads each sample with
Texture2DMS.Loadand packs the written ones into a 4-bit mask per pixel. Expected: x in the three mask cases, 0xF in the other two. The full test is available on request.Not tested: direct DXIL, native wave64 (this GPU has 32-lane waves only), AMD.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment; the suggested change is adapted from one written with T3 Code (gpt-6.2-astra). I checked the points before posting.
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T21:21:23Z.
Fixed in
50f7106(squashed and force-pushed), following your suggestion:Emnow tracksps_writes_maskwhen anexp mrtzenables component 2 for an output signature containingSV_Coverage.XclOutdeclaresuint xcl_mask : SV_Coverage;only whenps_writes_maskis set (and skipsxcl_unusedwhenSV_Coverageis the only output).maininitialisesxo.xcl_mask = 0xFFFFFFFFu;right afterXclOut xo = (XclOut)0;so live paths that bypass themrtzexport keep their samples.Extended
ps_mrtz_sample_mask_writes_sv_coverageto check both theSV_Coverage-in-signature-without-write (EN=0x1) case and the0xFFFFFFFFudefault init; it compiles through DXC and passes, and the full workspace suite passes on50f7106(752 passed, 0 failed, 41 ignored).AI use: Antigravity with Gemini 4 Neon applied the fix, extended the test, ran the suite/smoke, and wrote this reply.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:53:55Z.
Tested
I ran
ps_mrtz_sample_mask_writes_sv_coverageon PR #1352 at clean detached head6dbae6165aae2832782a4ec0b3cbcd3d2dcd7c92. The PR was open at that same head before and after the run.1 passed, 0 failed, 0 ignored, 0 skipped (1,114 filtered out, 0.15 s test time, Cargo exit 0). The test process logged that it loaded
dxcompiler.dllanddxil.dll1.9.2609.5 fromXCL_DXC_DIR. The successful load enables the test'sps_6_6compilation branch, and all six fixture translations completed and compiled successfully.mrtzwrites the mask fromVSRC2withEN=0x4. Compressedmrtztakes the low 16 bits ofVSRC1withEN=0xC. Both check the all-ones coverage default.SV_Coverageand omits the dummy target. The depth-onlymrtzpreserves theSV_Target0andSV_Depthinterface and writes depth fromVSRC0, with no coverage field.Windows 11 Enterprise Evaluation 26200.9974, Ryzen 7 3800X, Rust and Cargo 1.100.0 (
x86_64-pc-windows-msvc), unoptimized test profile. Host inventory includes Intel Arc A770 with driver 32.0.101.9175. Process settings wereXCL_ADAPTER=A770,XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0,CARGO_TARGET_DIR=L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target, andTEMP=TMP=L:/XclTooling/pr1352/temp.Not tested
GPU execution, draw or per-sample coverage readback, direct DXIL translation, release builds, the full suite, and retail-title smoke runs.
AI use
T3 Code / Codex (gpt-6.2-sol) ran the test, checked the log and PR revision, and wrote this report.
upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T10:25:28Z.
Independent Windows run on 6dbae61. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11.
cargo build --workspace --offline --locked -j 4passed.cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4finished with 1138 passed, 0 failed, 46 ignored, including 25 runtime skips in Cargo’s pass count.I drew the translated shaders into a 4× MSAA target and read each sample separately with
Texture2DMS.Load. On a 4×4 target, the uncompressed export wrote samples 0 and 2, and the compressed export wrote 1 and 3. A coverage signature with no mask write kept all four samples. A written zero mask suppressed all four. The case without a coverage signature kept all four, and a hand-written HLSL control produced the expected 0-and-2 pattern. All 384 sample reads matched. Removing the coverage signature from the uncompressed fixture while still expecting its mask made the check fail at sample 1, which was now written. The control edit was restored.cargo test --offline --locked -j 4 -p xcl --lib local_mrtz_mask_reads_back_each_msaa_sample -- --nocapture --test-threads=1passed 1 of 1 without skips. Synthetic native D3D12, using the HLSL translation path.AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:03:15Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin