shader: lower v_permlane16_b32 and v_permlanex16_b32 in direct compute #3022
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3022"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T06:07:41Z.
Fixes #3021. Part of #2935. Target branch
main. The measured requests reach these ops only once DPP16 row operations are lowered; that is #3010, now onmain.Change (
src/gfx1013_compute_native.cpp,src/gfx1013_direct_compute.inl): direct compute now lowersv_permlane16_b32andv_permlanex16_b32.iof a 16-lane row readsS0from lanesel = ({S2, S1} >> (4 * (i & 15))) & 15.permlane16reads from the same row.permlanex16reads from the other row of the same 32-lane half.op_sel[0]is FI andop_sel[1]is BOUND_CTRL.op_selbits, abs, neg, clamp and omod;vcc_lo,vcc_hion the wave64 path, exec, m0, null), and an S0 that is not a VGPR. In wave32,vcc_hiis ordinary scalar data;permlane16) or 32 (permlanex16).Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on
main6057071bplus this branch. The D3D12 debug layer is not installed. Release and Debug (devpreset) builds both pass.native_permlane_hardwarepassed. Seven wave32 programs ran in two 64-thread groups with sparse guest EXEC. All 2,064 output words matched a CPU reference, sentinels included. The programs are:x16with BOUND_CTRL and a literal-plus-SGPR selector;x16with FI and two SGPRs;x16with inline 0 selectors;permlane16with BOUND_CTRL and a literal-plus-SGPR selector;permlane16with two SGPRs;x16with an SGPR in S1 and a literal in S2;x16with the same literal in S1 and S2.The selectors differ per row lane, and S1 differs from S2.
native_permlane_controlspassed. A wave32 request and a split-wave64 container compile. These are refused:op_selbit 2;x16with 16 threads, andpermlane16with 8;Wave64 is covered by that compile case only, not by a readback.
The 9
native_dpp*,native_lane*,native_wave*,native_readlane*andnative_permlane*tests pass.Mutation checks, run by hand; each fails the hardware check:
x16;Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests.cpp-migration999e17cdplus #3010, before #3010 reachedmain).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T06:48:54Z.
Review: COMMENTED
Independent retest at
125f5313stacked on #3010 (7325dd17). I rebuiltcompile_dxilandnative_store_replayand rannative_permlane_controlsandnative_permlane_hardwareseparately withctest --preset <dev|release> --no-tests=error -V -R '^native_permlane_(controls|hardware)$'. Both passed in Debug and Release/O2without skips. The hardware replay matched 128 result words plus all guards in each of six cases with the inbox D3D12 runtime (Windows 11 build 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, replay debug layer off). No WARP test is registered.The AMD RDNA 2 ISA guide, §12.12 confirms the selector packing, row pairing and FI/BOUND_CTRL bit positions. The desktop readback exercises the proposed inactive-source model. The exact preserve-versus-zero behavior still needs a native RDNA 2 result. All 47 measured requests are flagged wave64, while the current wave64 control only compiles. Please coordinate with #3006 on a split-wave64 bit-exact readback with different lower/upper EXEC masks, so selecting the wrong half fails at a known lane.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T15:50:51Z.
#3010 is now on
mainas1ec2c938. I checked125f5313againstmain354c6870: an immediate base change still shows the pre-squash #3010 commit and conflicts indocs/experiments.md. Please rebuild this PR branch from currentmainwith only the permlane change, then change this existing PR’s base tomain. Keep the prior review and the inactive-source scope note linked. I’ll recheck against the new head withnative_permlane_(controls|hardware)and the DPP16 row regressions.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T17:41:43Z.
Rebuilt from current
main(63a30dc1) with only the permlane change (b99a223f); the base is nowmain, and the description is updated.125f5313and the scope note on the inactive-source rule still apply: https://github.com/R0Y00/Xbox2Windows/pull/3022#pullrequestreview-6084511164.sa, so its 32-lane requests stay on the wave32 model if #3006 lands; without #3006 the bit is ignored.native_permlane_controls,native_permlane_hardware,native_dpp_row_controls,native_dpp_row_hardware,native_dpp_quad_controlsandnative_dpp_quad_hardwarepass.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-27T18:21:28Z.
Thank you for the rebuild onto
mainand for the careful write-up. I reviewed042cb0b8and its merge onto currentmain(80668b97). The wave32 lowering matches the RDNA2 pseudocode as I read it: selector packing, row pairing, and FI/BOUND_CTRL handled like the existing DPP lowering.native_permlane_controlspasses on both trees in a Release cross build. A few requests before merge:main, requests always use the wave32 model, so the wave64 branch oflower_permlaneis only compiled, never read back. As a check, I changedauto exec = wave64 ? select(upper_half, read(127), read(126)) : read(126);toauto exec = read(126);. Bothnative_permlane_controlsandnative_permlane_hardwarestill pass. Since all 47 measured requests are flagged wave64, could you either add a split-wave64 readback with different lower/upper EXEC masks (with #3006 or through a container replay), or refuse the two ops on the wave64 path until that readback exists, and open a linked follow-up issue? If the maintainer prefers to track it in #3006, a link to that decision is enough.prtest preset, which selects neithernative_permlane_controlsnornative_permlane_hardware. The 69 tests in the Windows job don't include them, so your RTX 5080 Release run is the only Windows evidence at this head. Could you add the exact command, the driver version, Windows build and debug-layer status, and a Debug run (e.g.ctest --preset dev --no-tests=error -V -R '^native_permlane_(controls|hardware)$')? A manual "Windows checks → Run workflow" run of the branch would also do for the controls.docs/experiments/native-permlane.mdstill says "on #3010 (7325dd17) plus this change". That commit is #3010's pre-squash head and isn't inmain's history. Could you copy the two bases from the PR body into the doc: the tested commit (main63a30dc1plus this branch), and the base of the 2,689-request count (cpp-migration999e17cdplus #3010)?Smaller points, take or leave:
v_permlanex16_b32 v1, v2, 0x492f0381, 0x492f0381for gfx1013. It encodes word 1 as0x03FDFF02, the same as the "two literals" control, and only rejects two different literals. Either accept S1 = S2 = the same literal (operand32already returnsi.literalfor both) and make that control a compiled case, or reword the refusal message as a deliberate scope limit.|| i.neg || i.abs || i.clamp || i.scalekeeps the suite green. One row (e.g. clamp, word 00xD7788001) would pin it.vcc_hi(s107) is accepted as a selector, which matchesinitialize()'s treatment of s107 as ordinary scalar data. The body's "vcc" in the refused list could say "vcc_lo (and vcc_hi in wave64)".i.src[0] == 255clause removed, an S0 literal is still refused by the lowering ("S0 must be a VGPR"). The clause is redundant; keep or drop as you prefer.For the record, on a different stack (RTX 4070 Ti SUPER, Linux driver 550.163.01, vkd3d-proton under Proton experimental-11.0, debug layer off),
native_permlane_hardwarepassed all six readbacks at042cb0b8and on its merge withmain80668b97. Your three manual mutants (same row forx16, swapped S1/S2, ignored BOUND_CTRL) each failed it, as did ignoring FI and testing the destination lane's EXEC bit instead of the source's. Only the wave64 EXEC-half change above stayed green.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T19:43:04Z.
Thank you for the review and for the second-stack run. Rebased on
main6057071b; the new commit isb912ad58. The description is updated to match.mainthe wave64 branch oflower_permlaneis only compiled by the container control, never read back, so yourread(126)mutant survives. The experiment note now says so. The wave64 path is not refused here: the maintainer asked to coordinate the split-wave64 readback with #3006 (https://github.com/R0Y00/Xbox2Windows/pull/3022#pullrequestreview-6084511164).ctest --test-dir out/build/release -R "native_permlane|native_dpp|native_lane|native_direct_container", 9 of 9 passed.cmake --preset dev,cmake --build --preset dev --target compile_dxil native_store_replay, thenctest --preset dev --no-tests=error -R '^native_permlane_(controls|hardware)$'. Both passed.main6057071bplus this branch. The 2,689-request count comes fromcpp-migration999e17cdplus #3010.Smaller points:
cross-shared-literal. Its words are0xD7780001 0x03FDFF02 0x492F0381, with eight different selectors, the same for row lanes 0-7 and 8-15. A literal in S0 is still refused, and the message now says exactly that: "permlane S0 cannot be a literal".0xD7788001 0x00341902) now pins it. Removingi.clampfrom that check failsnative_permlane_controls.vcc_hi: the note now says that selectors refusevcc_lo, andvcc_hion the wave64 path. In wave32,vcc_hiis ordinary scalar data.i.src[0] == 255clause: I kept it as the decoder-level refusal for a literal S0.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:29:35Z.
Review: APPROVED
I reviewed
b912ad58merged overmainf6206217. The merge is clean (tree03bd58f5) andgit diff --cached --checkis clean.What I traced.
Against the RDNA2 definition:
Lis nibbleL & 7of S1 for lanes 0..7 and of S2 for lanes 8..15;v_permlane16_b32reads lanerow_base | selof the current row;v_permlanex16_b32flips row bit 4, so each row reads the other row of its pair.op_sel: bit 0 is FI and bit 1 is BOUND_CTRL. Without FI, an inactive source lane gives 0 under BOUND_CTRL and keeps D otherwise. Guest EXEC still predicates the write.
Refusals: S0 must be a VGPR, and a literal S0 is refused in the decoder. Modifiers and the other op_sel bits are refused.
Earlier requests: R0Y00's rebuild from
mainand the base change are done. JohnConnorNPC's points are each answered at this head:vcc_hiwording is fixed.The split-wave64 readback is deferred to #3006, as the maintainer asked.
What I ran. I built
compile_dxil native_store_replay native_compute_ir_dump offscreen_checkindevandrelease, then ran/O2.native_lane_spill_descriptor_warpreports a 77 skip in both builds; it is an existing WARP test that this PR doesn't touch.native_permlane_hardwarematched 128 results and all guards in each of its seven cases, includingcross-shared-literal.maind6912f58, the PR'snative_permlane_check.pyfails in both modes.controlsgetsrequests=7 compiled=0 refused=7("direct DXIL lowering for v_permlanex16_b32"), and thehardwarereplay compile fails.Mutants in
src/gfx1013_direct_compute.inl. For each, I rebuilt indevand rannative_permlane_(controls|hardware):x16keeps its own rowcross-literal-boundword 8:0x0vs0x25)0x2cvs0x25)0x21vs0x0)cross-sgprs-fiword 24:0x21vs0x15)Restored and rebuilt afterwards;
git diff --quietis clean.Non-blocking.
v2/v3/s13). No control usesvcc_lo,m0orexecas a selector. The refusal is a scope limit, not a correctness need, sinceoperand32can read those numerically. One control row would pin it.prCI preset doesn't selectnative_permlane_*, so this run and yours are the Windows evidence at this head.Verdict: approve on
b912ad58.Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off.
CI:
Build and test on Windowspasses onb912ad58.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T19:09:19Z.
Review: COMMENTED
LGTM — approved, no blocking issues.
Lowers
v_permlane16_b32andv_permlanex16_b32in direct compute. Permlane unpacks uniform selectors from S1/S2, picks from same row (x16) or paired row (x16_b32), handles FI/BOUND_CTRL correctly. DPP row ops added with correct lane shifting. Wave64 handled correctly with s126/s127 EXEC halves, physical lane indices correct. Inactive-source semantics match DPP rules. Test suite comprehensive with mutation coverage.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:29:35Z.
Review: APPROVED
LGTM — approved, no blocking issues.
Lowers
v_permlane16_b32andv_permlanex16_b32in direct compute. Permlane unpacks uniform selectors from S1/S2, picks from same row (x16) or paired row (x16_b32), handles FI/BOUND_CTRL correctly. DPP row ops added with correct lane shifting. Wave64 handled correctly with s126/s127 EXEC halves, physical lane indices correct. Inactive-source semantics match DPP rules. Test suite comprehensive with mutation coverage.