Recompiler: direct PS compares skip the per-quad mask where no helper bit is read #2571
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2571
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2571"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Kalmarv on GitHub · 2026-11-25 23:17 UTC · original
Kalmarv:direct-ps-local-masks→main· +610 −5 · 7 files · 1 commits · openSince #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 #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: #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.e44af706): main is ×1.415 in total, this PR ×1.109.dxc -dumpbin, function bodies) on 22 of them (the median and the largest growth under #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 #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).e1d84b7d,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
scripts/smoke.ps1, 60 s,XCL_DIRECT_DXIL=all(so the title's pixel shaders take the direct route this PR changes), main then this head back to back in one job. It ran beside two non-title jobs on the same machine, the same two during both runs.main:
this PR:
Tested by others
cargo test -p xcl --libon this branch merged with main: all passed, 0 failed, 26 ignored.Not tested
gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edgesexits 0xc0000005 before a result on this head and on an earlier head (#2514,57853e01); 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 (#134's constraint).ballot_pxfor every whole-live mask.AI use
🤖 Generated with Claude Code
@DavidM1911 on GitHub · 2026-11-25 23:28 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
@luckyteagirl on GitHub · 2026-11-26 00:46 UTC · original
RX 6800M focused test report for #2571: the helper-lane pixel test starts, then the Windows test process exits with
0xc0000005 (STATUS_ACCESS_VIOLATION)before reporting a pass or failure. I reproduced this on the exact PR head and on an earlier XCL head, so I cannot attribute the crash to this PR.Setup: Windows 11 Home build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (driver
30.0.13002.13003), Rust 1.99.0 MSVC, DXC/dxil1.9.2609.5.XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64,XCL_DIRECT_DXIL=1, withXCL_DXC_DIRset to the pinned DXC folder. Clean detached PR headad0ded91d9fac08d27631c8c09b2b83c9c923adf, isolated Cargo target.Tested:
cargo test --locked -p xcl --lib -j 1 gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges -- --test-threads=1 --show-output, under a monitor that stops on low free system commit or physical memory. Compilation completed and the harness printedrunning 1 test, the exact fixture name, and the DXC version. It then exited0xc0000005beforeok,FAILED, or summary counts. The guard did not stop this run. A no-build direct rerun of the same test binary with--exact --test-threads=1 --nocapturereproduced the same exit. There was noSKIPPEDline in either run; neither produced a test result.Earlier-head control: The same exact test in a previously built clean #2514 binary (
57853e017054d715cd46cd3c07cb70e58eddddc8) also exited0xc0000005at the same point, with no test result. That head has the samelanes.rsas currentmain, but other compiler files differ, so this is not an exact-main baseline.Not tested: exact current
main, a title smoke pair, or the full suite. The first cold build attempt stopped at the memory guard before any test ran; it is not counted as a test result. No game files were used.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.
@luckyteagirl on GitHub · 2026-11-26 01:14 UTC · original
Follow-up to my RX 6800M report above: Windows Application Error (Event ID 1000) records all three focused-test process crashes in
amdxc64.dllversion30.0.13002.13003, with exception0xc0000005at the same fault offset0x00000000006b097b. Two events name the exact #2571 test binary underwork-pr2571/target; the third names the earlier-head control binary underwork-pr2444/target. Their recorded times were 16:43:25, 16:44:57, and 16:45:55 local on 2026-11-25.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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.