Skip to content

D3D12.X: command list #142 applies the quad sample mask (XCL_SAMPLE_MASK=1) - #3076

Open
CharlyRien wants to merge 2 commits into
xcl-dev:mainfrom
CharlyRien:pr/quad-sample-mask
Open

CharlyRien wants to merge 2 commits into
xcl-dev:mainfrom
CharlyRien:pr/quad-sample-mask

Conversation

@CharlyRien

@CharlyRien CharlyRien commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Command list #142 of the newer console layout, SetQuadSampleMaskX(u64), is a stub on main: every pixel is drawn. The u64 is the two PA_SC_AA_MASK registers, 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, behind XCL_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 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 and ClearState go back to all ones, a mid-list split inherits it; bind_abi writes 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, after main's 113–118: IO_LOOP_BUDGET, IO_GROUP_LIMIT, IO_THREAD_LIMIT 115–117, IO_MESH_GROUP_BASE 118; below KERNEL_SCC_SLOT, 125).
  • crates/xcl/src/gpu/recomp/emit.rs (HLSL) and crates/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.
  • No pixel shader on main has early depth (the direct path's early_depth_stencil flag exists, every caller passes false). 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.
  • Tests: mask decoding and the title's masks with their complements; the slot; the io wiring across reset / 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 main has a two-pass form, whose mesh pass builds its io in prepare_two_pass_stage (two_pass_io), not through bind_abi, so with XCL_SAMPLE_MASK=1 none of those draws was masked. The mesh pass (not the compute pass) now writes the list's mask into IO_QUAD_KILL as bind_abi does. 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

  • Head 13a94c5 on main 0fe06eb (rebased 29/11 evening; one conflict, in gpu/dxil/core_tests.rs only: main had added a test where this PR adds quad_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 as main 0fe06eb; the test build has the same 18 warnings as main 0fe06eb (no new one).
  • Measured on this head, CPU only (XCL_ADAPTER=warp, so the GPU tests, the GPU draw gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_away among them, run on WARP or skip; XCL_REQUIRE_GPU unset; the tests that open the hardware adapter whatever XCL_ADAPTER says 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 5 shaders::pipeline_library::tests and shaders::warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable: CreateComputePipelineState returns 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 3 quad_mask tests, 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).
    • The same filters, same build settings, on main 0fe06eb: 363 passed, the same 6 failed with the same error, 19 ignored. The difference is this PR's 7 tests.
  • Measured on this head, GPU (RTX 3090, 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, no SKIPPED line: this PR's 7 tests, the GPU draw gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_away among them (run on the card, not skipped).
  • Read, CI: "Build and test (Windows, no GPU)" passed on this head.
  • Tested elsewhere (reports in this thread, not our runs):
    • Eterst, RTX 4070 SUPER, a retail title's world, 300 s: 0 masked draws without the second commit, 19,494 with it.
    • andrewDoing, RTX 5070, driver 616.92, head 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.
    • JJAutoCompare, Intel Arc A770, head 4c6207d: the GPU draw test and 6 host tests, 7 passed.
  • Not rerun on this head (the whole suite on a GPU, the title run with the switch): the results below are of the earlier head 0bab2ef on main e429936.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 2133 passed, 9 failed, 48 ignored. The 9 are the 9 tests main e429936 itself 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).
    • Before that rebase (head 4c6207d on main 2c717a0): a run with XCL_SAMPLE_MASK=1 had 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)
xcl-smoke v1
commit: 4c6207dfb0f75c36d4534a9e7bb4bede8532735d
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 200
exit: 0x0
frames shown: 1621 (PresentX 1621)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 35492 MB

Regression run
Same machine as under Tested, same title, 60 s each (the scripts/smoke.ps1 default), both through main d52ff48's scripts/smoke.ps1, XCL_PREPARE=0, the same scripted A presses (XCL_PRESS_A_AT), XCL_SAMPLE_MASK unset. Each run started from its own copy of the same shader cache, made by another main commit, so cold for both. The head is on main 0fe06eb; the main run is of main d52ff48 (the newest main today, 170 commits later), not of the head's base: the check asks for a commit of main.

main d52ff48:

xcl-smoke v1
commit: d52ff48caade1f5350d513bfffd370396dadfeb6
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 517 (PresentX 517)
presents per 2 s (last 3): 61 60 61
device removals: 0
crashes: 0
peak commit: 15968 MB

this head 13a94c5 (main 0fe06eb + this PR's two commits):

xcl-smoke v1
commit: 13a94c558c1f1a51e6715771af177d4c69817e56
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 603 (PresentX 603)
presents per 2 s (last 3): 61 60 61
device removals: 0
crashes: 0
peak commit: 15349 MB
  • Measured: no device removal and no crash in either run, both ended by themselves (exit 0x0). The head shows 603 frames against 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, main 61 60 61 presents. 60 s covers the start of the title, not a long stay in its world.
  • Deduced: the head's base is 170 commits behind main d52ff48, so the difference between the two runs includes those commits, not only this PR.
The earlier pair (200 s, earlier head 0bab2ef on main e429936)

Earlier pair: same machine, same title, 200 s, the same scripted A presses (XCL_PRESS_A_AT), XCL_PREPARE=0, XCL_SAMPLE_MASK unset, both through main's scripts/smoke.ps1, each starting from its own copy of the same shader cache (made by another main commit, so cold for both).

main:

xcl-smoke v1
commit: e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 200
exit: 0x0
frames shown: 2442 (PresentX 2442)
presents per 2 s (last 3): 1 1 1
device removals: 0
crashes: 0
peak commit: 31737 MB

earlier head 0bab2ef:

xcl-smoke v1
commit: 0bab2ef0d7a17ac8ba592f39c51baaf65c5dbd36
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 200
exit: 0x0
frames shown: 1852 (PresentX 1853)
presents per 2 s (last 3): 3 22 3
device removals: 0
crashes: 0
peak commit: 31534 MB
  • Measured: no device removal and no crash on the head; its frames are 75.8 % of main's, under the 80 % of CONTRIBUTING. The whole difference is in the first 25 s: main presented 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.
  • Read: 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. 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.
  • Deduced: this PR changes only pixel shaders (and the translator identity); the slow pipelines are compute pipelines, so the slow start is not specific to it. Why one run starts fast and another does not is not known.

The other runs of that setup:
main e429936, 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):

xcl-smoke v1
commit: e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 200
exit: 0x0
frames shown: 1908 (PresentX 1908)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 31509 MB

earlier head 0bab2ef, second run, with the cache its first run filled:

xcl-smoke v1
commit: 0bab2ef0d7a17ac8ba592f39c51baaf65c5dbd36
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 200
exit: 0x0
frames shown: 1751 (PresentX 1752)
presents per 2 s (last 3): 4 7 3
device removals: 0
crashes: 0
peak commit: 32587 MB

main e429936, third run, with the cache its second run filled:

xcl-smoke v1
commit: e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 200
exit: 0x0
frames shown: 1744 (PresentX 1744)
presents per 2 s (last 3): 3 2 0
device removals: 0
crashes: 0
peak commit: 32562 MB

Not tested

  • A title run of this head with 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).
  • The image: no capture was compared, and our run with the switch never got a partial mask, so whether the dithered fades now look as on the console is not shown.
  • The order of the 16-bit words (pixel (x, y) = word x + 2y) is taken from the register names; the title's tables are symmetric under swapping x and y, so they cannot tell the two orders apart (a wrong order would transpose the pattern, with the same coverage).
  • Masks that keep part of a pixel's samples (MSAA): the pixel is kept whole; the title only sets 0 or 0xFFFF per pixel.
  • Draws with no pixel shader, the older layout's Pr/newer title startup #142, AMD GPUs (Intel only through JJAutoCompare's tests above).

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

