Repository navigation
Recompiler: use wave32 register width in direct PS mask analysis - #3535
Conversation
PR xcl-dev#2571 (1183cd4) called x64_masks::whole_live_out(insts, false) and x64_masks::uses(d) inside ps_masks::forms(), both of which assume wave64 register pairs. On wave32 pixel shaders (all non-split PS on wave32 NVIDIA GPUs), a compare writing sN was treated as killing s(N+1) in both liveness and forward taint, allowing an earlier compare into s(N+1) that is still read whole (e.g. by s_bcnt1, s_and_saveexec_b32, or a branch/loop) to be misclassified as Form::Own (no ballot) or have its taint cleared. Expose x64_masks::uses_for_width and x64_masks::whole_live_out_for_width, pass o.wave64 from dxil::kernel into ps_masks::forms(), and use single-SGPR widths for VCC/EXEC/per-lane/writes in wave32 mode. Reported by CharlyRien on xcl-dev#2571.
|
Ran the 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, Both counts match the description at this exact head: the four Not tested: the full workspace suite, native wave64 hosts, AMD and Intel GPUs, Wine, release profile, the RTX 4090 world re-test mentioned in the description, 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. |
|
Unattended test report. Posted automatically by an AI agent on the account owner's instruction. The owner has not read or checked it. It is not a code review and not a Tested tree: head Hardware and tools: NVIDIA GeForce RTX 3080 10 GB (32-lane waves only), driver 621.40, AMD Ryzen 9 7950X, Windows 11 Pro build 26200, rustc 1.100.0, debug build. Results
Outcome: no new test failure with this PR on this wave32-only card. Not tested:
AI use: Claude Code (Claude Opus 5.5) ran the builds and tests, and wrote and posted this report. |
|
RTX 4090 world replay of this PR stacked with #3528, as asked on #2571: the world stays at ~0.2 frames/s, the same as without this PR. The PR's code does run (301 of 1,714 pixel shaders come out smaller), but the frame rate does not move. One of the two runs with it lost the device ( Setup
Frames/s per minute, 300–540 s. The world arrives at 117–143 s in all four runs, with 4,500–5,500 draws per present; the GPU is at 100 % and 105–120 W in all of them.
Device removal in the measured run with this PR
Not tested: a second measured run with this PR, this PR without #3528, the change Zippp69 suggested for #3528, AMD or other wave64 GPUs, a GPU profile. AI use: Claude Code (Claude Opus 5.5) built the trees, ran the replays, compared the shader caches and wrote this report. The person running these tests checked it and asked for it to be posted. |
|
I tested the adjacent-register case on my RTX 3080 (driver
Pixel coordinates and alpha also matched on both builds. This confirms the fix reaches the rendered pixels on Ampere. I didn’t measure retail-game frame time in this test. AI disclosure — Codex GPT-6.2 Sol wrote and ran the test. A separate GPT-6.2 Sol agent checked the fixture and GPU readbacks. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
Following the RTX 4090 world replay, I found one confound in the proposed For every compare that keeps the quad form, To isolate the world-frame cost, I suggest three otherwise matched wave32 builds: an empty PS form map (the original quad path); AI use: Codex (GPT-6.2 Sol) checked the current source and public reports; Codex (GPT-6.2 Astra) independently traced the retained-compare path. |
|
merge-check claim |
1 similar comment
|
merge-check claim |
|
merge-check |
|
Merged at the checked head after a combined trial of #3400, #3386, #3393 and #3535 on AI use: Claude Code (Claude Opus 5.5). |
|
merge-check claim withdrawn AI use: an agent posted this withdrawal. |
|
I ran the three variants suggested in the retained-compare discussion. Disabling
Same Series X save and scripted input on driver 621.40. Release builds on AI use: Codex (GPT-6) prepared the diagnostic variants, ran the replays, checked shader widths and drafted this update. |
Summary
Fixes the wave32 register-width bug in
recomp::ps_masksintroduced by #2571 (1183cd437), reported by @CharlyRien.Root cause:
ps_masks::forms()calledx64_masks::whole_live_out(insts, false)andx64_masks::uses(d), both of which assume wave64 register pairs (wave64 = true). On wave32 pixel shaders (every non-split pixel shader on wave32 NVIDIA GPUs), a compare writingsNwas treated as killings(N+1)in both liveness and forward taint. An earlier compare writings(N+1)that is still read whole later (e.g. bys_bcnt1,s_and_saveexec_b32, or a branch/loop) could therefore be misclassified asForm::Own(noWaveActiveBallot) or have its taint prematurely cleared.Fix:
x64_masks::uses_for_widthandx64_masks::whole_live_out_for_width.o.wave64fromdxil::kernelintops_masks::forms(insts, o.wave64).wave64throughps_masks(vcc_mask,exec_mask,writes,per_lane,subset_after,live_subsets,run) so wave32 compares andSAVEEXEC/WREXECuse single-SGPR widths.wave32_compare_does_not_kill_neighbor_sgpr_in_liveness_or_taintcovering @CharlyRien'sv_cmp -> s21,v_cmp -> s20,s_bcnt1 s21sequence ands_and_saveexec_b32.Also a candidate fix for @minimalhipster990's RTX 4090 wave32 world FPS regression reported on #2571 (needs RTX 4090 world re-test to confirm whether this accounts for all of the drop or whether
Form::LocalonEXECbranches/loops is also involved).Regression run
Baseline (
main):PR head:
Tested
cargo test -q -p xcl --lib gpu::recomp::ps_masks::tests -- --test-threads=1(4 passed, 0 failed, including the newwave32_compare_does_not_kill_neighbor_sgpr_in_liveness_or_taint).cargo test -q -p xcl --lib ps_ballot_tests -- --test-threads=1on Windows 11 + RTX 5070 Ti (8 passed, 0 failed).44eeb0c75vs91244db94): 1708 frames (61/60/60 per 2 s), 0 device removals, 0 crashes, 17453 MB peak commit.Not tested
cargo test --workspacelocally (covered by CI).AI use
ps_masks.rs/x64_masks.rs, implementing the width-aware fix and wave32 unit tests, running local tests and smoke, and writing this description.