startup: draw the gfx2hlsl two-source integer vector operations #1696
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1703"
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 Asimmimx on 2026-11-24T17:25:24Z.
Refs #1149.
Change
The
VEC_Utable oftools/startup/gfx2hlsl.pylowers 16 two- and one-source integer vector operations to single HLSL expressions. No check ran any of them: no startup test names any of these mnemonics.v_add_nc_u32,v_sub_nc_u32,v_subrev_nc_u32,v_mul_lo_u32,v_and_b32,v_or_b32,v_xor_b32,v_not_b32,v_lshlrev_b32,v_lshrrev_b32,v_ashrrev_i32,v_min_u32,v_max_u32,v_min_i32,v_max_i32,v_mul_u32_u24This PR adds a check only. The translator does not change.
tests/startup_gfx2hlsl_lane_alu.pyis a small runner for table families. It reuses the pixel fixture ofstartup_gfx2hlsl_bit_alu_check.py, which reads three flat parameters per pixel, applies one operation per lane and exports v12..v15 to mrt0, so the renderer compares four exact words. Per family it provides:llvm-mc -mcpu=gfx1013pixel bodies, plus abinarymode that reassembles them;tests/startup_gfx2hlsl_int_alu_check.pyis the first family. Lanes alternate the_e32and_e64spellings;v_mul_lo_u32exists only as VOP3. The references follow the AMD RDNA 2 ISA reference with plain integer arithmetic, not the lowering's expressions:revshifts take S1 shifted by S0[4:0];v_ashrrev_i32is an arithmetic shift;v_mul_u32_u24takes the product of the low 24 bits.Each operation has eight input sets, which is two draws. They include shift counts above 31 (33, 32,
0xffffffe1), sign-bit values for the signed and unsigned pairs, products that wrap, and sources with bits above bit 23.The mutations (one per operation):
v_mul_lo_u32, a full-widthv_mul_u32_u24;The tests are registered as
startup_gfx2hlsl_int_alu_controlsandstartup_gfx2hlsl_int_alu_{warp,hardware}next to the bit-operation tests. The check is added to the LLVM 15binarylist and to the platform-independent Python job, anddocs/experiments.mdgets a section.Results
Commit
63e73fc8onorigin/main. Windows 11 26300.9974, DXC 1.8.2502.11, FXC 10.0.26100, debug layer on.There were no skips. The existing
startup_gfx2hlsl_bit_alu_check.pycontrols still pass, and so dodocs_links_check.pyandbidi_controls_check.py.ctest --preset dev -N -R int_alulists the three tests.I also ran the existing
startup_gfx2hlsl_bit_aludraw on both adapters, whichdocs/experiments.mdsays has not been run on WARP or hardware yet. 46 draws matched and 12 mutated draws failed as expected on each. That is outside this PR's diff; I can record it separately.The runner is meant for the remaining table families (three-source integer forms, conversions, float and scalar operations). Each would come as its own PR.
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:28:18Z.
Review: COMMENTED
Review of head
63e73fc8c405865e0a74d5c8fa9ac5cd79fa7828(1 commit; 5 files, +306/-0:.github/workflows/windows.yml+2,CMakeLists.txt+10,docs/experiments.md+17, two new tests; no change totools/startup/gfx2hlsl.py).Linux limits. Linux x86_64 only. No CMake configure and no
ctest(the newstartup_gfx2hlsl_int_alu_*registrations are unexercised), no Windows, no DXC or FXC, no WARP or GPU. Thedrawmode and the quoted "64 draws matched / 32 mutated draws" on WARP and an RX 6600 are therefore not reproduced by me.What I ran
python3 -B tests/startup_gfx2hlsl_int_alu_check.py(translation controls): PASS, all 16 operations.... binary llvm-mc-19:fixture words match llvm-mc. The recorded body words are byte-identical to llvm-mc 19 output (CI passes llvm-mc 15; I did not run 15).git diff --check origin/main...HEAD: clean.tests/bidi_controls_check.pyandtests/docs_links_check.py: pass.startup_gfx2hlsl_bit_alu_check.pyexactly (thebinary llvm-mc-15entry in the pixel-binary list, and the plain script entry in the Linux Python list). No permission, trigger, action or secret line is touched.Pipeline.hlsl_ps(), took the four lane expressions, evaluated them in Python with 32-bit wrap (uint(),int()as signed,min,max), and compared them with the test's references on all 128 input sets. 128 of 128 match. The lowerings inVEC_Uagree with the RDNA 2 semantics the test states (subrev is S1 - S0, "rev" shifts use S0[4:0],v_ashrrev_i32is arithmetic,v_mul_u32_u24masks both sources to 24 bits).VEC_U, each run and restored (git statusclean):v_subrev_nc_u32as{0} - {1}: the PR's Linux controls still PASS (exit 0); my evaluation reports 6 wrong words.v_mul_u32_u24without the 24-bit masks: controls exit 1, but only because the test's own mutation regex no longer matches (count == 4assertion), not because the lowering is judged wrong; my evaluation reports 4 wrong words.v_lshrrev_b32with& 15: same, exit 1 through the regex assertion; evaluation reports 2 wrong words.Findings
startup_gfx2hlsl_int_alu_controls) never compare the emitted HLSL with the reference. They check lane naming, set sizes, that each mutation changes the first draw, and the accepted/refused forms. A wrong lowering such as the subrev swap passes them; only thewarpandhardwaredraws can catch it, and those skip (exit 77) without DXC or a device. The same holds for the sibling bit-operation check, so I do not block on it. A cheap addition would be a pure-Python evaluation of the emitted lane expressions againstops, like the one I ran, so the semantics are guarded without a GPU.pixel_aot_check.py,compute_store_check.py), but those cover other translators, so the claim holds forgfx2hlsl.py. A few words ("in the startup translator") would remove the doubt.ps_5_1, and the llvm-mc 15 CI path.No defect found in the lowerings or the workflow change.
AI-assisted review; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T22:28:02Z.
Hardware run of head
63e73fc8. Windows 11 Pro 26100.9168, DXC/FXC from Windows SDK 10.0.26100,devpreset, debug layer unavailable here. Adapter selected withXBOX2WINDOWS_ADAPTER: WARP 10.0.26100.8972, NVIDIA Quadro M1000M (Maxwell, 10de:13b1) 32.0.15.7371, Intel HD Graphics 530 (Gen9, 8086:191b) 31.0.101.2111.startup_gfx2hlsl_int_alu_controlsstartup_gfx2hlsl_int_alu_warpstartup_gfx2hlsl_int_alu_hardwareon the Quadro M1000Mstartup_gfx2hlsl_int_alu_hardwareon the HD 530No changes made.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:31Z.
@Asimmimx could you rebase this branch onto current
mainand force-push?GitHub reports head
63e73fc8as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(cf97bee1):.github/workflows/windows.ymlCMakeLists.txtdocs/experiments.mdtests/startup_gfx2hlsl_lane_alu.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:24:31Z.
Merged
origin/maininto this branch (two commits, headb1a7d6d6a, fast-forward from63e73fc8c) so the PR no longer conflicts. No author test code was changed.Conflicts, all mechanical:
.github/workflows/windows.yml(two blocks),CMakeLists.txtanddocs/experiments.md: kept both sides.tests/startup_gfx2hlsl_lane_alu.py: add/add, because #1706 added the same helper. Took main's version, which is a superset (it adds the optionalpipelinekeyword argument);startup_gfx2hlsl_int_alu_check.pyruns unchanged against it.CMakeLists.txtleft this PR'sforeach(adapter ...)unclosed, so the second commit adds the missingendforeach().Verification:
python3 -B tests/startup_gfx2hlsl_int_alu_check.pyandtests/startup_gfx2hlsl_lane_alu.py: PASS (Linux)x2w_pipe.py win2025 1703 --patch <merge diff> --targets offscreen_check --regex startup_gfx2hlsl_int_alu: dev 3/3 and release 3/3 passed (startup_gfx2hlsl_int_alu_controls,_warp,_hardware).AI-assisted; commands listed were executed locally.