Repository navigation
D3D12.X: command list #142 applies the quad sample mask (XCL_SAMPLE_MASK=1) - #3076
Draft
CharlyRien wants to merge 1 commit into
Draft
CharlyRien wants to merge 1 commit into
CharlyRien wants to merge 1 commit into
Conversation
|
Tested Clean detached
7 passed, 0 failed, 0 ignored, 0 skips. All native processes and the Arc wrapper exited 0. The executable SHA-256 held before, under, and after the lock. Not tested Hardware MSAA, end-to-end command-list-to-GPU wiring, the runtime enable switch, retail smoke, and the full suite. AI use T3 Code / Codex ( |
Kalmarv
added a commit
to Kalmarv/xcl
that referenced
this pull request
Nov 28, 2026
Command list xcl-dev#142 of the newer layout (SetQuadSampleMaskX, a stub so far) gets a handler that only counts: its calls, those with a mask other than all ones, and the title's graphics work recorded while such a mask is current on its list (direct draws, DispatchMesh, and graphics ExecuteIndirect calls by kind, each once at the title's call). One tally line every ten seconds of graphics work, so a window without use reads as zeros. Nothing is applied: no shader, io or state change. It answers whether xcl-dev#3076 has anything to act on in a title before that PR's shader change is tried. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…AMPLE_MASK=1) The newer layout's command list xcl-dev#142, SetQuadSampleMaskX(u64), takes the two PA_SC_AA_MASK registers: 16 sample bits for each pixel of a 2x2 quad (X0Y0, X1Y0, X0Y1, X1Y1 from bit 0). A retail title sets it per draw from dithered fade tables (0 to 4 pixels of the quad, each 0 or 0xFFFF, and the complement for the other side of a cross-fade). As a stub every pixel is drawn, so LOD cross-fades draw both levels whole. The name is the one xcl-dev#1274 gives the slot (a no-op there). Host (hle/d3d12x/quad_mask.rs, bind.rs): the handler keeps the mask per list as the samples it takes away; bind_abi writes them into io slots 117 / 118 (recomp::IO_QUAD_KILL) of graphics draws, only when the mask is partial; reset and ClearState go back to all ones, a mid-list split inherits it. Older layout: xcl-dev#142 is another method, answered as the stub did. Off unless XCL_SAMPLE_MASK=1: off, the io slots stay 0 and nothing is discarded. Translator: every pixel shader starts (before its EXEC is taken) with the test. HLSL: one uniform branch on the two io words, then a discard of the pixel whose quad word is all ones. Direct DXIL: the same straight-line, one conditional discard. No pixel shader on main has early depth; one that gets it must not get this test (the discarded pixels' depth would still be written). Tests: mask decoding and the title's masks, the slot, the io wiring across reset / ClearState / split, the HLSL text and the direct path's discards, and a GPU draw through both paths with each kind of mask. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CharlyRien
force-pushed
the
pr/quad-sample-mask
branch
from
November 28, 2026 05:05
4c6207d to
0bab2ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Command list #142 of the newer console layout,
SetQuadSampleMaskX(u64), is a stub onmain: every pixel is drawn. The u64 is the twoPA_SC_AA_MASKregisters, 16 sample bits for each pixel of a 2×2 quad. A retail title sets it per draw from dithered fade tables (0 to 4 pixels of the quad, each 0 or 0xFFFF, and the complement for the other side of a cross-fade), so LOD cross-fades draw both levels whole instead of a dither pattern. This applies the mask in the translated pixel shaders, behindXCL_SAMPLE_MASK=1(off by default). The slot's name is the one #1274 gives it (a no-op there).What is in it (one commit)
crates/xcl/src/hle/d3d12x/quad_mask.rs(new): the Pr/newer title startup #142 handler (newer layout only; on the older one Pr/newer title startup #142 is another method, answered as before), the mask kept per list as the samples it takes away, the switch, a log line at the first call and counts at powers of two from 1024.crates/xcl/src/hle/d3d12x/bind.rs: the list's mask; reset andClearStatego back to all ones, a mid-list split inherits it;bind_abiwrites it into io slots 117 / 118 of graphics draws only when it is partial.real.rs: the slot.crates/xcl/src/gpu/recomp/mod.rs:IO_QUAD_KILL = [117, 118](trap-temp SGPR slots; 113 is left for D3D12.X: dispatches of more than 65 535 groups in X are folded into Y #1428, 114..116 aremain's DispatchX thread limits).crates/xcl/src/gpu/recomp/emit.rs(HLSL) andcrates/xcl/src/gpu/dxil/lower_gfx.rs(direct DXIL): every pixel shader starts, before its EXEC is taken, with the test: HLSL one uniform branch on the two io words, then a discard of the pixel whose 16 bits are all taken away; direct DXIL the same straight-line with one conditional discard. With the switch off the io words are 0 and nothing is discarded, but the text of every pixel shader changes, so the translator identity changes.mainhas early depth. One that gets it (Recompiler: console pixel shaders tested depth-first keep early depth #2181) must not get this test: the depth of the discarded pixels would still be written. The comment at the test says so.ClearState/ split; the HLSL text and the direct path's discards (dxil::core_tests); a GPU draw through both paths with each kind of mask, 16×16 pixels compared (recomp::tests::gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_away).346 added lines, 3 removed, about 150 of them tests.
Tested
0bab2ef(rebased ontomaine429936). RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631, Rust 1.100.0, debug for the suite, release for the smoke runs.cargo test --workspace --no-fail-fast -- --test-threads=4: 2133 passed, 9 failed, 48 ignored. The 9 are the 9 testsmaine429936itself fails on a GPU since the last merges, the same names as in this report on an RTX 4080 (2126 passed there; this PR adds 7 tests): threegpu::dxil::module::splitdispatch-chain tests,gpu_heap_flat_reads_match_guarded_and_root_output,gpu_compute_mode_dispatch_abi,gpu_float_cas_uses_ieee_equality, and three e2e test-title runs. The 7 tests of this PR passed, among them the GPU one,recomp::tests::gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_away(both paths, each kind of mask, 16×16 pixels compared).SKIPPEDon this adapter: 25 lines. 21 are "no wave64" (8 with that reason alone, 13 inlower_dxil::testswith the part named, e.g. "f32 arithmetic, wave64: no wave64"); 3 are the per-lane form refusing f16 / packed f16 / f32-to-f16 conversions ("its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's"); 1 isheap_window_out_of_memory_falls_back_to_the_switch_form("no heap windows"). None is a test of this PR.main's own build error (E0451, a private field ofConfigused by a test), the same onmaine429936; the earlier failure on4c6207dwas the known flakyfine_timer_makes_short_sleeps_short.4c6207donmain2c717a0): the suite gave 1473 passed, 0 failed, 47 ignored, and a run withXCL_SAMPLE_MASK=1had no device removal and no crash; in it the title only set an all-ones mask (1024 calls, 0 partial, no count line at 2048), so nothing was discarded: that run checks that the switch is harmless, not that the fades are right.xcl-smoke block of the XCL_SAMPLE_MASK=1 run (4c6207d)
Regression run
maine429936and this PR's head0bab2ef, same machine, same title, 200 s, the same scripted A presses (XCL_PRESS_A_AT),XCL_PREPARE=0,XCL_SAMPLE_MASKunset, both throughmain'sscripts/smoke.ps1, each starting from its own copy of the same shader cache (made by anothermaincommit, so cold for both).main:
this PR's head:
No device removal and no crash on the head. Its frames are 75.8 % of
main's, under the 80 % of CONTRIBUTING, so this stays a draft. The whole difference is in the first 25 s:mainpresented 603 frames there, the head none. After 25 s the two runs are within about 2 % (1,795 frames against 1,838).What the logs show about those 25 s: at start the background pipeline builders spent 21 to 24 s each in the driver on a few large compute pipelines ("slow driver compile" lines), and the first frame came at about 28 s. That is not specific to this PR:
main's own first run of this build (below,116g1) shows the same slow driver compiles at 25.7 s and its first frame at 28.2 s. Onlymain's second run (the pair above) started fast: its third run, with the cache the second one filled, had the slow start again (2 presents in the first 25 s, 1,744 frames in all, 71 % of the second). A second run of the head with the cache its first run filled (below) had the slow start too (1,751 frames). Why one run starts fast and another does not is not known; on this machine it movesmain's own 200 s total between 1,744 and 2,442 frames. This PR changes only pixel shaders (and the translator identity); the slow pipelines are compute pipelines.The other runs (same setup)
maine429936, its first run (frames 1908; a compile of another branch ran on the same machine during its first 95 s, so it is not a clean reference):this PR's head, second run, with the cache its first run filled:
maine429936, third run, with the cache its second run filled:Not tested
AI use
🤖 Generated with Claude Code