D3D12.X: command list #142 applies the quad sample mask (XCL_SAMPLE_MASK=1) #3076
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3076"
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 CharlyRien on 2026-11-27T22:14:55Z.
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 (two commits)
First commit:
crates/xcl/src/hle/d3d12x/quad_mask.rs(new): the #142 handler (newer layout only; on the older one #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 119 / 120 of graphics draws only when it is partial.real.rs: the slot.crates/xcl/src/gpu/recomp/mod.rs:IO_QUAD_KILL = [119, 120](trap-temp SGPR slots, aftermain's 113–118:IO_LOOP_BUDGET,IO_GROUP_LIMIT,IO_THREAD_LIMIT115–117,IO_MESH_GROUP_BASE118; belowKERNEL_SCC_SLOT, 125).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 (the direct path'searly_depth_stencilflag exists, every caller passes false). One that gets it (#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).Second commit (from Eterst's test in this thread): every console mesh pipeline on
mainhas a two-pass form, whose mesh pass builds its io inprepare_two_pass_stage(two_pass_io), not throughbind_abi, so withXCL_SAMPLE_MASK=1none of those draws was masked. The mesh pass (not the compute pass) now writes the list's mask intoIO_QUAD_KILLasbind_abidoes. Eterst measured it on an RTX 4070 SUPER, a retail title's world: 0 masked draws without it, 19,494 with it, in 300 s.+360 / −7 in 9 files for the two commits.
Tested
13a94c5onmain0fe06eb(rebased 29/11 evening; one conflict, ingpu/dxil/core_tests.rsonly:mainhad added a test where this PR addsquad_sample_mask_starts_pixel_shaders_on_both_paths, both kept;main's io slots checked again, still nothing at 119 / 120,IO_MESH_GROUP_BASE= 118 is the last). RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631; Rust 1.100.0, release tests.cargo check --release -p xcl --lib --bins: passes, the same 38 warnings asmain0fe06eb; the test build has the same 18 warnings asmain0fe06eb(no new one).XCL_ADAPTER=warp, so the GPU tests, the GPU drawgpu_quad_sample_mask_discards_the_quad_pixels_it_takes_awayamong them, run on WARP or skip;XCL_REQUIRE_GPUunset; the tests that open the hardware adapter whateverXCL_ADAPTERsays left out with--skip):cargo test --release -p xcl --lib -- gpu::recomp::tests hle::d3d12x::quad_mask hle::d3d12x::real::readback_routing_tests gpu::dxil::core_tests hle::d3d12x::bind::tests shaders::pipeline_library::tests shaders::warm_library::tests --test-threads=4: 370 passed, 6 failed, 19 ignored; 155 of the passes are tests that skipped (no GPU, or no mesh shaders on WARP), the GPU draw among them. The 6 failures are 5shaders::pipeline_library::testsandshaders::warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable:CreateComputePipelineStatereturns E_INVALIDARG on this machine's WARP, which has no SM 6.6. That is a local artefact of a WARP run here. This PR's 7 tests passed: the 3quad_masktests,list_142_sets_the_quad_sample_mask,quad_sample_mask_reaches_the_io_of_the_lists_draws,quad_sample_mask_starts_pixel_shaders_on_both_paths, and the GPU draw (skipped: no GPU).main0fe06eb: 363 passed, the same 6 failed with the same error, 19 ignored. The difference is this PR's 7 tests.XCL_REQUIRE_GPU=mesh, release):cargo test --release -p xcl --lib -- d3d12x::quad_mask:: list_142_sets_the_quad_sample_mask quad_sample_mask_reaches_the_io_of_the_lists_draws quad_sample_mask_starts_pixel_shaders_on_both_paths gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_away --test-threads=1: 7 passed, 0 failed, 0 ignored, noSKIPPEDline: this PR's 7 tests, the GPU drawgpu_quad_sample_mask_discards_the_quad_pixels_it_takes_awayamong them (run on the card, not skipped).ccd6134: a four-draw mask sequence on a 4× MSAA target against a native reference shader, both backends, switch off and on: every resolved pixel matched.4c6207d: the GPU draw test and 6 host tests, 7 passed.0bab2efonmaine429936.cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 2133 passed, 9 failed, 48 ignored. The 9 are the 9 testsmaine429936itself failed on a GPU, the same names as in this report on an RTX 4080. The 7 tests of this PR passed, the GPU draw among them (both paths, each kind of mask, 16×16 pixels compared).4c6207donmain2c717a0): 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), 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
Same machine as under Tested, same title, 60 s each (the
scripts/smoke.ps1default), both throughmaind52ff48'sscripts/smoke.ps1,XCL_PREPARE=0, the same scripted A presses (XCL_PRESS_A_AT),XCL_SAMPLE_MASKunset. Each run started from its own copy of the same shader cache, made by anothermaincommit, so cold for both. The head is onmain0fe06eb; themainrun is ofmaind52ff48(the newestmaintoday, 170 commits later), not of the head's base: the check asks for a commit ofmain.maind52ff48:this head
13a94c5(main0fe06eb+ this PR's two commits):main's 517 (116.6 %; the check wants at least 80 %), peak commit 15,349 MB against 15,968 MB (96.1 %; at most 125 %). Last three 2 s slices: head 61 60 61,main61 60 61 presents. 60 s covers the start of the title, not a long stay in its world.maind52ff48, so the difference between the two runs includes those commits, not only this PR.The earlier pair (200 s, earlier head
0bab2efon maine429936)Earlier pair: 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:
earlier head
0bab2ef:main's, under the 80 % of CONTRIBUTING. 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).main's own runs of this build gave 1,908, 2,442 and 1,744 frames; a second run of the head with the cache its first run filled gave 1,751.main's own first run of this build shows the same slow driver compiles at 25.7 s and its first frame at 28.2 s; only its second run (the pair above) started fast.The other runs of that 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):earlier head
0bab2ef, second run, with the cache its first run filled:maine429936, third run, with the cache its second run filled:Not tested
XCL_SAMPLE_MASK=1(the regression run above has it unset), and the whole suite on a GPU on this head (only this PR's tests ran on the GPU).AI use
AI use: working out the call's meaning from the values the title passes, the code, the tests, the two-pass commit, the rebases, the test, title and smoke runs and this description were done with Claude Code (Claude Opus 5.5), checked and posted by me.
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T22:49:35Z.
Tested
Clean detached
4c6207dfb0f75c36d4534a9e7bb4bede8532735don Windows 11 build 26200, Ryzen 7 3800X, Intel Arc A770 (8086:56a0, driver 32.0.101.9175), Rust 1.100.1 MSVC, and DXC/DXIL 1.9.2602.17. I reran the pinned stock test executable with--exact --nocapture --test-threads=1.gpu::recomp::tests::gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_awaypassed six masks per path on HLSL-to-DXIL and direct DXIL, for 12 single-sample draws and 3,072 RGBA pixel comparisons. The fixture injected the mask words into shader I/O and checked expected white or clear-blue output. The Arc probe identified the A770 and the stock runner usedXCL_ADAPTER=A770through its hardware-only named selector.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 (
gpt-6.2-sol) independently reran the stock fixtures and wrote this report.Imported from ivall/xcl. Originally posted by Eterst on 2026-11-28T18:53:07Z.
A test of this change in the world of the retail title, plus two things a port to
nvidia-devwill need (many of the #505 testers run that branch).Setup: RTX 4070 SUPER 12 GB (driver 621.40), Ryzen 7 5700X, 32 GB RAM, Windows 10 19045, Rust 1.100.0, release. A local test tree (
mainof 11-27 plus a two-pass mesh path likenvidia-dev's), with this PR's commit applied by hand. One run of each, 300 s, the same scripted A presses.The title does set partial masks in the world. Your 200 s run saw only all-ones masks; past the loading screens they come:
XCL_SAMPLE_MASKunsetXCL_SAMPLE_MASK=1XCL_SAMPLE_MASK=1+ the two-pass fix below1. Two-pass mesh draws don't get the mask. On
nvidia-devevery console mesh pipeline is two-pass, andbind_two_pass_stagebuilds its io withtwo_pass_io, not throughbind_abi. Soquad_kill_ionever runs for those draws: that's the 0 in the second row. Three lines inbind_two_pass_stage, after itstwo_pass_io(...)call, gave the third row:(
with(this, …)is the list's bind state, as inbind_abi.)2. The io slots are taken on
nvidia-dev. ThereIO_THREAD_LIMITis[115, 116, 117]andIO_MESH_GROUP_BASEis118(gpu/recomp/mod.rs), soIO_QUAD_KILL = [117, 118]would overlap both. Slots 119 to 124 are free on that branch. Onmain117 and 118 are free, as the PR says.Not judged yet: whether the dithered fades now look right. In these runs the comparable scenes were dominated by draws skipped while their pipelines were built cold, so the frames can't settle it. A run with warm caches is next.
AI use: Claude Code (Claude Opus 5.5) ported the change, made the two-pass addition, ran the title and wrote this comment.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-28T23:26:59Z.
Rebased on
main7db2f39(after #3203); headccd6134(2 commits). Tests (cargo test --release -p xcl --lib,XCL_REQUIRE_GPU=mesh,quad_mask,bind,realand the mask tests, the GPU drawgpu_quad_sample_mask_discards_the_quad_pixels_it_takes_awayamong them): 285 passed, 1 failed. The failure,bind::tests::two_pass_binds_set_the_shared_view_heap, fails onmain7db2f39too: a "no heap windows" skip thatXCL_REQUIRE_GPU=meshturns into a failure. The compiler warnings are the same 18 asmain's.What changed in the rebase, both from Eterst's test above (thanks):
mainnow uses 113–118 (IO_LOOP_BUDGET,IO_GROUP_LIMIT,IO_THREAD_LIMIT115–117,IO_MESH_GROUP_BASE118), soIO_QUAD_KILLmoves to 119 / 120 (belowKERNEL_SCC_SLOT, 125). The tests follow.prepare_two_pass_stage, not throughbind_abi; it now writes the list's mask the same way (not the compute pass). This is the change Eterst measured (0 → 19,494 masked draws in 300 s).bind.rswas restructured onmain; the mask's state and io writes were placed again by hand.0bab2ef.main7db2f39itself, run with these filters and those of our other PRs, same setting, has 7 failures, all skips thatXCL_REQUIRE_GPU=meshturns into failures on this card: sixlower_dxil::tests::*_on_the_gpu("…, wave64: no wave64") andbind::tests::two_pass_binds_set_the_shared_view_heap("no heap windows").The branch merges with
main227d2cbwithout conflict (not tested there).Setup: RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631, Rust 1.100.0, release tests,
XCL_REQUIRE_GPU=mesh.AI use: Claude Code with Claude Opus 5.5 did the rebase, added the two-pass commit, ran the tests and wrote this. The person running these tests asked for it.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T23:34:04Z.
On head
ccd6134631fad30fa7fe9ab76dc220dd2f47432a, I compared a four-draw mask sequence on a 4× MSAA target against an independent native pixel shader on RTX 5070, driver 616.92. Both translated backends matched every resolved pixel.The fixture called the newer-layout #142 handler, took snapshots through the list-state and IO-packing helpers, then submitted the four scissored draws on one native command list. For each switch/backend combination I compared the entire resolved 16×16 float target with a native reference shader that selected pixels directly by screen coordinates. Every value was exactly the white draw color or blue clear color. The two checkerboards occupied opposite positions. The enabled and disabled tests ran in separate processes; both passed with zero skips.
These are whole-pixel 0/0xffff masks on a multisampled target. The readback is a hardware resolve, not a per-sample dump. The test uses synthetic tracked list state, normal vertex/pixel draws and the translated shader IO. It does not exercise guest vtable lookup, the two-pass mesh binding path or a retail fade.
AI use: OpenAI Codex adapted the test fixture, ran the GPU comparisons and drafted this report.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-28T23:58:38Z.
@andrewDoing thanks for the MSAA comparison against a native reference on the RTX 5070, on
ccd6134, with both backends and the switch off and on.AI use: Claude Code with Claude Opus 5.5 wrote this reply.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-29T13:57:36Z.
Rebased on
main7a649b0; head9e68021(no conflict). Measured, CPU only (cargo test --release -p xcl --lib, this PR's modules + the library tests): 356 passed, 7 failed (146 skipped GPU tests, the GPU draw among them); the 3quad_masktests,list_142_sets_the_quad_sample_mask,quad_sample_mask_reaches_the_io_of_the_lists_drawsandquad_sample_mask_starts_pixel_shaders_on_both_pathspassed. The 7 failures are the 6shaders::pipeline_library::testsandwarm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable, the same 7 with the same errors onmain7a649b0here: E_INVALIDARG fromCreateComputePipelineStateon this machine's WARP (no SM 6.6). Deduced: a local artefact of WARP here, not the CI failure mode. No GPU run on the card, no title run.Read, CI: the 4
pipeline_library/warm_libraryfailures of our previous CI runs weremain's own on227d2cb(run 46201186646) and passed onmainsincefa20459;main7a649b0now fails 8hle::d3d12x::title_textures::testsin CI (run 46261846646), so a red Build and test with those 8 ismain's. "PR description" stays red only for thexcl-smokepair of the new head, which needs a title run (not made: CPU only this time).Description refreshed (Tested, Regression run, AI use). The body now has io slots 119 / 120, the two-pass commit, and the reports of Eterst, andrewDoing and JJAutoCompare.
Stack: RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631; Rust 1.100.0, release tests,
XCL_ADAPTER=warp,XCL_REQUIRE_GPUunset.AI use: rebase, test runs and this comment done with Claude Code (Claude Opus 5.5), checked by me.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-29T17:07:55Z.
Rebased on
main0fe06eb(new head13a94c5); the only conflict was a neighbouring test ingpu/dxil/core_tests.rs, both kept, and io slots 119 / 120 are still free onmain. CPU-only (WARP) on the PR's test filters: 370 passed, 6 failed, andmain0fe06ebhas the same 6 (WARP has no SM 6.6 here), so the difference is this PR's 7 tests, all passing; same 18 build warnings asmain. Details in the Tested section; still ready for a look.Rebased and tested with Claude Code (Claude Opus 5.5), checked and posted by me.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:27:24Z.
Triage (#1607) – head
13a94c5No open or merged PR implements command list #142
SetQuadSampleMaskX; #1274 only names the slot as a no-op, and #2358 / #3252 export the shader's ownexp mrtzmask to SV_Coverage, which is a different mechanism.Note: the prologue in
emit::quad_mask_prologue/Lw::quad_mask_prologueis added to every pixel shader even withXCL_SAMPLE_MASKunset (two io loads and a uniform branch, plus a translator identity change, so caches are rebuilt); the cost of that default is not measured in the description.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T11:46:35Z.
merge-check
base:
493dbd3dd0head:
13a94c558cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2907 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: read the whole diff (+360/-7). Command list #142 (
SetQuadSampleMaskX, a no-op since #1274) now stores the two mask words in io slots 119 / 120, and withXCL_SAMPLE_MASK=1a pixel whose 16 samples the mask takes away is discarded. The run below has a second smoke with the switch on, which in 60 s doesn't reach the world, where the partial masks come. Findings: (1) The shader change isn't behind the switch. Every translated pixel shader gets the mask test: on the HLSL path a uniform-branched prologue (emit.rs~5532 / ~5593,quad_mask_prologue), and on the direct path two loads, about 10 integer ops and a discard with no branch (lower_gfx.rs~241-282). That changes every shader's identity, so all caches rebuild once. It also adds a discard to shaders that had none, which on some drivers costs early depth testing even when it's never taken (unverified here). Emitting the test only whenXCL_SAMPLE_MASK=1is set would leave the default path identical to main. (2) Draws with no pixel shader (depth-only passes) are never masked, while on the console masked pixels write no depth, so a dithered fade's depth prepass writes both levels in full. (3) Reading #142's arguments as the twoPA_SC_AA_MASKregisters is deduced from the values the title passes. The PR quotes those masks; a raw log line in the description would back it. Fine: no new pipeline variants and nothing built at draw time (the mask is per-draw io data). Reset,ClearState, mid-list splits and two-pass mesh draws are handled, io slots 119 / 120 are free on main, and the GPU test checks pixels on both shader paths. A partial per-sample mask keeps the whole pixel, which fits the title's 0 / 0xFFFF masks and is documented. #2358 / #3252 write the shader's own export mask toSV_Coverage, a different mechanism.performance: 60 s smoke of a retail title, main
493dbd3dvs this merge (2e43b2d1): 1670 -> 1470 frames shown (88 %; last presents per 2 s: 60 61 60), peak commit 17083 -> 16581 MB, 0 device removals, 0 crashes. The first run after the merge has 1470 frames (88 % of main), most likely because every translated pixel shader was translated again (the second run, warm, is back to normal); the second run withXCL_SAMPLE_MASK=1, on the now-warm cache, had 1671 frames (last presents per 2 s: 61 60 60), peak commit 16897 MB, 0 device removals, 0 crashes. Its log shows #142 called 1024 times with only all-ones masks (0 partial, 0 masked draws), so the masking itself isn't reached in 60 s.verdict: not yet: the mask test goes into every translated pixel shader even with the switch off (finding 1), which changes every shader's cache identity; the first run below shows the cost of that rebuild, and the discard it adds can cost early depth testing. Emitting it only with
XCL_SAMPLE_MASK=1keeps the default path as mainhardware / 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.