Recompiler: specialize constant-selector v_perm_b32 in direct DXIL #2267
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!2267
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2267"
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?
@ramon-victor on GitHub · 2026-11-25 11:53 UTC · original
ramon-victor:opt/dxil-perm-b32-const-sel→main· +155 −0 · 1 files · 1 commits · openSpecializes
Lw::perm_b32(v_perm_b32) in the direct DXIL translator when the byte selector operandselis a compile-time constant, avoiding the ~125-instruction dynamic per-byte select tree emitted for arbitrary runtime selectors.For constant selectors (the standard RDNA2 idiom for packing, unpacking, byte-swapping, and sign-extending),
perm_b32_const:s0ors1) and byte-shift delta into a single shift (and omits the byte mask whenever the shift already zeroes the excluded lanes, reducing identity selectors like0x03020100/0x07060504to 0 ops and half-packs like0x05040100to 3 ops).8..=11) into a singleashr(orshl 16+ashr 31for bit-15 signs).12) and0xFF(>= 13) bytes directly into a single constant operand.Part of #1269.
What is in it
crates/xcl/src/gpu/dxil/prelude.rs: addLw::perm_b32_const, dispatched fromLw::perm_b32whenself.s.m.const_u64(sel)isSome(k)(dynamic selectors stay on the existing loop), plusperm_b32_const_tests::gpu_direct_perm_b32_const_selector_matches_isachecking DXIL validation, disassembly (select-tree elimination), and GPU execution across 10 selector patterns covering all selector classes (0..=3,4..=7,8..=11,12,13,255).On a seeded 600-program sample (
xcl shaders <archive> --direct --sample 600 --seed 3 --max-bytes 40000 --validate --threads 8, 573 programs within the cap, measured before rebasing onto1a0bbe3), all 573/573 validate cleanly (0validator failures):42,232,344 B -> 42,221,860 B(-10,484 B)302.63 ms -> 284.48 msTested
621.24, wave32), AMD Ryzen 7 5700X, Windows 11 Pro26300,rustc 1.99.0(x86_64-pc-windows-msvc), DXC/DXIL1.8.2502.11(Windows SDK10.0.26100.0).cargo test -p xcl --lib perm_b32_const_tests(debug):1 passed; 0 failed(validates DXIL, verifies select-tree elimination, and verifies 10 selector patterns × 8 inputs on the RTX 3070)..\scripts\test.ps1(debug, full workspace on headc665154):1251 passed; 0 failed; 46 ignored(25 GPU sub-checks skipped on this wave32 adapter: 21no wave64, 1no heap windows, 3 per-lane#1426refusals).cargo build --release -p xcl+ direct DXIL validation sweep on 573 sampled retail shader programs:573/573translated anddxil.dll-validated (0failures).Regression run
Not tested
XCL_SAMPLE_*env vars unset).AI use
perm_b32_constinprelude.rs, added DXIL disassembly and GPU ISA parity tests, and ran the full workspace test suite, 573-shader validation benchmark, and 60 s smoke regression run.@itsSio on GitHub · 2026-11-25 12:09 UTC · original
Tested
Independent Windows verification at clean
c6651548d9b30d1da3929e5cbbe7de1d9c6067ca. Both PCs used Windows 11 Pro build 26200, x64 MSVC, and unoptimized dev/test profiles with debug info off.cargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocaptureexited 0 on both.SKIPPED32.0.16.108832.0.16.1088cargo test -p xcl --lib --locked perm_b32_const_tests -- --test-threads=1 --nocapture: 1 passed / 0 failed / 0 ignored, no runtime skips, on each RTX card and the Radeon RDNA2 iGPU (driver32.0.21043.5001, same Ryzen 7 system and toolchain). The fixture validated DXIL, checked the generated select count, and compared 10 selectors ? 8 inputs against the CPU reference. The GPU fixture uses wave32 on all three adapters.Not tested
Native or split wave64 for this fixture, full AMD workspace, Intel, title samples, and performance.
AI use
Ran via Samaritan:
openai/gpt-6.2-sol): scoped and ran the Windows checks, audited the logs and fixture, and wrote this report. No subagents contributed.@luckyteagirl on GitHub · 2026-11-25 12:52 UTC · original
Independent RX 6800M check of PR head
c6651548d9b30d1da3929e5cbbe7de1d9c6067ca, including a local test-only native-wave64 variant of its new GPU fixture.Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5.XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64,XCL_DIRECT_DXIL=1; debugcargo test --locked -p xcl --lib -j 2 perm_b32_const_tests -- --test-threads=1 --show-output.gpu_direct_perm_b32_const_selector_matches_isapassed 1/0/0, no skip. ItsKernelOptionsis hard-coded towave64: false, so this is a wave32 execution on the wave64-capable adapter.KernelOptionstowave64: true, split: falseand its capability check fromwave32_supported()towave64_supported()(with matching skip text). The same selector/input fixture passed 1/0/0, no skip, on native wave64. This validates the PR's unchanged production lowering on the RX 6800M in native-wave64 mode. The two test-only edits were not committed; I restored the clean PR head afterward.The fixture checks 10 selector patterns across 8 input pairs and validates/disassembles the generated DXIL. I did not run the full workspace suite, a retail-title smoke, split-wave64, or a performance benchmark on this head. The local wave64 result is not an exact-head test-binary result; it uses the exact-head production code with the fixture mode changed as described.
AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows tests, made and restored the local fixture-only change, checked the logs, and drafted this report. No game data was used.
@nnonno91 on GitHub · 2026-11-25 15:14 UTC · original
Independent Windows test of
c6651548d9b30d1da3929e5cbbe7de1d9c6067ca. Constant-selector byte permutations matched the ISA reference on both adapters, including the upper half of split wave64 on RTX 5090.Tested
cargo test --locked -p xcl --lib perm_b32 -- --nocapture --test-threads=1. The wave32 fixture reported 1 passed, 0 failed, 0 ignored, and no logged skips on each adapter.cargo test --locked -p xcl --lib gpu_direct_perm_b32_const_selector_matches_isa -- --nocapture --test-threads=1. Enabled all 64 execution lanes and checked 10 selector patterns against eight inputs in each half of the wave, with reversed input order in the upper half. The logs confirmed native wave64 on the Radeon and split wave64 on the RTX 5090. Both reported 1 passed, 0 failed, 0 ignored, and no logged skips. DXIL validation and the select-count assertion also passed. Restored the clean checkout afterward.Not tested
Parent revision, performance, retail titles, or the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) prepared and ran the tests, verified the results, and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 17:05 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. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 18:41 UTC · original
Diff review, CI, and both AMD and NVIDIA checks passed on
c665154, but recentorigin/mainmerges turned this branchCONFLICTING/DIRTY. Please rebase ontoorigin/mainso it becomes mergeable again.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.