shader: place compute entry registers from COMPUTE_PGM_RSRC2 #1601
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1608"
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 Jess-Doit on 2026-11-24T14:56:23Z.
Change
Refs #1544. This covers the user SGPR span, the enabled group-ID SGPRs and the local-ID VGPRs. TG_SIZE is refused.
tools/compute_store_aot.pytook the group-ID registers from the caller (--group-reg,--group-reg-y,--group-reg-z).lower()now also takesrsrc2=(the program'sCOMPUTE_PGM_RSRC2), also available as--rsrc2.entry_registers(rsrc2)places what a gfx10 compute wave receives:USER_SGPR, bits 5:1, come first. The table pointer must lie within them.TGID_X/Y/Z_EN(bits 7–9), in X, Y, Z order with no gap for an omitted axis.TIDIG_COMP_CNT(bits 12:11) gives v0, v0–v1 or v0–v2, one local ID per VGPR. A local Y or Z it does not enable is not bound. The reserved value 3 is refused.TG_SIZE_EN(bit 10) is refused, as agreed in #1544. Its word layout differs between Mesa's GFX6–10 and GFX10.3+ readings, and the guest wave width is not established. A desktop readback cannot tell them apart, so that is left for a follow-up with independent evidence.Unchanged behaviour:
rsrc2, nothing changes.rsrc2,--group-reg*is refused.Fixture
tests/compute_entry_layout_check.pyuses source-built gfx1013 programs. They name the group IDs only through the registers the layout assigns; no group register is passed by hand. Each thread computes its dispatch coordinate on every axis it uses (group × size + local) and stores them as a record at an address built from those coordinates, so every thread has its own destination. All 320 words are compared, including sentinels between and after the records.COMPUTE_PGM_RSRC2enablesx_zs2, Zs3y_zs2, Zs3z_onlys2xyzs2,s3,s4x_user4s4The expected words are computed from the record layout, not from the translator. Each case also translates to the same source as when its group registers are named by hand.
Negative controls:
x_z,y_z,xyz, on the largest dispatch) must mismatch.x_z, Z dropped fromxyz;x_z, sos3becomes Y; X enabled undery_z; Y omitted underxyz, sos3becomes Z;x_user4with five user SGPRs;x_user4with two user SGPRs;TIDIG_COMP_CNT, in four cases.TG_SIZE_EN(alone, with group IDs, and in a translation),TIDIG_COMP_CNT3, a table outside the user SGPRs, andrsrc2with group registers.USER_SGPR). Unrelated bits (bit 0,TRAP_PRESENT, bits 13–14, an LDS size, bit 31) leave the placement unchanged. Values outside 32 bits and non-integers are refused.compute_store_check.py'sPITCH) translates the same withrsrc2as with its hand-named registers.binary <llvm-mc>assembles the fixture programs for gfx1013. It is added to the gfx1013 CI job, and the controls are added to the Linux Python job andAGENTS.md.Verification
Tested
2bdd20db(ona3ac47a9; it merges cleanly with currentmain,7c5dac78) on Windows 10 22H219045.6456. Adapters: a GTX 1060 6 GB (10de:1c03, driver32.0.15.6094) and in-box WARP (10.0.19041.5794). DXC is the one the CMake configure found, and the D3D12 debug layer was enabled.compute_entry_layout_{warp,hardware}and the existingcompute_store_aot_{warp,hardware}. All 68 debug-layer summaries in each configuration readdebug_errors=0 debug_warnings=0.tests/docs_links_check.py: passed.binary: passed with a local LLVM 23.1.6llvm-mc. CI uses LLVM 15.The output was the same on both adapters and in both configurations:
This PR and #1611 (image stores) both add a keyword to
lower(). Whichever merges second needs a one-line merge.Not covered
TG_SIZE_EN), refused as above.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T15:12:39Z.
Review: CHANGES_REQUESTED
This head still emits a TG_SIZE word using bits 11:6 and leaves the other reported layout open. As agreed in #1544, keep TG_SIZE_EN rejected in this slice. Keep the enabled SGPR and VGPR mapping, and exercise noncontiguous Y/Z or X/Z bits, omitted IDs and distinct coordinates in more than one axis. The desktop readback currently reproduces the assumed packing rather than identifying the guest encoding.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:48:05Z.
Review: COMMENTED
Technical review (Linux only; no Windows, WARP or GPU run). The draw test
compute_entry_layout_{warp,hardware}(320-word readback per case) is therefore not reproduced here.Checked out the PR head (
2bdd20db, which refuses TG_SIZE_EN and adds the noncontiguous-axis cases) in a clean tree.What I ran:
tests/compute_entry_layout_check.py(decoding and translation controls): passes.tests/compute_entry_layout_check.py binary llvm-mc-19: all five fixture programs assemble for gfx1013. (The workflow pinsllvm-mc-15; this is an additional LLVM 19 check.)entry_registers()with unrelated bits set (TRAP_PRESENT bit 6, bit 13, bits 15..24, bit 31): the result is unchanged, so only USER_SGPR, TGID_X/Y/Z_EN, TG_SIZE_EN and TIDIG_COMP_CNT are read. User SGPR counts 15, 16 and 31 decode as given. Negative and 2**32 values raiseValueError.(rsrc2 >> 1) & 0x1f, bits 7..9,components + 1, with the reserved count 3 refused. The table pointer pair must satisfytable_reg + 1 < user_sgprs, which is the right bound for a 64-bit pointer.rsrc2together with--group-reg*is refused, and local Y/Z are bound only when both enabled and larger than one.Local mutation check on
tools/compute_store_aot.py, against the Linux controls (each reverted afterwards; tree clean):rsrc2allowed with group registers,local_axesignored: all caught.0 <= rsrc2 < 1 << 32range check removed: not caught. (Negative values would still hit the TG_SIZE_EN test, so only values of 2**32 and above slip through.)Suggestions (non-blocking): add one control with
USER_SGPRof 16 or more (for exampleuser(16) | TGID_X) and onersrc2with unrelated bits set (TRAP_PRESENT or an LDS size) that must decode like the plain value, so the field extraction is pinned from both sides.entry_registers(1.0)raisesTypeErrorrather thanValueError; only reachable from Python, since the CLI parses an integer.Still open as the earlier review says: the draw readback checks consistency with the layout this code assumes, not the guest's own encoding. TG_SIZE staying refused is the right call until independent evidence exists.
No defects found in the lowering.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T15:26:07Z.
Updated in
2bdd20db:TG_SIZE_ENis now refused, and the TG_SIZE word and--wave-sizeare removed.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T15:50:17Z.
Thanks @tedin7. Both suggestions are in, in the commit after the main merge:
USER_SGPRof 16 and 31 now place group X ins16ands31. Narrowing the mask to four bits fails the controls.TRAP_PRESENT, bits 13–14, an LDS size and bit 31.ValueError, and so do non-integers such as1.0, a string orTrue. Removing the range check fails the controls.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:09:10Z.
Review: APPROVED
The requested scope is in place: TG_SIZE_EN is refused, and the fixture distinguishes absent axes and the enabled X/Z and Y/Z bindings. The binary check is registered in the parallel Linux job. Windows Release passed the two compute_entry_layout hardware and WARP tests with no skips on this head.