Repository navigation
Recompiler: a pixel shader's carry ballot reads its quad lane by lane, not through quadOp - #3455
ArtuArtaza wants to merge 1 commit into
Conversation
ebcc28f to
8363f77
Compare
|
Ran the pixel-shader carry-ballot tests at System
Results
What this adds Not tested 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. |
…, 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)
|
merge-check base: 0fe06eb head: 8363f77 merge: clean. Tested local trial merge build: tests:
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. performance: 60-second release smokes on the Series S profile, title
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 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. |
|
@moombathepilot thanks for the merge-check. On your two points:
@Aniseto thanks for the NVIDIA run. Written with Claude Code (Claude Fable 5.2), from my runs on the hardware in the description. |
|
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 |
|
Confirmed test run on Radeon 7700XT, gets past 7381166e806847c9 shader without crashing at [143.158]. |
|
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: tests: 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 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: 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 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. |
|
@moombathepilot thanks for the second run. My settings are the same as yours (Series S,
@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 On the four texture failures: I cannot tie them to this change, which only touches pixel-shader translation. On this machine texture upload tests ( Written with Claude Code (Claude Fable 5.2), from my runs on the hardware in the description. |
|
Status on head @moombathepilot thanks for both merge checks. Could you look at the verdict again? On the two reasons in the second one:
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 Anyone with an RX 6000 card (RDNA2): this is the hardware that can confirm the fix. On I cannot queue my own PR on #3041. If someone who has read it thinks it belongs there, the request would be Written with Claude Code (Claude Fable 5.2), from my runs on the hardware in the description. |
|
merge-check claim |
|
merge-check |
8363f77 to
4dd1796
Compare
|
@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 4dd1796 is rebased on 9dfbe3e, and both forms now end in the same One thing next to it, in main and not in this PR: a pixel shader that reads a mask's word whole (a live What I could not run is NVIDIA: (Change and reply written by Claude Code with Claude Opus 5.5, sent from my account.) |
|
New head 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, The three named tests pass on this Blackwell desktop part with 16 GB of VRAM and driver 621.40, on a head rebased onto 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. |
… 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>
|
merge-check The changed path, on the retail title (release builds, default
This is #3544: on Windows/AMD, #3243's default crashes AMD's compiler on this pipeline, on RDNA4 and RDNA2. 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. |
|
merge-check |
|
Follow-up review (head 4dd6842, since 4dd1796, diff read, not a merge-check):
New: none. Fine: the lane-by-lane form sets bit AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 4dd68427: 2 finding(s). 1 are inline. These are on lines outside the diff:
crates/xcl/src/gpu/recomp/emit.rs:6842: This only changes the direct translator. The HLSL path's ballot_px, which ballot_fn picks for every non-compare PS mask, carry ballots included, still builds its quad bits from QuadReadAcrossX/Y/Diagonal(own), the same quadOp-of-a-WaveReadLaneAt-derived-value pattern that crashes amdxc64. Any pixel shader that falls back to HLSL, or any run with XCL_DIRECT_DXIL=0, still gets carry ballots of v_readfirstlane-derived values lowered to dx.op.quadOp, and the RX 6700 XT driver still dies in CreateGraphicsPipelineState. Changing ballot_px in the HLSL prelude to four QuadReadLaneAt(own_b, p) << p would fix both paths. The Lw::ballot_ps doc comment (lanes.rs:900) still says it matches HLSL ballot_px, which is no longer true.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| } else { | ||
| // (bit `p` = the quad's member `p`, the lane `4k + p`, as `own << (lane & 3)` above) | ||
| let mut q = z; | ||
| for p in 0..4u32 { |
There was a problem hiding this comment.
Not certain about this one: the new form quad-reads every member's predicate without masking it by that member's EXEC bit, unlike the compare path it copies (lower_valu.rs:1344-1361 ANDs each member with lanebit_at(el, eh, qbase|p)). In a quad where some lanes are hardware-inactive (after a discard/demote, or switched off by divergent control flow at the ballot), QuadReadLaneAt of those lanes is undefined, and that bit goes into the mask through ballot_ps_quad. A later s_cbranch_vccnz / s_and_saveexec on it can see lanes set that should be clear. The quadOp form had the same gap.
|
merge-check verdict: safe to merge |
|
I tested The run got past pixel shader record The title stayed up until the configured 720-second cutoff and exited with code AI use - Codex (GPT-6) checked the saved logs and drafted this comment. |
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
|
@ArtuArtaza #[cfg(test)]
let idioms = super::idioms::IDIOMS_IN_TEST.with(|c| c.get());
#[cfg(test)]
let quad_op = super::lanes::QUAD_OP_IN_TEST.with(|c| c.get());
// ...
#[cfg(test)]
super::idioms::IDIOMS_IN_TEST.with(|c| c.set(idioms));
#[cfg(test)]
super::lanes::QUAD_OP_IN_TEST.with(|c| c.set(quad_op));I was about to run an AMD merge-check on AI use: Claude Code (Claude Opus 5.5) found the conflict in a trial merge and drafted this note. |
…, 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>
4dd6842 to
1895d9e
Compare
|
Follow-up review (head 1895d9e, since 4dd6842, diff read, not a merge-check; checks red):
New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check
main 5eaadb5: this PR 1895d9e (clean checkout): verdict: safe to merge (the code; the red |
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 record7381166e806847c9. 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 throughQuadReadAcrossX/Y/Diagonal(quadOp). In this PS 10 of its 27 such ballots take a value that derives fromWaveReadLaneAt. 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 4QuadReadLaneAt, as the compare path does. Related: #134, #2996.Rebased on main
9dfbe3ea. #3501 had addednote_own_bittoballot_pssince 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 thequadOpform. 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 sameballot_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
quadOp81 → 0,quadReadLaneAt172 → 280 build in 4.3 s.How to test
git fetch origin pull/3455/head:pr-3455,git checkout pr-3455,cargo build --release -p xcl. Nothing to clear: an edit ofgpu/dxilchanges the translations' cache identity, and the driver builds again only the pixel shaders whose DXIL changed.mainwithXCL_PREPARE=0 XCL_PSO_TRACE=1 XCL_ACTIVITY=1(I usedXCL_DEVICE_TYPE=lockhart) and go into the world. It isunhandled exception 0xc0000005 in amdxc64.dllright afterdriver 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).driver compile finishfor that record and goes on.cargo test -p xcl --lib ps_ballot_tests(its GPU test draws both forms and compares the pixels) and ascripts/smoke.ps1pair.driver compile startline before a crash.What is in it
crates/xcl/src/gpu/dxil/lanes.rs:ballot_psorsquad_read_lane_at(cond, p) << pforpin 0..4 (bitpis the quad's memberp, whichown << (lane & 3)relied on too), then records the own bit as before. Only tests can ask for thequadOpform (cfg(test)). NoTRANSLATOR_VERSIONbump: agpu/dxiledit changes the direct translations' cache identity by itself.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 throughv_readfirstlane, and thatv_cndmasktakes the carry itself in both;gpu_direct_ps_carry_ballot_draws_the_same_lane_by_lane_as_through_quadopdraws a carry mask, its DPPddx(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, likeNO_SELECT_FOLD.Tested
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4(with--nocapture, on this tree just before it was committed as4dd68427): 2881 passed, 7 failed, 51 ignored (44 test binaries). The 7 are 6 tests, and all 6 failed with the same values on unmodified main9dfbe3eaon this card (ran them there alone, for4dd1796f; not again for4dd68427):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 ingpu/recomp), andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(parent and child run). 4SKIPPED(2 no heap windows, 1 no GPU_UPLOAD heaps, 1 cannot disable the driver cache).cargo test -p xcl --lib ps_ballot_testson the same tree: 9 passed, 0 failed. On4dd1796f: withnote_own_bittaken out of the new form both changed tests fail (the v_cndmask tests the mask's word; 32 pixels differ). WithXCL_ADAPTER=warp: 9 passed, the 3 GPU tests of the moduleSKIPPED(no wave32 / no wave64).8363f77a, against its main0fe06eb0; not repeated on9dfbe3ea): 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:0fe06eb0:driver compile start #3221: graphics PSO, 138304 B DXIL, record 7381166e806847c9at 259.6 s, the null read inamdxc64.dll+0x671f78at 260.3 s, the process ends (exit 0xc0000005).8363f77a: the pipeline of record7381166e806847c9(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, onebcc28f5) and 1 ms from its cache in that run (at 167.6 s).v_readfirstlanevalue) does not crash this driver in thequadOpform, 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: main9dfbe3ea(this PR's merge base, which ran first), then this PR's head.Not tested
4dd1796f: maind0832e61dies on this record on an RX 9070 XT (RDNA4) and an RDNA2 iGPU, and with this PR it builds on both.ps_ballot_testson an RTX 5070 Ti is in the comments, from before Recompiler: direct DXIL PS IR cuts (shared float decode, direct quad shuffles, predicate-derived lane masks) #3501.)quadOp); the 60 s frame counts above are my only measure. In the comments, 60 s, one run per side: 101 % of main's frames on an RTX 5070 Ti, 93 % on an RTX 3090 (cold cache).AI use
XCL_PS_BALLOT_QUADOPswitch 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