Skip to content

Recompiler: a pixel shader's carry ballot reads its quad lane by lane, not through quadOp - #3455

Open
ArtuArtaza wants to merge 1 commit into
xcl-dev:mainfrom
ArtuArtaza:fix/ps-carry-ballot-quad-read
Open

ArtuArtaza wants to merge 1 commit into
xcl-dev:mainfrom
ArtuArtaza:fix/ps-carry-ballot-quad-read

Conversation

@ArtuArtaza

@ArtuArtaza ArtuArtaza commented Nov 29, 2026 •

Copy link
Copy Markdown

On an RX 6700 XT the retail title (TitleID 7952987A, Series S profile) ends at its first world load: unhandled exception 0xc0000005 in amdxc64.dll (a null read) about 1 ms into the build of one graphics pipeline, the one of pixel shader record 7381166e806847c9. It is the same on drivers 32.0.21030.2001 (+0x65d678) and 32.0.21045.29003 (+0x671f78), with one pipeline worker too, and 3,000+ other graphics pipelines build fine before it.

The cause is in the direct translator's pixel-shader ballot outside compares (Lw::ballot_ps: carry masks and the like). It collected its quad's 4 bits through QuadReadAcrossX/Y/Diagonal (quadOp). In this PS 10 of its 27 such ballots take a value that derives from WaveReadLaneAt. That is the driver bug the compare path already avoids (#134, lower_valu: "amdxc64 crashes on quadOp of values derived from WaveReadLaneAt"); this path was not covered. The ballot now reads its quad with 4 QuadReadLaneAt, as the compare path does. Related: #134, #2996.

Rebased on main 9dfbe3ea. #3501 had added note_own_bit to ballot_ps since the first head (8363f77a), and that head returned before it: the two merged without a conflict, but the new form then tested a lane's own bit through the mask's word, and helper lanes drew another value than in the quadOp form. saintwolf found it (16 pixels of the GPU test, on an RTX 4070 SUPER; I get the same 16 on RDNA2). Both forms now end in the same ballot_ps_quad + note_own_bit.

How it was narrowed (on fa20459 with local per-PS debug switches, not in this PR): the pipeline builds without its PS (397 ms); it still dies without blending and in the plain wave64 form. With the ballots lane by lane, the same VS and description (byte-identical) and a PS that differs only in quadOp 81 → 0, quadReadLaneAt 172 → 280 build in 4.3 s.

How to test

  • Build: git fetch origin pull/3455/head:pr-3455, git checkout pr-3455, cargo build --release -p xcl. Nothing to clear: an edit of gpu/dxil changes the translations' cache identity, and the driver builds again only the pixel shaders whose DXIL changed.
  • Does your card have the crash: run the title on main with XCL_PREPARE=0 XCL_PSO_TRACE=1 XCL_ACTIVITY=1 (I used XCL_DEVICE_TYPE=lockhart) and go into the world. It is unhandled exception 0xc0000005 in amdxc64.dll right after driver compile start …: graphics PSO, … record 7381166e806847c9, and the process ends. Here that came 4 – 7 minutes in on a cold driver cache, most of them without frames (the wait of AMD hive: one goal – the retail title (7952987A) past world load on AMD. RX 9070 XT and other RDNA owners, pick a lane #2996).
  • With this PR the same run logs driver compile finish for that record and goes on.
  • Other adapters (NVIDIA, Intel): cargo test -p xcl --lib ps_ballot_tests (its GPU test draws both forms and compares the pixels) and a scripts/smoke.ps1 pair.
  • Useful in a report: GPU and driver, the commit, crashed or not, and the last driver compile start line before a crash.

What is in it

  • crates/xcl/src/gpu/dxil/lanes.rs: ballot_ps ors quad_read_lane_at(cond, p) << p for p in 0..4 (bit p is the quad's member p, which own << (lane & 3) relied on too), then records the own bit as before. Only tests can ask for the quadOp form (cfg(test)). No TRANSLATOR_VERSION bump: a gpu/dxil edit changes the direct translations' cache identity by itself.
  • Tests in lanes.rs: direct_ps_non_vopc_carry_ballot_reads_its_quad_lane_by_lane (was ..._uses_quad_op) checks both forms' DXIL, also with the carry's operand coming through v_readfirstlane, and that v_cndmask takes the carry itself in both; gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadop draws a carry mask, its DPP ddx (helper lanes on the triangles' edge) and the mask's bit of the lane to the right (from the mask's word) in both forms, and compares every pixel; away from that edge it also compares with the known values.
  • crates/xcl/src/gpu/dxil/kernel.rs: the test-only choice of the form is handed to the translator's thread, like NO_SELECT_FOLD.

Tested

  • AMD Radeon RX 6700 XT (driver 32.0.21045.29003), Ryzen 5 5600X, 48 GB, Windows 11 build 26200.9974, rustc 1.100.0; tests in debug, title runs in release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 (with --nocapture, on this tree just before it was committed as 4dd68427): 2881 passed, 7 failed, 51 ignored (44 test binaries). The 7 are 6 tests, and all 6 failed with the same values on unmodified main 9dfbe3ea on this card (ran them there alone, for 4dd1796f; not again for 4dd68427): gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form (what Recompiler: compact literal indices are read from one table word on AMD #3473 fixes), gpu_direct_image_get_resinfo_d16 (see Tests: name the trailing VGPRs in the D16 resinfo kernel test #3513), f32_programs_on_the_gpu, gpu_f32_compares_with_nan, gpu_float_compares_random (all three in gpu/recomp), and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (parent and child run). 4 SKIPPED (2 no heap windows, 1 no GPU_UPLOAD heaps, 1 cannot disable the driver cache).
  • cargo test -p xcl --lib ps_ballot_tests on the same tree: 9 passed, 0 failed. On 4dd1796f: with note_own_bit taken out of the new form both changed tests fail (the v_cndmask tests the mask's word; 32 pixels differ). With XCL_ADAPTER=warp: 9 passed, the 3 GPU tests of the module SKIPPED (no wave32 / no wave64).
  • The crash, on the first head only (8363f77a, against its main 0fe06eb0; not repeated on 9dfbe3ea): the retail title, XCL_DEVICE_TYPE=lockhart XCL_PREPARE=0 XCL_PSO_TRACE=1, A pressed every 15 s from 30 s, 720 s, one run each:
    • main 0fe06eb0: driver compile start #3221: graphics PSO, 138304 B DXIL, record 7381166e806847c9 at 259.6 s, the null read in amdxc64.dll+0x671f78 at 260.3 s, the process ends (exit 0xc0000005).
    • 8363f77a: the pipeline of record 7381166e806847c9 (138944 B of DXIL) builds and the run ends by itself at 720 s (exit 0x0, 3075 frames), 0 device removals, 0 pipelines rejected. The driver took 2797 ms for it the first time (at 237.0 s, on ebcc28f5) and 1 ms from its cache in that run (at 167.6 s).
  • A synthetic PS with only this shape (a carry ballot of a v_readfirstlane value) does not crash this driver in the quadOp form, so there is no small reproduction: the tests check the form and the pixels, not the crash.

Regression run

60 s (menus, the pipeline is not reached), scripts/smoke.ps1, XCL_DEVICE_TYPE=lockhart XCL_PREPARE=0, A pressed at 30 s and 45 s: main 9dfbe3ea (this PR's merge base, which ran first), then this PR's head.

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: AMD Radeon RX 6700 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 13578 MB
xcl-smoke v1
commit: 4dd6842738511d3de90b272d1f87aa745d165799
gpu: AMD Radeon RX 6700 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1543 (PresentX 1543)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13683 MB

Not tested

AI use

  • Claude Code with Claude Fable 5.2 found the cause (took the pipeline apart on the hardware above), wrote the first head and its tests and ran its runs; Claude Opus 5.5 rebased it, found and fixed the missing own bit, extended the tests, ran the suite and the 60 s runs, removed the XCL_PS_BALLOT_QUADOP switch after review, and wrote this version of the description. All on my machine; the PR was submitted from my Claude Code session at my request, with me present.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) labels Nov 29, 2026
@ArtuArtaza
ArtuArtaza marked this pull request as ready for review November 29, 2026 19:47
@ArtuArtaza
ArtuArtaza force-pushed the fix/ps-carry-ballot-quad-read branch from ebcc28f to 8363f77 Compare November 29, 2026 19:51
@Aniseto

Aniseto commented Nov 29, 2026

Copy link
Copy Markdown

Ran the pixel-shader carry-ballot tests at 8363f77a on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib ps_ballot_tests -- --test-threads=1: 8 passed, 0 failed, 0 ignored.

What this adds
All eight tests pass, including the GPU draw that compares the QuadReadLaneAt form against the quadOp form pixel by pixel, with carry masks and helper lanes on triangle edges. The author's run was on an AMD RX 6700 XT, where the crash occurs; this is an independent NVIDIA datapoint on driver 32.0.16.2140. The current head is 8363f77a, not the ebcc28f5 named in the description. The AMD driver crash itself was not reproduced here.

Not tested
A retail title, an AMD adapter, a paired smoke run, the full workspace suite here, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

dudenudem pushed a commit to dudenudem/xcl that referenced this pull request Nov 29, 2026
…, not through quadOp

A pixel shader's ballots outside compares (`Lw::ballot_ps`: carry masks and the
like) collected their quad's 4 bits through `QuadReadAcrossX/Y/Diagonal`
(`quadOp`). An AMD RDNA2 driver (amdxc64 32.0.21030.2001 and 32.0.21045.29003,
RX 6700 XT) dies with a null read about 1 ms into the pipeline build of a
retail title's pixel shader (record 7381166e806847c9) in which 10 of the 27
such ballots take a value that derives from `WaveReadLaneAt`: the title ends
there at its first world load. Found by taking the pipeline apart: without its
PS it builds, without blending or in the plain wave64 form it does not; with
the ballots below, the same VS and description build in 4.3 s and the run goes
on.

The ballot now reads its quad with 4 `QuadReadLaneAt`, as the compare path
does for the same driver (xcl-dev#134, `lower_valu`): bit `p` is the quad's member
`p`, which is what `own << (lane & 3)` relied on too. `XCL_PS_BALLOT_QUADOP=1`
keeps the `quadOp` form (with `XCL_TRANSLATED_CACHE=0`, a translation on disk
keeps its form).

Tests: `direct_ps_non_vopc_carry_ballot_reads_its_quad_lane_by_lane` (was
`..._uses_quad_op`) checks both forms' DXIL, also with the carry's operand
coming through `v_readfirstlane`;
`gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadop`
draws a carry mask and its DPP `ddx` (helper lanes on the triangles' edge) in
both forms and compares every pixel. The test-only form is handed to the
translator's thread like `NO_SELECT_FOLD`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
(cherry picked from commit 8363f77)

Based on 8363f77 by ArtuArtaza (xcl-dev#3455)
dudenudem pushed a commit to dudenudem/xcl that referenced this pull request Nov 29, 2026
@moombathepilot

Copy link
Copy Markdown

merge-check

base: 0fe06eb

head: 8363f77

merge: clean. Tested local trial merge 5d268fbb10cb842b9df2626185fe2ed61b642c78.

build: cargo build --workspace and cargo build --release -p xcl -> ok.

tests: cargo test -p xcl --lib ps_ballot_tests -- --test-threads=1 --nocapture -> 8 passed, 0 failed, 0 ignored, 0 skipped. The GPU draw matched both ballot forms pixel by pixel on RX 7800 XT, including triangle-edge helper lanes, in wave32 and wave64.

cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture -> 2,736 passed, 2 failed, 49 ignored. There were 12 explicit SKIPPED notices: 6 unsupported per-lane f16/f32 cases, 2 no heap windows, 3 missing D3D12 debug layer, and 1 driver cache could not be disabled. Both failures matched earlier targeted runs on this exact unmodified base and machine: fuzz_validate_and_gpu_1 (seed 722) and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (two-pass state release assertion).

review: Read the full diff. The lane-by-lane lowering preserves the quad bit positions and reuses the existing quad ballot assembly. The disassembly test also covers the carry input derived from a lane read. git diff --cached --check passed. GitHub's Windows build check passed. The PR description check remains red, and the supplied PR-side smoke blocks still name ebcc28f.

performance: 60-second release smokes on the Series S profile, title 817b32af, with XCL_PREPARE=0, networking off, and no input. Both exited 0 with zero crashes and device removals.

Build Frames shown Peak commit
main 1,393 12,235 MB
trial merge 1,622 12,143 MB

A separate 300-second trial-merge run used the same profile, PSO tracing, and scheduled A presses starting at 30 seconds. It exited 0 with 2,491 presents, zero crashes or device removals, and 27,803 MB peak commit. The last three two-second windows had zero presents. The affected record 7381166e806847c9 did not appear in the trace, so the run leaves that pipeline and world entry unverified on RDNA3. Frame cost of the extra quad-lane read was not isolated.

verdict: not yet: the PR description check is failing on the current head, and the specific retail pipeline remains unverified on this AMD setup.

hardware / tool and model: Radeon RX 7800 XT (driver 32.0.32029.2010), Ryzen 7 5700X3D, Windows 11 Home build 26300, Rust 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17. Codex (GPT-6, exact variant unavailable) verified refs, reviewed the diff, ran the build, tests and smokes, compared baseline logs, and drafted this report.

Reviewed by the posting user before submission.

@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Nov 29, 2026
@ArtuArtaza

Copy link
Copy Markdown
Author

@moombathepilot thanks for the merge-check. On your two points:

  • The description now names the current head 8363f77a: the suite, both PR-side smoke blocks and the 720 s run were redone on it, and the three checks are green. (The first head ebcc28f5 failed CI because my new GPU test drew on the runner's software adapter; it now skips there, as its neighbours do.)
  • Reaching the pipeline: 300 s is short for it. On my RX 6700 XT the title asks for record 7381166e806847c9 between 168 s and 260 s once the driver's cache has the compute programs that come before it, and at 386 s the first time on a cold cache; most of that wait is without frames. A 720 s run with XCL_PSO_TRACE=1 and the A presses was enough here. On main look for driver compile start …: graphics PSO, … record 7381166e806847c9 followed by the amdxc64.dll exception; with the PR, a driver compile finish for the same record. If your driver builds it on main too, RDNA3 does not have this bug, which would be worth knowing as well.

@Aniseto thanks for the NVIDIA run.

Written with Claude Code (Claude Fable 5.2), from my runs on the hardware in the description.

@moombathepilot

moombathepilot commented Nov 29, 2026 •

Copy link
Copy Markdown

Thanks, that explains it: my 300 s run was likely too short. I still need to run 720 s on main and the trial merge to check record 7381166e806847c9 on RDNA3. ETA 21:45UTC

@JR-Wiederkehr

JR-Wiederkehr commented Nov 29, 2026 •

Copy link
Copy Markdown

Confirmed test run on Radeon 7700XT, gets past 7381166e806847c9 shader without crashing at [143.158].

@moombathepilot

Copy link
Copy Markdown

merge-check

base: 1bd9cee

head: 8363f77

merge: clean, trial merge bfa9aef78b7dad5c356c992f3876ba91ef2c4f2e. Main advanced again during testing. The description now names this head in both PR-side smoke blocks, and the latest three GitHub checks are green.

build: cargo build --workspace passed on the merge. Both release builds passed.

tests: cargo test -p xcl --lib ps_ballot_tests -- --test-threads=1 --nocapture gave 8 passed, 0 failed, 0 ignored, 0 skipped. The full merge suite (cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture) gave 2,743 passed, 6 failed, 49 ignored, and 12 skip notices (6 unsupported per-lane f16/f32 cases, 2 no heap windows, 3 missing debug layer, 1 driver-cache control unavailable). Fuzz seed 722 and the two-pass cache test matched failures on the exact base. Four texture tests failed in the merge suite (one subtraction overflow, three poisoned locks). The texture group rerun gave 65 passed, 0 failed, 1 ignored on both builds. The full base lib run aborted with 0xc0000409, so the four failures could not be classified in a like-for-like full-suite comparison.

review: The live head is unchanged from the previous merge-check, which covers the diff review. Both 720 s traces logged the shader record: base [52.589] [SHADER] ps 7381166e806847c9, merge [53.057] [SHADER] ps 7381166e806847c9. Neither trace logged a graphics PSO compile start or finish for it or an AMD driver exception. Pipeline behavior and world entry remain unverified here.

Each trace had unique numbered starts and finishes, with no finish lacking a start. One start in each trace had no matching finish. These were also the last driver compile lines:

Base  [  717.984][25380][INFO ] D3D12.X: driver compile start #9249: compute PSO, 1081184 B DXIL, record b8004a436fac775d, driver blob absent
Merge [  716.751][16204][INFO ] D3D12.X: driver compile start #12507: compute PSO, 845112 B DXIL, record ccc5774a7210c001, driver blob absent

After the last nonzero present window, base logged 76 starts and 76 finishes, and merge logged 7,554 of each. These are independent event counts in that interval, so a finish can belong to a start before the cutoff. Both traces continued logging completed compute, compute-pass, mesh and graphics PSOs. The unmatched starts do not establish a hang or its cause.

performance: Series S profile, title 817b32af, XCL_PREPARE=0 XCL_PSO_TRACE=1 XCL_NETWORK=0, A every 15 s starting at 30 s. Sequential base then merge, with caches retained and recorded before each run. Both exited 0x0 after the 720 s timer, with zero crashes and device removals. Base: 2,545 presents, last nonzero sample ending at 128.400 s, 29,229 MB peak commit. Merge: 2,575 presents, last nonzero sample ending at 130.474 s, 30,949 MB peak commit. Neither resumed presenting after that gap. These are two-second sample timestamps. Presents stopped at about the same point on both builds, so these runs do not show the stall as specific to this PR. The first baseline attempt missed the timer because of environment inheritance in the smoke harness. It was excluded and the pair was restarted with the timer set before launch.

On my RX 7800 XT, neither build logged a compile start for record 7381166e806847c9 within 720 s. Does your run use any settings, cache preparation or input timing that differ from mine? The existing driver and XCL caches were retained. Before base and merge respectively, AMD DxCache had 263 files in both, AMD DxcCache had 207 files in both (13.56 and 13.76 GB), Windows D3DSCache had 770 files in both, and XCL DXIL had 130,666 and 130,671 files. XCL logged its driver-blob disk cache as off on AMD. The two unmatched compiles above were for other compute records.

verdict: not yet: the target graphics pipeline was not observed compiling on either build, and the four suite-only texture failures remain unresolved.

hardware / tool and model: Radeon RX 7800 XT (32.0.32029.2010), Ryzen 7 5700X3D, Windows 11 Home build 26300, Rust 1.100.0 MSVC. Codex (GPT-6, exact variant unavailable) verified refs and checks, ran the builds and tests, compared the traces, and drafted this report.

@ArtuArtaza

Copy link
Copy Markdown
Author

@moombathepilot thanks for the second run. My settings are the same as yours (Series S, XCL_PREPARE=0, XCL_PSO_TRACE=1, network off, A every 15 s from 30 s, no cache preparation step). What differs is how warm the driver's cache was:

  • The 720 s pair in the description was not the first run of those trees. Before the main 0fe06eb0 run that crashed at 260 s, this machine had done a 60 s, a 240 s and a 330 s run of that main and a 60 s and a 240 s run of the PR. Neither the 240 s nor the 330 s main run reached the pipeline (the 330 s one sat in big compute compiles until its end). Each run left more of those compute programs in AMD's cache, and the next one got further.
  • The first time on a cold driver cache (on fa20459, right after a driver update) the compile start for record 7381166e806847c9 came at 386 s, after about 200 s without frames.
  • In all my runs the request for that pipeline comes inside that no-frames stretch, after a batch of large compute programs. So on your card the question is whether the title gets through that batch within the timer. What moved it here was repeating the same run with the caches kept, not a longer timer.

@JR-Wiederkehr thanks. Was that run on this PR or on main? If it was the PR: a run of unmodified main that reaches the same record would tell whether RDNA3 has this crash at all. A driver compile finish for it on main would rule it out for that driver; the amdxc64.dll exception would confirm it. The same goes for anyone on RDNA4.

On the four texture failures: I cannot tie them to this change, which only touches pixel-shader translation. On this machine texture upload tests (title_textures gpu_*) fail now and then at --test-threads=4 on unmodified main too (fa20459, about one run in six) and pass alone. I have not seen an overflow or poisoned locks here: both suite runs on this PR's heads had only the two-pass cache test failing.

Written with Claude Code (Claude Fable 5.2), from my runs on the hardware in the description.

@ArtuArtaza

Copy link
Copy Markdown
Author

Status on head 8363f77a: not a draft, no conflict with main, all three checks green, no review asking for changes. What it still lacks is in other people's hands, so three requests.

@moombathepilot thanks for both merge checks. Could you look at the verdict again? On the two reasons in the second one:

  • Target pipeline not seen compiling on your card. Per the process notes on [OFFICIAL] Merge queue: which PRs can be merged next, and how to claim a merge check #3041 (throny, 2026-11-27), a retail-title run is not part of a merge check: the check is the trial merge, the build, the whole suite and the review of the merge result. Your RX 7800 XT may also simply not have this driver bug; so far the crash is only shown on RDNA2 (RX 6700 XT, drivers 32.0.21030.2001 and 32.0.21045.29003). Your traces would fit better as a test report with "crash not reproduced on RDNA3".
  • Four texture failures. Your rerun of the texture group gave 65 passed, 0 failed on both builds. Here the title_textures gpu_* tests fail about one run in six at --test-threads=4 on unmodified main and pass alone, and this PR only touches pixel-shader translation (gpu/dxil/lanes.rs). If a like-for-like base run is what you need, the lib binary alone (cargo test -p xcl --lib --no-fail-fast -- --test-threads=4) on the base is enough to classify them.

If something in the diff itself worries you, say so and I will fix it.

@JR-Wiederkehr thanks for the RX 7700 XT run. To count as a test report it needs the commit you ran (this PR's 8363f77a, or main), the driver version, and the suite counts if you ran any (cargo test -p xcl --lib ps_ballot_tests is 8 tests). Whether it was the PR or main matters most: a driver compile finish for record 7381166e806847c9 on unmodified main would show RDNA3 does not have the crash.

Anyone with an RX 6000 card (RDNA2): this is the hardware that can confirm the fix. On main, XCL_PREPARE=0 XCL_PSO_TRACE=1 XCL_ACTIVITY=1 into the world ends with unhandled exception 0xc0000005 in amdxc64.dll right after driver compile start …: graphics PSO, … record 7381166e806847c9; with this PR the same record logs driver compile finish. It can take several runs with the driver cache kept before the title asks for that pipeline. A merge check from such a machine is welcome as the hardware the first check did not have.

I cannot queue my own PR on #3041. If someone who has read it thinks it belongs there, the request would be importance: crash.

Written with Claude Code (Claude Fable 5.2), from my runs on the hardware in the description.

@saintwolf

saintwolf commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

merge-check claim
head: 8363f77

@saintwolf

Copy link
Copy Markdown
Contributor

merge-check
base: 9dfbe3e
head: 8363f77
merge: clean (trial merge f2b7ad1173bced603287998e9cdfa3f2d57cc847; git diff --check clean; +136/-15 in gpu/dxil/lanes.rs and kernel.rs)
build: cargo build --workspace -> ok (39 pre-existing warnings, none from the PR's files)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2885 passed, 2 failed, 51 ignored (lib 2737/2/31, integration 148/0/20); SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"); failing: (1) gpu::dxil::lanes::ps_ballot_tests::gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadop — new in this PR, absent on base; fails here, deterministically (also run alone): wave64=false leg, 16 pixels differ between the two forms, all in output channel 1 (DPP ddx of the masked carry value minus the value): e.g. (16,17) [16.5,-16.5,16.5,17.5] vs [16.5,1.0,16.5,17.5] — the lane-by-lane form's adjacent-lane DPP read returns 0.0 (the no-carry value) where the quadOp form returns the neighbor's masked value; the test's earlier assert (the carry mask is held, channel 0) passes in the new form; the differing readers sit on/below the main diagonal (x = y and x = y-1, odd y 17..31). (2) gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 — pre-existing here: fails identically on base 9dfbe3e (same "2D D16 resinfo clobbered v2/v3" assertion), untouched by this PR.
review: (1) the PR's new GPU parity test fails on my hardware (NVIDIA Ada, wave32-only); per the thread it passes on RDNA2, RDNA3 and an RTX 5070 Ti (Blackwell — also wave32), so this is Ada-specific, not a wave32-vs-wave64 effect; (2) the new default path (ballot_ps) returns before the self.note_own_bit(lo, hi, cond) that the quadOp path still calls: a carry ballot's own bit is no longer recorded, so a later masked op extracting this lane's bit of that mask falls back to a shift+and of the mask word (ISA/ALU cost, no correctness change); (3) the kernel.rs change is cfg(test)-only plumbing forwarding QUAD_OP_IN_TEST to the translator thread (mirrors the existing NO_SELECT_FOLD pattern); (4) the opt-out env XCL_PS_BALLOT_QUADOP=1 is OnceLock-cached and off by default; on-disk translations keep the form they were made with (documented in the diff); (5) open #3429 adds tests to the same ps_ballot_tests module in the context this PR rewrites — expect a small rebase conflict for whichever lands second; (6) duplicate scan: no open or merged PR makes this change, no #1607 group covers it, #3405 are adjacent compare-path work.
performance: the default form replaces andc+shl+3 quadOp with 4 quadReadLaneAt+4 shlc (+3 ops per PS carry ballot, wave-uniform code) and drops the note_own_bit shortcut from review (2); no memory change; not measured — Tier 1, no retail run.
verdict: not yet: the PR's own new GPU parity test fails on NVIDIA Ada (RTX 4070 SUPER, driver 32.0.16.2140, wave32) — 16 px differ between the lane-by-lane and quadOp forms, in the DPP-derived channel at the mask boundary; deterministic; passes on RDNA2/RDNA3/Blackwell per the thread. Needs the author's call: investigate Ada helper-lane quad-read visibility, or relax the parity assert with a documented exception.
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0, DXC 1.8.2502.11 (23992152) / OpenCode, Qwen 3.8 27B

@ArtuArtaza
ArtuArtaza force-pushed the fix/ps-carry-ballot-quad-read branch from 8363f77 to 4dd1796 Compare November 30, 2026 15:51
@github-actions github-actions Bot added gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) and removed gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) labels Nov 30, 2026
@ArtuArtaza

Copy link
Copy Markdown
Author

@saintwolf thanks, the failure is real, and it is not Ada-specific: the old head merged into 9dfbe3e gives the same 16 pixels on my RX 6700 XT. The cause is your point (2). #3501 added note_own_bit at the end of ballot_ps after that head was written, and its early return skipped it. So the new form tested each lane's own bit through the mask's word, and helper lanes drew another value than in the quadOp form. The earlier runs that passed were from before #3501.

4dd1796 is rebased on 9dfbe3e, and both forms now end in the same ballot_ps_quad + note_own_bit. The two tests changed too: the DXIL test checks that v_cndmask takes the carry itself in both forms, and the GPU test also reads the mask's word (the bit of the lane to the right), because with the own bit noted the old program no longer did. Both fail without the line and pass with it. The suite and the 60 s pair are in the description; the 6 tests that fail fail with the same values on unmodified 9dfbe3e here.

One thing next to it, in main and not in this PR: a pixel shader that reads a mask's word whole (a live WaveActiveBitOr), ends in discard(!exec) and reads a neighbour through DPP gets 0 from helper lanes on triangle edges here, in both forms, and also as hand-written HLSL. I think it is because a lane's EXEC bit there comes from WaveActiveBallot, whose result in helper lanes is undefined. The GPU test therefore only asks the two forms to agree on those edges.

What I could not run is NVIDIA: cargo test -p xcl --lib ps_ballot_tests on your card would tell whether the mask's word holds there too.

(Change and reply written by Claude Code with Claude Opus 5.5, sent from my account.)

@Aniseto

Aniseto commented Nov 30, 2026

Copy link
Copy Markdown

New head 4dd1796f: the pixel-shader carry-ballot tests run and pass here. This is a new response in the same thread; my earlier report at 8363f77a (#3455 (comment)) covered the first head and is not edited.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib ps_ballot_tests -- --test-threads=1
9 passed; 0 failed; 0 ignored; 2761 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib direct_ps_non_vopc_carry_ballot_reads_its_quad_lane_by_lane -- --test-threads=1
1 passed; 0 failed; 0 ignored; 2769 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadop -- --test-threads=1
1 passed; 0 failed; 0 ignored; 2769 filtered out      (exit 0)

The three named tests pass on this Blackwell desktop part with 16 GB of VRAM and driver 621.40, on a head rebased onto 9dfbe3ea where #3501 added note_own_bit. My earlier run was on the first head, 8363f77a, so this is a second NVIDIA host and a second head for the same tests.

Not tested: the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, the title and paired smoke runs, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-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.

bobosneefdev added a commit to bobosneefdev/xcl that referenced this pull request Dec 1, 2026
… 6800 A/B

Testbed only. A pixel shader's carry ballot reads its quad lane by lane;
XCL_PS_BALLOT_QUADOP=1 keeps the quadOp form. Lead for the amdxc64 null read
on PS 7381166e806847c9 (xcl-dev#3544).

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

Chrysana commented Dec 1, 2026

Copy link
Copy Markdown

merge-check
base: d0832e6
head: 4dd1796
merge: clean (trial merge 1df769bb3c9607491ae2e018ed46881b1dcfbe3a; git diff --check clean; +172/−22 in gpu/dxil/lanes.rs and kernel.rs)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2883 passed, 9 failed, 51 ignored. SKIPPED: 6 (2× no heap windows, 1× driver cache needs Windows Developer Mode, 3× no D3D12 debug layer), the same as base. Failing: the same 8 tests as on base d0832e61 on this card (2882 passed, 9 failed, 51 ignored there): fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_3, gpu_smem_flat_descriptor_windows_and_limits, f32_programs_on_the_gpu, gpu_f32_compares_with_nan, gpu_float_compares_random, gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends, and the e2e two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (counted twice). All 9 ps_ballot_tests pass here, including gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadop (wave32 and wave64).
review: none blocking; I read the whole diff. ballot_ps now collects the quad with 4 QuadReadLaneAt of the lane's 0/1 predicate, each shifted to its quad position. That's the same mask as own << (lane & 3) ORed with the 3 QuadReadAcross*, and it still ends in ballot_ps_quad + note_own_bit. The test override reaches the translator's thread through kernel.rs. Minor: XCL_PS_BALLOT_QUADOP=1 isn't part of the translation-cache identity, as its doc comment says (needs XCL_TRANSLATED_CACHE=0). Targeted check of the changed path: this is the pipeline behind #3544 on Windows/AMD, see below.
performance: reasoned plus one run. Per ballot outside compares, 4 lane reads in place of 3 quadOp; the compare path already does it this way. With the default XCL_DIRECT_DXIL, main doesn't get past 48 s here, so there's no frame comparison. The PR's 90 s run ended by itself with 2159 frames, and the target pipeline compiled in 561 ms.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 9070 XT 16 GB (RDNA4, driver 32.0.32015.2008) and the Ryzen 7 9800X3D's iGPU (RDNA2 gfx1036, driver 32.0.21045.11001), 32 GB RAM, Windows 11 25H2 build 26200, rustc 1.100.1 / Claude Code (Claude Opus 5.5)

The changed path, on the retail title (release builds, default XCL_DIRECT_DXIL, XCL_PSO_TRACE=1, XCL_PREPARE=0):

GPU main d0832e61 trial merge 1df769bb
RX 9070 XT, 90 s driver compile start #2182: graphics PSO, 70024 B DXIL, record 7381166e806847c9 at 48.0 s, then unhandled exception 0xc0000005 in amdxc64.dll+0x735dd8 (read at address 0x0) on the same thread at 48.1 s record 7381166e806847c9 (70,444 B DXIL) compiles in 561 ms at 43.6 s; the run ends by itself, 2159 frames, no crash
iGPU, 120 s the same record's compile start at 47.5 s, then amdxc64.dll+0x671d88 (read at address 0x0) at 47.6 s the record compiles in 383 ms at 44.2 s. Device removed at 89.8 s on a CreatePlacedResourceX (0x887a0005), the same as main with XCL_DIRECT_DXIL=1 on this iGPU (88.7 s), so not this PR. I take it to be the 2-CU iGPU's 485 MiB.

This is #3544: on Windows/AMD, #3243's default crashes AMD's compiler on this pipeline, on RDNA4 and RDNA2.

xcl-smoke v1
commit: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f
gpu: AMD Radeon RX 9070 XT
title: 21222967
seconds: 90
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 2
peak commit: 17508 MB
xcl-smoke v1
commit: 1df769bb3c9607491ae2e018ed46881b1dcfbe3a
gpu: AMD Radeon RX 9070 XT
title: 21222967
seconds: 90
exit: 0x0
frames shown: 2159 (PresentX 2159)
presents per 2 s (last 3): 20 12 21
device removals: 0
crashes: 0
peak commit: 26532 MB

Claude Code (Claude Opus 5.5) ran the merge, the build, the suite and the guarded title runs, read the diff and drafted this check. I checked it before posting.

@github-actions github-actions Bot added the needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) label Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 7d86c5d
head: 4dd1796
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2897 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 (+172/-22). ballot_ps (lanes.rs ~923) now ORs quadReadLaneAt(own, p) << p for the 4 quad lanes into the same bit layout as the old own << (lane & 3) instead of using quadOp, and note_own_bit stays on both forms. On current main this holds: the PR base 9dfbe3e already has ps_masks (f4ee8ac), which only marks V_CMP compares, so carry ballots (v_add_co and the like) always take ballot_ps; the only dxil change since (44eeb0c, the wave32 width fix) doesn't touch this path, so the #3429-style breakage doesn't apply. Findings: (1) XCL_PS_BALLOT_QUADOP adds an env switch outside the translation's cache identity, and the tests don't need it (they use QUAD_OP_IN_TEST); CONTRIBUTING puts env switches in their own PR. (2) The crash fix was only verified on the first head (8363f77), and the frame cost of 4 quadReadLaneAt vs 3 quadOp per PS ballot isn't measured (both stated in the description). Fine: the DXIL test fails on main (no quadOp, 4 lane reads, v_cndmask takes the carry itself), the GPU test compares both forms pixel by pixel including helper lanes on edges, and the AI use names exact models.
performance: 60 s smoke of a retail title, main 7d86c5d vs this merge (1fe65259): 1663 -> 1692 frames shown (101 %; last presents per 2 s: 60 60 61), peak commit 17153 -> 17123 MB, 0 device removals, 0 crashes. The smoke run is capped at 60 presents per second, so it doesn't measure the cost of 4 quadReadLaneAt vs 3 quadOp per pixel-shader ballot.
verdict: not yet: XCL_PS_BALLOT_QUADOP changes the generated code but isn't in the translation's cache identity, so switching it serves stale cached shaders; drop it (the tests don't need it) or move it to its own PR with the identity. The fix itself passes here with a flat smoke run
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.

@github-actions github-actions Bot added checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 4dd6842

No open or merged PR changes Lw::ballot_ps this way. #3429 and #3405 also touch pixel-shader quad reads, but on the compare paths (lower_valu, lower_wide), not the non-compare ballot.
No problems found in the diff: the lane-by-lane form ends in the same ballot_ps_quad + note_own_bit as the old one, and only tests can ask for the quadOp form (QUAD_OP_IN_TEST, passed to the translator thread like NO_SELECT_FOLD); there is no XCL_PS_BALLOT_QUADOP switch any more.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@CharlyRien

CharlyRien commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: b2b1f10
head: 4dd1796
merge: clean (local trial merge 399e44b0, not pushed; git diff --check clean; +172/-22 in gpu/dxil/lanes.rs and kernel.rs)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (debug, on the merged tree) -> 2901 passed, 2 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 1 no heap windows (opt-in), 1 no heap windows, 1 no GPU_UPLOAD heaps); failing: test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred (e2e), both fail on base b2b1f10 alone too (2900 passed, the same 2 failed, 51 ignored). ps_ballot_tests in release on the GPU, GPU skips not allowed: 9 passed, 0 failed, both new tests included, no SKIPPED. This card has no wave64, so gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadop ran its wave32 legs only (its wave64 legs are left out without a SKIPPED line).
review: no blocking finding in the default path after reading the whole diff and the code around it. Most serious first:

  • XCL_PS_BALLOT_QUADOP is not part of any cache identity: neither the translated cache's (translated::identity_from_source in recomp/pso.rs, which tags XCL_DIRECT_COMPACT, XCL_DIRECT_COMPACT_NEST, XCL_X_LDS_ORDER and XCL_PER_LANE for the same reason) nor semantic_pipeline_setting (warm library). The doc comment covers one direction (with the switch on, a cached translation keeps its old form unless XCL_TRANSLATED_CACHE=0). The other direction is worse: a run with XCL_PS_BALLOT_QUADOP=1 and the cache on writes its misses in the quadOp form under the default identity, and later default runs load that form, which is the one that crashes the RDNA2 compiler, until the direct translator's sources change. It is off by default, and the tests do not need it (they use QUAD_OP_IN_TEST). So I agree with the earlier check's point: drop the switch, or tag the identity the way XCL_DIRECT_COMPACT is tagged (one line).
  • The change also reaches NVIDIA. In a translated cache of the retail title from our local stack (main 493dbd3 + D3D12.X: use whole form once ready for split ExecuteIndirect #3528 + Memory: the 16-window layout keeps 4 runtime sparse windows #3517 + local commits, before this PR), 411 of 2,886 direct-DXIL pixel-shader translations (351 distinct programs) have these ballots in the quadOp form: 25,329 quadOp calls, so about 8,400 ballots, up to 95 in one shader (ballot_ps is the only place the direct translator emits quadOp). With this PR each ballot reads its quad with 4 QuadReadLaneAt instead of 3 quadOp. ballot_ps_quad (WaveActiveBit(Or) since Recompiler: direct DXIL PS IR cuts (shared float decode, direct quad shuffles, predicate-derived lane masks) #3501) is unchanged and used by both forms. (Counted offline with dxc -dumpbin over the cache. The shader we saw hang this card with Recompiler: direct PS compares skip the per-quad mask where no helper bit is read #2571's forms off, Recompiler: direct DXIL PS IR cuts (shared float decode, direct quad shuffles, predicate-derived lane masks) #3501 (comment), has no quadOp, so this PR does not change it.)
  • The new form builds the same nibble: bit p is QuadReadLaneAt(cond, p) << p, as own << (lane & 3) ORed with the 3 QuadReadAcross*. Helper lanes are read the same way, the constant-false shortcut is kept, and both forms end in ballot_ps_quad + note_own_bit (the fix for the 16 pixels of the earlier head). The kernel.rs change is cfg(test) only and hands the test's choice to the translator's thread, like NO_SELECT_FOLD.
  • The DXIL test checks both forms in wave32 and wave64, also with the carry's operand from v_readfirstlane. The GPU test compares both forms pixel by pixel, including helper lanes on the triangles' edge.
    Not covered here: the AMD crash itself (no AMD card), wave64 hardware, and this PR on plain main in the world (see performance).
    performance: by default it adds 1 lane read per pixel-shader carry ballot (4 QuadReadLaneAt and their shifts instead of 3 quadOp and one shift). The DXIL also grows in the 411 shaders above, which costs some driver compile time on a cold cache.
    Measured, 60 s scripts/smoke.ps1, one run per side, the retail title, XCL_PREPARE=0, cold shader cache on both sides: base b2b1f10 543 frames, peak commit 15,844 MB; merged 505 frames (93 %), peak commit 16,191 MB (+347 MB, 102 %). 0 device removals and 0 crashes on both sides. These 60 s do not reach the world on this machine.
    World, one run with the PR's commit on our local tree (main 493dbd3 + D3D12.X: use whole form once ready for split ExecuteIndirect #3528 ba8592a + Memory: the 16-window layout keeps 4 runtime sparse windows #3517 0b4283d + 42 local commits, none in lanes.rs or kernel.rs), fresh shader preparation for each build, the same switches as our Recompiler: direct DXIL PS IR cuts (shared float decode, direct quad shuffles, predicate-derived lane masks) #3501 comment (XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_SPARSE_WINDOWS=4 XCL_GPU_WAIT_TIMEOUT_MS=45000 XCL_PREPARE=0 and others): neither run left the loading screens in the 200 s after the first heavy draws (that tree is slow, see Recompiler: direct PS compares skip the per-quad mask where no helper bit is read #2571); without the PR 0.23 presents/s, with it 0.22; 0 removals, no hang either way. One run per side, so this only shows no new hang or removal on NVIDIA, not a pace difference.
    verdict: not yet: XCL_PS_BALLOT_QUADOP is outside the translated cache's identity (see review); a one-line fix, the default path passes here
    hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 616.56, Resizable BAR off), AMD Ryzen 9 5950X, 32 GB, Windows 11 build 22631 / AI use: Claude Code (Claude Opus 5.5) ran the merge, the builds, the suite, both smoke runs, the world run and the offline DXIL count on this machine, read the diff and wrote this report; checked and posted by me.

…, not through quadOp

A pixel shader's ballots outside compares (`Lw::ballot_ps`: carry masks and the
like) collected their quad's 4 bits through `QuadReadAcrossX/Y/Diagonal`
(`quadOp`). An AMD RDNA2 driver (amdxc64 32.0.21030.2001 and 32.0.21045.29003,
RX 6700 XT) dies with a null read about 1 ms into the pipeline build of a
retail title's pixel shader (record 7381166e806847c9) in which 10 of the 27
such ballots take a value that derives from `WaveReadLaneAt`: the title ends
there at its first world load. Found by taking the pipeline apart: without its
PS it builds, without blending or in the plain wave64 form it does not; with
the ballots below, the same VS and description build in 4.3 s and the run goes
on.

The ballot now reads its quad with 4 `QuadReadLaneAt`, as the compare path
does for the same driver (xcl-dev#134, `lower_valu`): bit `p` is the quad's member
`p`, which is what `own << (lane & 3)` relied on too. Both forms record the
lane's own bit (`note_own_bit`, xcl-dev#3501). Only tests can ask for the `quadOp`
form: no setting changes the translation outside its cache identity.

Tests: `direct_ps_non_vopc_carry_ballot_reads_its_quad_lane_by_lane` (was
`..._uses_quad_op`) checks both forms' DXIL, also with the carry's operand
coming through `v_readfirstlane`, and that `v_cndmask` takes the carry itself;
`gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadop`
draws a carry mask, its DPP `ddx` (helper lanes on the triangles' edge) and the
mask's bit of the lane to the right in both forms and compares every pixel. The
test-only form is handed to the translator's thread like `NO_SELECT_FOLD`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ArtuArtaza
ArtuArtaza force-pushed the fix/ps-carry-ballot-quad-read branch from 4dd1796 to 4dd6842 Compare December 1, 2026 15:16
@github-actions github-actions Bot removed checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 1, 2026
@Aniseto

Aniseto commented Dec 1, 2026

Copy link
Copy Markdown

This is a new response on the same thread as my reports at 8363f77a (#3455 (comment)) and 4dd1796f (#3455 (comment)); the head moved to 4dd68427, so I am not editing those comments.

Ran the ps_ballot_tests module at 4dd68427 on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) 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, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib ps_ballot_tests -- --test-threads=1
9 passed; 0 failed; 0 ignored; 2761 filtered out      (exit 0)

All nine tests pass here at the new head, the same count as at 4dd1796f: the GPU test that draws both ballot forms and compares every pixel, plus the lane-by-lane DXIL tests. The description's full workspace suite and the title smoke runs were not repeated; no title was run.

Not tested: a retail title, the AMD crash scenario, the full workspace suite, Wine, Intel GPUs, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-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.

@ArtuArtaza

Copy link
Copy Markdown
Author

@Foniass @CharlyRien agreed on XCL_PS_BALLOT_QUADOP: it was outside the translated cache's identity, so a run with it on could leave quadOp translations for later default runs. 4dd68427 removes it. Only tests can select the old form now (cfg(test), like NO_SELECT_FOLD), and the code XCL emits by default is the same as at 4dd1796f.

Run on an RX 6700 XT, on this same tree just before it was committed:

  • cargo test -p xcl --lib ps_ballot_tests -- --test-threads=1 --nocapture: 9 passed, 0 failed, 0 skipped.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 2881 passed, 7 failed, 51 ignored, 4 SKIPPED. The 7 are the same 6 tests the description lists as failing on unmodified 9dfbe3ea (I did not rerun them on main today).

Smoke pair (scripts/smoke.ps1, 60 s, release, XCL_DEVICE_TYPE=lockhart XCL_PREPARE=0, A at 30 s and 45 s), the PR's merge base first, then 4dd68427, one run each. It shows no regression in the menus; it does not test the crash, which comes later than 60 s here.

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: AMD Radeon RX 6700 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 13578 MB
xcl-smoke v1
commit: 4dd6842738511d3de90b272d1f87aa745d165799
gpu: AMD Radeon RX 6700 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1543 (PresentX 1543)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13683 MB

@Aniseto thanks for the run on the new head.

The description still names 4dd1796f and the switch; the PR description check is red until it has the second block.

(Change, runs and reply by Claude Code with Claude Opus 5.5, sent from my account.)

@Gevroska

Gevroska commented Dec 1, 2026

Copy link
Copy Markdown

@ArtuArtaza I confirmed the cache issue in both directions on 4dd1796f, merged locally into b2b1f109. I used the same synthetic wave32 carry shader in six fresh processes.

  • With the cache seeded under the default setting, switching XCL_PS_BALLOT_QUADOP=1 returned the byte-identical default DXIL: 0 quadOp and 9 quadReadLaneAt calls.
  • With the cache seeded under XCL_PS_BALLOT_QUADOP=1, switching back to default returned the byte-identical alternate DXIL: 3 quadOp and 5 quadReadLaneAt calls.

Both warm hits skipped translation. With XCL_TRANSLATED_CACHE=0, each direction rebuilt the requested form. Separately, the carry-ballot pixel-output test passed on my RTX 3080 with zero skips.

This confirms the failure that removing the production switch in 4dd68427 addresses. My local runs cover the earlier revision only.

AI disclosure — Codex GPT-6.2 Sol ran the tests. A separate GPT-6.2 Sol agent verified the original artifacts. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@Gevroska

Gevroska commented Dec 1, 2026 •

Copy link
Copy Markdown

merge-check
base: 6bfb5c5
head: 4dd6842
merge: clean (361bda0b)
build: cargo build --workspace passed
tests: 2,905 passed, 0 failed, 51 ignored. The suite also reported 28 runtime skips covering native wave64, heap windows, driver-cache control and the D3D12 debug layer. I disabled dev/test debug symbols on the retry after the first compile ran out of disk space. Test selection and assertions stayed the same.

review: All nine pixel-ballot tests passed on my RTX 3080. GPU readback matched the expected output for both lowering forms across eight literal-carry draws. The disassembly check also covered a carry derived from WaveReadLaneAt. Source review confirmed that the old XCL_PS_BALLOT_QUADOP switch is gone and the direct DXIL cache key changed.

performance: I ran one matched 60-second retail game startup on each revision, main first, with no inputs, on-demand shader compilation and a fresh XCL cache for each run. Main showed 1,301 frames (1,301 PresentX) and peaked at 15,844 MB commit. The merge showed 1,430 frames (1,431 PresentX) and peaked at 15,905 MB. Both exited cleanly with zero crashes or device removals. The NVIDIA driver cache was shared across runs, so I would use this pair as a startup regression check only.

verdict: not yet. The cache test stopped before GPU dispatch. I still can’t confirm cold or warm behavior on the revised head, or whether it rejects entries from the old alternate cache. The affected AMD RDNA2 driver also needs a check on that hardware.

hardware / tool and model: NVIDIA GeForce RTX 3080, driver 32.0.16.1692, Ryzen 7 5700X, Windows 11 Education 25H2 (26200.9457). OpenAI Codex GPT-6.2 Sol ran the tests. Independent Codex agents reviewed the source and evidence. Their exact models were not recorded. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 1, 2026
@CharlyRien

Copy link
Copy Markdown
Contributor

merge-check
base: 6bfb5c5
head: 4dd6842
merge: clean (local trial merge 875cebf8, not pushed; git diff --check clean; +164/-22 in gpu/dxil/lanes.rs and kernel.rs)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (debug, on the merged tree) -> 2903 passed, 2 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 1 no heap windows (opt-in), 1 no heap windows, 1 no GPU_UPLOAD heaps); failing: test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred (e2e), the same 2 that fail on main b2b1f10 alone on this card (not rerun on 6bfb5c5). ps_ballot_tests in release on the GPU, GPU skips not allowed: 9 passed, 0 failed, the PR's tests included, no SKIPPED.
review: none blocking. 4dd1796..4dd6842 changes only lanes.rs: the XCL_PS_BALLOT_QUADOP switch is gone, the quadOp form is reachable from tests only (QUAD_OP_IN_TEST, cfg(test)), so a cached translation can no longer get the old form under the default identity (the point of the earlier checks). Outside tests quad_op is false: the code XCL emits is the one I checked on 4dd1796 (#3455 (comment), with its smoke and world runs). Tier 1 (translator only), so no new smoke or title run on this head.
performance: as in my check of 4dd1796 (one more lane read per pixel-shader carry ballot; 60 s smoke there 93 % of main's frames, +347 MB peak commit, no removal); not remeasured on this head.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 616.56, Resizable BAR off), AMD Ryzen 9 5950X, 32 GB, Windows 11 build 22631 / AI use: Claude Code (Claude Opus 5.5) ran the merge, the build, the PR's tests and the suite on this machine and read the diff; checked and posted by me.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up review (head 4dd6842, since 4dd1796, diff read, not a merge-check):

  • XCL_PS_BALLOT_QUADOP outside the translation's cache identity: fixed. The switch and ps_ballot_quad_op are gone; only tests can pick the quadOp form, through the cfg(test) cell QUAD_OP_IN_TEST (lanes.rs ~19-24, ~916-919; kernel.rs ~255-264), and other builds always emit the quadReadLaneAt form.
  • Crash fix checked only on the first head; frame cost not measured: partly fixed. The code emitted by default has not changed since 4dd1796f, which a merge-check on the PR showed building on an RX 9070 XT and an RDNA2 iGPU where main crashes. The cost of 4 quadReadLaneAt against 3 quadOp per pixel-shader ballot is still only covered by 60 s smoke runs capped at 60 presents per second, as Not tested says.

New: none.

Fine: the lane-by-lane form sets bit p from quad member p, matching the old own << (lane & 3) layout, and both forms end in the same ballot_ps_quad + note_own_bit; the DXIL test checks both forms in wave32 and wave64 with and without a v_readfirstlane operand; the GPU test compares both forms pixel by pixel including helper lanes on the triangles' edge.

AI review: Claude Code (Claude Opus 5.5), 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:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs:amd-test Needs a test report or merge-check on an AMD GPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants