Repository navigation
Recompiler: direct PS compares skip the per-quad mask where no helper bit is read - #2571
Conversation
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
|
RX 6800M focused test report for #2571: the helper-lane pixel test starts, then the Windows test process exits with Setup: Windows 11 Home build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (driver Tested: Earlier-head control: The same exact test in a previously built clean #2514 binary ( Not tested: exact current AI use: Codex (GPT-6) and a Codex Luna subagent ran the guarded test and direct controls, verified commit and binary provenance, and wrote this report. |
|
Follow-up to my RX 6800M report above: Windows Application Error (Event ID 1000) records all three focused-test process crashes in This localizes the observed access violation to the AMD shader-compiler module on this machine. The earlier-head control faulted at the same offset, so it still does not establish a regression from #2571. I have no call stack or shader compiler dump and did not rerun the test for this follow-up. AI use: Codex (GPT-6) read the local Windows Application Error records and prepared this supplemental report. |
…read (port upstream xcl-dev#2571) LATER shared analysis: new backend-independent recomp/ps_masks.rs forward analysis lands whole with its CPU unit tests (3 pass on Linux). The DXIL consumption (ballot_ps_local, vopc forms, TRANSLATOR_VERSION) stays out for the future SPIR-V path.
|
Test report on AMD RDNA4 for ad0ded9 Tested
0 failed and no Not tested
AI use
|
|
Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2571 at head Environment
Targeted release tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib masks_read_lane_by_lane_or_restored_before_derivatives_take_the_cheap_forms -- --nocapture |
1 passed; 0 failed; 0 ignored; 1326 filtered out (0.00s) |
cargo test --release -p xcl --lib masks_read_across_lanes_keep_the_quad_form -- --nocapture |
1 passed; 0 failed; 0 ignored; 1326 filtered out (0.00s) |
cargo test --release -p xcl --lib a_kill_mask_of_live_lanes_stays_exact -- --nocapture |
1 passed; 0 failed; 0 ignored; 1326 filtered out (0.00s) |
cargo test --release -p xcl --lib gpu::recomp::ps_masks:: (3 consecutive runs) |
3 passed; 0 failed; 0 ignored; 1324 filtered out × 3 (0.00s, 0.00s, 0.00s) |
cargo test --release -p xcl --lib gpu::dxil:: |
183 passed; 0 failed; 3 ignored; 1141 filtered out (3.41s; dispatch_chain_native_wave64_builds_whole self-skipped on Wave32-only RTX 4060) |
cargo test --release -p xcl --lib gpu::recomp:: |
395 passed; 0 failed; 19 ignored; 913 filtered out (5.09s; Wave64-only and #1426-refused subcases self-skipped as expected) |
cargo build --release -p xcl --bin xcl |
Clean build (1m 09s, exit 0) |
Paired quiet 60 s retail smoke (title: 29640639)
Exact parent & merge-base (e1d84b7d9153f86a97d2ec5d209d196046fc0bea, cached baseline on the same machine):
xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1531 (PresentX 1531)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13982 MB
PR #2571 (ad0ded91d9fac08d27631c8c09b2b83c9c923adf):
xcl-smoke v1
commit: ad0ded91d9fac08d27631c8c09b2b83c9c923adf
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1605 (PresentX 1605)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13990 MB
Runtime log observations (xcl.log)
9220log lines,0[ERROR]/ device-removal / panic lines.- Final draw/memory telemetry in log:
19618 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample13990 MB committed by the process; video memory 6116 MB local, 4651 MB non-local.
Limits of coverage
- Pixel-shader mask classification (
ps_masks::, 3×) and fullgpu::dxil::/gpu::recomp::suites passed on RTX 4060 (with expected Wave64-only skips on Wave32-only Ada and existing#[ignore]dump/fuzz/benchmark tests left ignored). - No separate cold retail PS corpus DXIL-size or driver compile-time benchmark (
retail_ps_gallery/retail_shader_cost) or visual pixel-diff inspection was performed; the 60 s warm-cache retail smoke confirms clean runtime execution and zero regression ontitle: 29640639(frame-count delta vs. cached parent smoke reflects normal single-run startup variance, not this PR).
AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
|
Tested: Clean Not tested: Base comparison, native wave64, full suite, retail smoke and performance. AI use: T3 Code / Codex ( |
|
A possible wave32 gap in Read (head ad0ded9, and the same code rebased onto main 7a649b0):
Deduced: in wave32 pixel shaders translated by the direct path, a compare whose destination is still read whole could get the per-lane form, giving wrong counts or ballots on helper-lane / triangle-edge pixels. I have not identified any affected program in a run. Suggested: pass the wave width to Context: we read this while rebasing a test tree onto main 7a649b0 (RTX 3090 24 GB, driver 616.56, Windows 11 22631). Nothing was built or run for this note. AI use: found by an independent code review run with Claude Code (Claude Opus 5.5), checked and posted by me. |
ad0ded9 to
c1686b6
Compare
c1686b6 to
d24df30
Compare
… bit is read Since xcl-dev#2083 every pixel-shader compare on the direct route rebuilds its quad's four bits from quad reads of its operands and four WaveActiveBallot passes. On 610 retail PS that makes the DXIL 1.42x larger than before xcl-dev#2083; the driver time grew with it (+28 % to +81 % on an RTX 4060, measured in xcl-dev#2083). recomp/ps_masks.rs picks the cheapest form a compare's mask allows: the lane's own bit when the mask is never read whole, WaveActiveBallot | own bit (HLSL ballot_px_local) when it is read whole but nothing reads another lane's helper bit, cond ? EXEC : 0 for scalar operands. In the ballot | own form every lane's copy of the mask has the live lanes' bits and its own right, so EXEC predication, v_cndmask and carry-ins stay exact in helper lanes and so do the values derivatives read later. A forward taint analysis refuses it where a helper bit of another lane is read: a non-bitwise SALU, SCC / VCCZ, a scalar operand, DPP / ds_swizzle / bpermute / permlane / readfirstlane while EXEC carries it, or values a branch on such an EXEC lets differ between lanes. A subset of the entry EXEC (a kill's live-pixel mask) has no helper bits and stays exact. Kept compares OR in their own bit. 610 PS: 43 % own bit, 31 % ballot | own, 4 % cond ? EXEC : 0, 23 % kept; DXIL x0.784 (x1.109 of before xcl-dev#2083), all validate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d24df30 to
f4ee8ac
Compare
|
Correction, December 1. The RTX 4090 world replay reproduces the drop from 0.716 to 0.186 fps across an interval containing #3503, #3501, #2123 and #2571. I previously attributed that whole drop to #2571 alone. The comparison does not establish that. With #3318 applied throughout, the fast tree was The two measured 600 s runs finished on driver 621.40. The 300-540 s windows covered 170 presents in 237.51 s and 44 in 236.12 s. Three mesh/pixel shader pairs accounted for 68.8% of the summed GPU intervals in the slow four-frame sample ( I then added identical inner timestamps and GPU-side indirect argument readback to both trees. On the slow tree, the mesh/raster dispatch of this pair accounts for 2392 of its 2426 ms/frame across four frames. For draws executing 2 compute groups and 8 mesh groups with 2560×1440 color and depth surfaces, compute measured 0.0345 vs 0.0346 ms/draw. Mesh/raster measured 0.0408 vs 17.0510 ms/draw (188 fast and 209 slow draws). We have yet to measure emitted primitives and pixel-shader invocations, so the specific shader or coverage change responsible is still open. The fast diagnostic replay finished its 360 s limit. The slow one read all four frames at 245.8 s, then lost the device at 322.2 s ( Original November 30 measurements, with the tree label corrected below. Setup
Frames/s per minute, 300–540 s. The world arrives at 110–125 s in every tree, with the same 4,600–5,400 draws per present.
Also seen while bisecting, gone on current Not tested: AMD or other wave64 GPUs, isolated in-world frame time for this PR, or this PR on AI use: Claude Code (Claude Opus 5.5) built the trees, ran the bisection and the replays and wrote this report. The person running these tests checked it and asked for it to be posted. December 1 update: Codex (GPT-6) checked the Git ancestry, ran the follow-up replays and drafted the correction. |
|
Thank you @CharlyRien and @minimalhipster990 for catching both of these! Opened #3535 to fix @CharlyRien's wave32 register-width bug in @minimalhipster990 — if you have a chance to test #3535 (stacked with #3528) on your RTX 4090 world replay, please let us know if that lifts the 0.75 -> 0.20 fps drop. If it still stays at ~0.20 fps with wave32 liveness fixed, the next suspect is |
PR #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 #2571.
|
An RTX 3090 data point for the drop minimalhipster990 bisected to this PR on the 4090: we see the same thing, and on NVIDIA this PR seems to hide a GPU hang from #3501 rather than cause the slowdown on its own. Stack: main 493dbd3 (has #3535) + #3528 (ba8592a) + #3517 (0b4283d) + 42 local commits of ours (memory-window, alias-copy and diagnostic switches; none touches
What we read (not measured):
What we deduce: on NVIDIA (wave64 split into two wave32 halves) the #3501 The image in the two no-hang runs is not clean either (bald character and half-dark window, as on our earlier trees, see #505 / #3517), so this is a pace and hang result, not a rendering one. Hardware: RTX 3090 24 GB (driver 616.56, Resizable BAR off), Ryzen 9 5950X, 32 GB, Windows 11 22631. Not tested: AMD, main without our local commits. AI use: Claude Code (Claude Opus 5.5) ran the builds, preparations and runs, read the logs and wrote this; Antigravity CLI (Gemini 4 Neon) compared the two DXIL dumps (read-only); checked and posted by me. |
Since #2083 every pixel-shader compare on the direct DXIL route rebuilds its quad's four bits: quad reads of its VGPR operands and four
WaveActiveBallotpasses. That is right for masks whose helper-lane bits are read, but it is used for every compare. On the 610 pixel shaders of title ea3b5e4d, it makes the DXIL 1.42× larger than before #2083 (median 1.36×). @MarcosMDev measured +28 % to +81 % driver time on an RTX 4060 in #2083, and found that a mask onlyv_cndmaskreads needs no ballot.This PR picks the cheapest form each compare's mask allows, from a forward dataflow analysis (
recomp/ps_masks.rs):x64_masks) takes the lane's own bit, as @MarcosMDev's variant in Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083 did;WaveActiveBallot(c) | own bit(the HLSL path'sballot_px_local): a mask that is read whole, but where nothing reads another lane's helper bit. In this form every lane's copy has the live lanes' bits and its own bit right. So EXEC predication,v_cndmaskand carry-ins stay exact in helper lanes, and so do the values they compute for later derivatives. The analysis refuses the form where something reads another lane's bit:s_cmp,s_wqm,s_bcnt…), SCC or VCCZ of the mask, or a scalar operand;ds_swizzle/bpermuteor permlane while EXEC carries the mask (they read the source lane's bit of the reader's EXEC);v_readfirstlaneunder it (waterfall loops);A register known to be a subset of the entry EXEC (the live-pixel mask a kill updates) has no helper bits, so it is exact whatever it was computed from;
cond ? EXEC : 0: a compare of scalar / constant operands;None of the new forms has a quad op, so #134's AMD constraint holds: the kept compares still quad-read their operands, never the predicate.
On the 610 PS (110,821 compares) the forms split as:
The main reasons a compare is kept (shares of the whole-read masks, first reason only):
s_cbranch_vcczon the mask: 20 %;s_andn2_wrexec/s_mov execchanges inside a branch on it: 7 %;v_readfirstlane: 4 %;Part of #156. Follows #2083.
What is in it
crates/xcl/src/gpu/recomp/ps_masks.rs: the analysis (forms), with unit tests.crates/xcl/src/gpu/dxil/lower_valu.rs,lanes.rs:Lw::vopctakes the chosen form;Lw::ballot_ps_local; kept compares OR in their own bit.kernel.rscomputes the forms for pixel shaders (not the split form),compact.rskeys blocks on them, andTRANSLATOR_VERSION10.lanes.rstest: Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083's standalonev_cmpread only byv_cndmasknow expects no quad reads.TRANSLATOR_VERSION10 is also taken by my wave64-split PR; whichever lands second rebases to 11.Tested
xcl shaders --direct --windows 4 --split 0 --validateon the 610 PS of title ea3b5e4d (DXC 1.9.2609): 0 errors, all validated on both sides.dxc -dumpbin, function bodies) on 22 of them (the median and the largest growth under Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083, 20 random): 1,120,934 on main → 824,591 (×0.736); per program median ×0.79, best ×0.39. DXIL bytes on the same 22: 7.65 MB → 5.76 MB.CreateGraphicsPipelineState(driver shader cache off withShaderCacheControl) of each of the 22 PS with a pass-through VS, main and this PR alternating, two repeats (local harness, not in this PR):XCL_DIRECT_DXIL=all; VS and PS take the non-split direct form there): the 509 PS behind its cold graphics pipelines are 104.4 MiB of DXIL on main and 72.1 MiB here (−31 %), 16.62 M → 11.12 M instructions; VS unchanged; 0 failures.xcl shadersreporting patch (CLI only, not in this PR):ps_ballot_tests4 passed (with Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083'sgpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges: ddx, ddy and a waterfall loop on triangle edges);XCL_DIRECT_DXIL=all,gpu_ps_: 8 passed;XCL_DIRECT_DXIL=all,gpu_wave64_ps: 2 passed; 0 failed, 0 skipped.cargo test --release --workspace --no-fail-fast -- --test-threads=4on the RTX 5070 Ti (XCL_DXC_DIR= DXC 1.9.2609): 1426 passed, 0 failed, 46 ignored.SKIPPED(15 tests): the wave64 cases (no wave64 on this GPU) oflower_dxil/lower/ kernel tests,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware; the f16 / f32-conversion per-lane cases (refused forms);heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).XCL_ADAPTER=nomatch): 1426 passed, 0 failed, 46 ignored. Two earlier runs of the lib binary ended in an access violation insidetls::tests, which this PR does not touch; those tests pass alone (15 of 15 runs).XCL_DIRECT_DXIL=all:ps_ballot_tests4/0/0,gpu_ps_8/0/0,gpu_wave64_ps2/0/0 on both, noSKIPPED;gpu::: 700 passed, 3 failed, 22 ignored here, 697/3/22 on main (the 3 more are the newps_maskstests). The same 3 fail on both (f64 / f16 rounding on that stack) and the same 13 tests printSKIPPEDon both.Regression run
main:PR head:
Not tested
gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edgesexits 0xc0000005 before a result on this head and on an earlier head (Recompiler: scratch SADDR 0x7F addresses the offset alone (ST form) #2514, 57853e0); the Windows Application Error events put all three crashes inside amdxc64.dll at the same offset (0x6b097b). So the crash is in the driver and not new here; it does not show whether this PR's shaders reach it more or less often. The new forms add no quad op (Pixel shaders: masks hold the helper lanes (#105 item 1) #134's constraint).ballot_pxfor every whole-live mask.AI use
🤖 Generated with Claude Code