shader: support defined numeric M0 in direct compute #3205
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3205"
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 xiaoqi72665 on 2026-11-27T21:37:45Z.
Fixes #3202. Refs #2935, #3143 and #3172.
Change
Support defined numeric M0 (RDNA2 scalar encoding 124) in the direct compute frontend. Reuse the existing per-wave register storage, numeric state analysis and CFG joins. Allow the 32-bit scalar move destination and explicit numeric operand reads; keep M0 unbound on entry. This adds eight production lines and removes four. No new state structure or memory-addressing support.
The raw-buffer-load decoder is unchanged: #3172 owns the off/offen and nonzero SGPR-offset work, and still explicitly excludes M0. M0 buffer offsets remain refused. This is a separate register-support prerequisite, not a claim to implement implicit LDS, relative VGPR indexing, interpolation, or all M0 instruction forms. The existing 64-bit pair restrictions remain.
Actual verification
Base
673a9f2c95, candidate6307e67200.d99e0aerejected s_mov_b32 m0,4 and subsequent read. On the candidate, both compile via native_cpp; raw loads with M0 still hit the same decoder refusal.Public source-generated fixtures only. AI-assisted; locally tested by Buhe (@xiaoqi72665).
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:01:28Z.
Review: CHANGES_REQUESTED
I tried to review
6307e672over currentmain6cc46a3c. The trial merge conflicts in both source files, and the conflicts are semantic, not just textual. Three PRs landed after this PR's base673a9f2cand changed the same three spots:Emit::require_numeric(src/gfx1013_compute_native.cpp): #3180 (63fd6ea8) gave it alimitparameter (reg < limit, default 106), andoperand32now passessgpr_limit. This PR'sreg <= 105 || reg == 124has to be folded into that form, for example(reg < limit || reg == 124). If the conflict is resolved by keepingmain's side, reads of M0 would skip the numeric check entirely, since 124 is above every limit. Yourundefinedandpartial_joincontrols should catch that, so please make sure they still run after the rebase.operand32(src/gfx1013_direct_compute.inl): the samerequire_numeric(i, n, sgpr_limit)call. Thenumeric_m0condition itself merges unchanged.s_mov_b32/s_mov_b64destination guard: #3192 (2b7ebf18) replaced!(wave64 && i.dst == 127)with anexec_hiflag that also covers wave32s_mov_b32 exec_hi. Both clauses need to stay:!exec_hi && !(compute && i.dst == 124 && n == "s_mov_b32").Reading of the change itself, from the diff only, not run:
unbound, so a read before any write refuses.soffsetafter #3172, whose decoder admits SGPRs 0 to 105 only.operand32excludes MUBUF/MTBUF/GLOBAL (allEncoding::Mubuf) and SMEM, so M0 cannot become a memory offset through that path either.I found nothing else to change there. I stopped at the conflict, so I have not built or run this head.
Requested: rebase onto current
mainwith the three resolutions above, then re-runnative_m0_controls/native_m0_hardware. I'll retest the new head.Environment: Windows 11 25H2 build 26200.9974; Git trial merge only.
CI:
Build and test on Windowspasses on6307e672against its own base.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by xiaoqi72665 on 2026-11-27T22:04:49Z.
Thanks for the precise conflict analysis. Rebased #3205 onto
a5c02dbas906d027, preserving all three semantics: numeric M0 with the caller's SGPR limit, the sgpr_limit call, and the upstream EXEC_HI exception alongside the M0 s_mov_b32 exception. Both Debug and Release native_m0_controls passed, including undefined and partial_join. The stock native_m0_hardware fixture skips on this host; relinking the freshly built replay objects with the existing app-local Agility 1.620.2 export and using the upstream --direct-warp mode gave exact 2064-DWORD readbacks on RX 7900 XT and WARP in both builds (4/4, 8256 DWORDs). No changes to the test oracle or M0 scope. The prior commit is retained locally. Debug layer unavailable. Buhe; AI-assisted.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T22:15:13Z.
Review: COMMENTED
I reapplied exact head
906d0271overmain886a5a28(trial tree382502fb) without a conflict. I checked the three areas called out on the prior head: the caller's SGPR bound is preserved, the numeric M0 read still receives that bound, and the wave32EXEC_HIand M0s_mov_b32destination exceptions coexist. MUBUF/SMEM still exclude M0. Debug and Release /O2 each passednative_direct_container,native_m0_controls, andnative_salu_shift64_controlsfrom a source build, with no skips. These are compiler/validation results; the GPU-vendor results above are the author's. @pigalot, the rebase addresses the conflicts you identified on6307e672; could you update your review for the new head?Follow-up on the same trial tree: the stock native_m0_hardware fixture passed in both Debug and Release /O2 on RTX 4060 Laptop (32.0.16.1656, Windows 11 26200.9974), with an exact 2,064-DWORD comparison per run and no capability skip. The standalone compute replay does not enable the D3D12 debug layer.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:37:57Z.
Review: APPROVED
I retested
906d0271merged overmainc1de64a5. The merge is clean (tree6af2f070) andgit diff --cached --checkis clean. This supersedes the changes-requested review on6307e672.Earlier findings. All three are addressed at this head:
Emit::require_numeric: the check is now(reg < limit || reg == 124). A caller's lowerlimitis kept, and M0 is always checked.operand32: it still passessgpr_limittorequire_numericfor the numeric M0 read.s_mov_b32/s_mov_b64destination guard: #3192'sexec_hiexception and the newcompute && i.dst == 124 && s_mov_b32exception are separate clauses. A wave64s_mov_b64into M0 stays refused.What I traced.
unbound, so a read before a defining write is refused, and a join of defined and undefined stays refused.What I ran. I built
compile_dxil native_store_replay native_compute_ir_dumpindevandrelease, then ran/O2. The skip (77) isnative_lane_spill_descriptor_warp, an existing WARP test this PR doesn't touch.native_m0_hardwareran here, with no skip, and matched the 20 value words and all 2,044 guard and untouched words for both groups.native_m0_controlsgives the expected refusal forundefined,partial_join,descriptor,pair_source,pair_destinationandmemory_offset.maind6912f58, the PR'snative_m0_check.pyfails in both modes.controlsis refused atnumericwith+0x1c: direct scalar move destination, and thehardwarereplay compile fails.Mutants. For each, I rebuilt in
devand rannative_m0_(controls|hardware):require_numericwithoutreg == 124undefinedcompiles)unboundundefinedcompiles)memory_offset)pair_destination)s_mov_b64pair_destination)Restored and rebuilt afterwards;
git diff --quietis clean.Verdict: approve on
906d0271.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 on906d0271.This reply was AI-assisted.