@JJAutoCompare

Copy link
Copy Markdown

Tested

Clean detached 4c6207dfb0f75c36d4534a9e7bb4bede8532735d on 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.

  • Arc (1 passed): gpu::recomp::tests::gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_away passed 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 used XCL_ADAPTER=A770 through its hardware-only named selector.
  • Host (6 passed): same-binary controls covered mask decoding, pixel retention, draw I/O and command-list state, handler 142 routing, and code generation for both paths.

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.

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

Eterst commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

A test of this change in the world of the retail title, plus two things a port to nvidia-dev will 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 (main of 11-27 plus a two-pass mesh path like nvidia-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:

run #142 calls with a partial mask draws bound with one presents in 300 s device removals
XCL_SAMPLE_MASK unset 32,768 by 259 s 15,606 0 2,446 0
XCL_SAMPLE_MASK=1 32,768 by 221 s 17,136 0 2,237 0
XCL_SAMPLE_MASK=1 + the two-pass fix below 32,768 by 221 s 16,792 19,494 2,397 0

1. Two-pass mesh draws don't get the mask. On nvidia-dev every console mesh pipeline is two-pass, and bind_two_pass_stage builds its io with two_pass_io, not through bind_abi. So quad_kill_io never runs for those draws: that's the 0 in the second row. Three lines in bind_two_pass_stage, after its two_pass_io(...) call, gave the third row:

    if !compute_pass {
        quad_kill_io(&mut io, with(this, |s| s.quad_kill));
    }

(with(this, …) is the list's bind state, as in bind_abi.)

2. The io slots are taken on nvidia-dev. There IO_THREAD_LIMIT is [115, 116, 117] and IO_MESH_GROUP_BASE is 118 (gpu/recomp/mod.rs), so IO_QUAD_KILL = [117, 118] would overlap both. Slots 119 to 124 are free on that branch. On main 117 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.

CharlyRien added a commit to CharlyRien/xcl that referenced this pull request Nov 28, 2026
Every console mesh pipeline on main now has a two-pass form, whose mesh pass builds
its io in prepare_two_pass_stage (two_pass_io), not through bind_abi, so quad_kill_io
never ran for those draws: with XCL_SAMPLE_MASK=1 none of them was masked. The mesh
pass (not the compute pass) now writes the list's mask into IO_QUAD_KILL as bind_abi
does.

Found and tested by Eterst on xcl-dev#3076 (RTX 4070 SUPER, a retail title's world: 0 masked
draws without it, 19,494 with it, in 300 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 28, 2026
@CharlyRien

Copy link
Copy Markdown
Contributor Author

Rebased on main 7db2f39 (after #3203); head ccd6134 (2 commits). Tests (cargo test --release -p xcl --lib, XCL_REQUIRE_GPU=mesh, quad_mask, bind, real and the mask tests, the GPU draw gpu_quad_sample_mask_discards_the_quad_pixels_it_takes_away among them): 285 passed, 1 failed. The failure, bind::tests::two_pass_binds_set_the_shared_view_heap, fails on main 7db2f39 too: a "no heap windows" skip that XCL_REQUIRE_GPU=mesh turns into a failure. The compiler warnings are the same 18 as main's.

What changed in the rebase, both from Eterst's test above (thanks):

  • The io slots: main now uses 113–118 (IO_LOOP_BUDGET, IO_GROUP_LIMIT, IO_THREAD_LIMIT 115–117, IO_MESH_GROUP_BASE 118), so IO_QUAD_KILL moves to 119 / 120 (below KERNEL_SCC_SLOT, 125). The tests follow.
  • Second commit: two-pass mesh draws get the mask too. Their mesh pass builds its io in prepare_two_pass_stage, not through bind_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.rs was restructured on main; the mask's state and io writes were placed again by hand.
  • The description above still describes 0bab2ef.

main 7db2f39 itself, run with these filters and those of our other PRs, same setting, has 7 failures, all skips that XCL_REQUIRE_GPU=mesh turns into failures on this card: six lower_dxil::tests::*_on_the_gpu ("…, wave64: no wave64") and bind::tests::two_pass_binds_set_the_shared_view_heap ("no heap windows").

The branch merges with main 227d2cb without 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.

@andrewDoing

Copy link
Copy Markdown
Contributor

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.

64-pixel band, in draw order White with XCL_SAMPLE_MASK=1 White with switch off
First checkerboard 32 64
Complementary checkerboard 32 64
Zero mask 0 64
After resetting the tracked list state 64 64

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.

@CharlyRien

Copy link
Copy Markdown
Contributor Author

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

CharlyRien added a commit to CharlyRien/xcl that referenced this pull request Nov 29, 2026
Every console mesh pipeline on main now has a two-pass form, whose mesh pass builds
its io in prepare_two_pass_stage (two_pass_io), not through bind_abi, so quad_kill_io
never ran for those draws: with XCL_SAMPLE_MASK=1 none of them was masked. The mesh
pass (not the compute pass) now writes the list's mask into IO_QUAD_KILL as bind_abi
does.

Found and tested by Eterst on xcl-dev#3076 (RTX 4070 SUPER, a retail title's world: 0 masked
draws without it, 19,494 with it, in 300 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CharlyRien

Copy link
Copy Markdown
Contributor Author

Rebased on main 7a649b0; head 9e68021 (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 3 quad_mask tests, list_142_sets_the_quad_sample_mask, quad_sample_mask_reaches_the_io_of_the_lists_draws and quad_sample_mask_starts_pixel_shaders_on_both_paths passed. The 7 failures are the 6 shaders::pipeline_library::tests and warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable, the same 7 with the same errors on main 7a649b0 here: E_INVALIDARG from CreateComputePipelineState on 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_library failures of our previous CI runs were main's own on 227d2cb (run 46201186646) and passed on main since fa20459; main 7a649b0 now fails 8 hle::d3d12x::title_textures::tests in CI (run 46261846646), so a red Build and test with those 8 is main's. "PR description" stays red only for the xcl-smoke pair 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_GPU unset.

AI use: rebase, test runs and this comment done with Claude Code (Claude Opus 5.5), checked by me.

CharlyRien and others added 2 commits November 29, 2026 17:48
…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 119 / 120
(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>
Every console mesh pipeline on main now has a two-pass form, whose mesh pass builds
its io in prepare_two_pass_stage (two_pass_io), not through bind_abi, so quad_kill_io
never ran for those draws: with XCL_SAMPLE_MASK=1 none of them was masked. The mesh
pass (not the compute pass) now writes the list's mask into IO_QUAD_KILL as bind_abi
does.

Found and tested by Eterst on xcl-dev#3076 (RTX 4070 SUPER, a retail title's world: 0 masked
draws without it, 19,494 with it, in 300 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CharlyRien

Copy link
Copy Markdown
Contributor Author

Rebased on main 0fe06eb (new head 13a94c5); the only conflict was a neighbouring test in gpu/dxil/core_tests.rs, both kept, and io slots 119 / 120 are still free on main. CPU-only (WARP) on the PR's test filters: 370 passed, 6 failed, and main 0fe06eb has 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 as main. 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.

@CharlyRien
CharlyRien marked this pull request as ready for review November 30, 2026 09:29
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 13a94c5

No 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 own exp mrtz mask to SV_Coverage, which is a different mechanism.
Note: the prologue in emit::quad_mask_prologue / Lw::quad_mask_prologue is added to every pixel shader even with XCL_SAMPLE_MASK unset (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.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 493dbd3
head: 13a94c5
merge: 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 with XCL_SAMPLE_MASK=1 a 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 when XCL_SAMPLE_MASK=1 is 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 two PA_SC_AA_MASK registers 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 to SV_Coverage, a different mechanism.
performance: 60 s smoke of a retail title, main 493dbd3 vs 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 with XCL_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=1 keeps the default path as main
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants