pixel_aot: lower 13 SDWA cvt, frexp_exp, and pkrtz forms #2563
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2571"
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 KomaGuy on 2026-11-25T21:24:57Z.
Summary
Lowers 13
SDWAconversion, exponent, and packed-RTZ forms intools/pixel_aot.py(counted in bothdocs/coverage/gfx1013.tsvanddocs/coverage/rdna2.tsv), with static refusal controls,pixel_aot_sdwa_cvt_{warp,hardware}draw tests, LLVM 15check_binaryfixtures, andform_coverage_checkcoverage assertions:v_cvt_i32_f32_sdwa,v_cvt_u32_f32_sdwa,v_cvt_flr_i32_f32_sdwa,v_cvt_rpi_i32_f32_sdwa,v_frexp_exp_i32_f32_sdwav_cvt_f32_i32_sdwa,v_cvt_f32_u32_sdwa,v_cvt_f32_ubyte0_sdwa,v_cvt_f32_ubyte1_sdwa,v_cvt_f32_ubyte2_sdwa,v_cvt_f32_ubyte3_sdwa,v_cvt_off_f32_i4_sdwav_cvt_pkrtz_f16_f32_sdwaContracts & Semantics
f32->int32,frexp_exp,pkrtz): Require whole-dword VGPR/SGPR sources (src0_sel:DWORD, plussrc1_sel:DWORDanddst_sel:DWORDforpkrtz) with optional bit-31abs/negmodifiers (|reg|,abs(reg),-reg,-|reg|), refusingsext(),clamp, andomod.f32->int32andfrexp_expreuse the IEEE-754 saturating/special-value bit helpers (cvt_{i32,u32,flr_i32,rpi_i32}_f32,dpp_frexp_exp_i32_f32) with SDWA destination placement (BYTE_0..3,WORD_0..1,DWORD+UNUSED_PAD/UNUSED_PRESERVE);v_cvt_pkrtz_f16_f32_sdwaproduces the(lo, hi)compressed-export pair and remains exempt fromHALF_RTZrefusal.int->f32): Accept VGPR/SGPR sources withBYTE_0..3,WORD_0..1, orDWORDselection, optionalsext(), optionalclamp(saturate(...)), and SDWA destination placement, refusing float modifiers andomod.UNUSED_SEXT,UNUSED_PRESERVEon untracked/non-numeric destinations, pending scalar loads, outstanding samples, and non-entry EXEC masks.Verification
python3 tests/pixel_aot_check.py(including newcheck_sdwa_cvt_controls)form_coverage_check:check_sdwa_cvt_forms(+13 forms ingfx1013.tsvandrdna2.tsv, unlowered neighbours excluded, single-opcode removal control),check_shader_records,check_sdwa_f16_forms,check_sdwa_int_extra_forms,check_sdwa_cmp_coveragepkrtzRTZ discrimination check + manual inspection of generated HLSLpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,python3 tests/rdna2_tools_check.py(156 tests OK)git merge-tree --write-tree --name-only origin/main HEADandgit diff --check origin/mainpixel_aot_binaryassembly/disassembly round-trips for all 4SDWA_CVT_*fixturespixel_aot_sdwa_cvt_warp/pixel_aot_sdwa_cvt_hardwaredraws and all 16 mutationsImported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:36:31Z.
Review: COMMENTED
Review of head
3bf6dd18(comment only, Linux checks; the WARP draw test is run separately on Win2025).Result: sound on code and fixtures, no blocking findings.
tools/pixel_aot.py(5 float-to-int/frexp_exp, 7 int-to-float, 1 pkrtz). The float-source forms reuse the existing e64/DPP bit helpers and SDWA destination placement; refusals cover src0_sel other than DWORD, sext on float sources, UNUSED_SEXT, clamp/omod on the float forms, pending loads and non-entry EXEC.draw-sdwa-cvt(pixel_aot_sdwa_cvt_{warp,hardware}) draws the translated shader and compares the readback withsdwa_cvt_reference, an independent Python model (not the lowering's own helpers), plus per-group mutations that must change the result. This is the readback-vs-CPU-reference test the repo asks for.check_sdwa_cvt_controlscovers the static refusals.v_cvt_off_f32_i4(signed nibble times 0.0625: -8 -> -0.5, 15 -> -0.0625) and the ubyte byte selection by hand against the reference.form_coverage_checkassertions are extended, with a single-opcode removal control. No other open or merged PR covers these opcodes (searchedSDWA cvt frexp_exp pkrtz).Commands run locally:
python3 tests/pixel_aot_check.py-> passpython3 tests/docs_links_check.py-> ok (489 links);python3 tests/bidi_controls_check.py-> ok;git diff --check origin/main...HEAD-> cleantests/form_coverage_check.pycould not run on this Linux box (missingiced_x86); it is left to the Win2025 run.src0_sel:DWORDrefusal failscheck_sdwa_cvt_controls; dropping the float-source modifier refusal fails it too; dropping the UNUSED_SEXT refusal fails the existing movrel control.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:47:34Z.
Win2025 WARP result for head
572c3cca(head after updating with main; the PR's own diff is unchanged): the new draw test FAILS, so this PR cannot be merged yet.pixel_aot_sdwa_cvt_warpandpixel_aot_sdwa_cvt_hardware(both run on the WARP adapter on this VM):Failed, same result on a rerun of the warp test. Groupf32_to_int, case 2, pixel (0,0), channel 2: expected bitsfffe0000, actual bitsfffeffff.v_cvt_flr_i32_f32_sdwainto WORD_0. The lowering reuses the existingcvt_flr_i32_f32helper (tools/pixel_aot.py, see its comment citing #1772): a NaN input gives0x7fffffff(or0x80000000with the sign bit set). The test referencesdwa_cvt_reference(tests/pixel_aot_check.py,cvt_i32) returns 0 for every NaN, so its low word is0000while the shader writesffff.cvt_i32/cvt_u32for the other channels do pass, so only theflr(and probablyrpi) NaN rule differs.flrandrpi(NaN ->0x7fffffff + sign bit, negative subnormal ->-1forflr), keepingcvt_i32/cvt_u32as they are, then rerun the test. If the intent is NaN -> 0 for the SDWA forms, the helper call has to change instead; that is a choice for the author and @R0Y00.form_coverage_checkand the otherpixel_aottests.Commands run:
x2w_pipe.py win2025 2571 --wait 7200 --keep-release --regex 'pixel_aot_sdwa_cvt_warp|form_coverage|^pixel_aot', thenx2w_pipe.py win2025 2571 --wait 7200 --regex '^pixel_aot_sdwa_cvt_warp$'.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-25T21:52:20Z.
Thanks for catching that on Win2025 WARP! Fixed in
98821939: updatedsdwa_cvt_reference(cvt_i32) intests/pixel_aot_check.pyto match thecvt_flr_i32_f32/cvt_rpi_i32_f32helper contract from #1772 (NaN ->0x7fffffff + sign_bit, negative subnormal ->0xffffffffforflr, keepingcvt_i32_f32/cvt_u32_f32NaN ->0). Row 2 channel 2 now expects0xfffeffff, matching the WARP readback; re-verifiedtests/pixel_aot_check.pyandform_coverage_check.check_sdwa_cvt_formslocally.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:57:02Z.
Review: COMMENTED
Review of head
21e6bca1(comment only, no approval).What I checked:
tools/pixel_aot.pyreuse the existing e64/DPP bit helpers; float-source forms requiresrc0_sel:DWORD, int-source forms accept sel/sext/clamp. Refusals (UNUSED_SEXT, sext on float, pending sample overlap, non-entry EXEC) are covered bycheck_sdwa_cvt_controls.pixel_aot_sdwa_cvt_{warp,hardware}CTest entries run a real draw and compare readback with the CPU reference, and are registered next to the siblingpixel_aot_f16_exact_extra_*tests.Commands run in a clean worktree of this head:
python3 tests/pixel_aot_check.py-> exit 0python3 tests/docs_links_check.py-> okpython3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> cleancvt_f32_ubyte1shift 8u -> 0u:pixel_aot_check.pyfails incheck_sdwa_cvt_controls.src0_sel:DWORDrefusal:pixel_aot_check.pyfails (control sub-check).form_coverage_check.pycould not run here (missingiced_x86); left to CI / Win2025.Not a startup/game claim. Windows WARP receipt still to come from the pipeline.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:20:42Z.
Win2025 WARP result for head
cb0a97d5(head after updating with main; the PR's own diff is the same as98821939, which fixed the NaN and negative-subnormal rules insdwa_cvt_reference):pixel_aot_sdwa_cvt_warpandpixel_aot_sdwa_cvt_hardwarenow pass (both on the WARP adapter)./O2:ctest --preset release -R 'pixel_aot|form_coverage'= 191/191 passed. Dev preset: 191/191 passed.tests/form_coverage_check.pyok.git diff --check,tests/docs_links_check.py,tests/bidi_controls_check.pyok.Blocker: main moved again and this branch now conflicts.
gh pr update-branchis refused ("conflicts"). @KomaGuy, please merge main into the branch and resolve the conflict (likelytools/pixel_aot.py/tests/pixel_aot_check.py). After that the PR only needs a re-run on the new head.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-25T22:56:52Z.
@tedin7 Merged
origin/main(069e64fe) in21e6bca1and resolved the conflicts with #2578 inCMakeLists.txt,docs/experiments.md,tests/form_coverage_check.py, andtests/pixel_aot_check.py(also replaced the now-loweredv_min_f16_sdwa/v_frexp_mant_f16_sdwaentries in the unlowered-neighbour/refusal checks with genuinely unlowered SDWA ops).Re-verified locally on Linux:
tests/pixel_aot_check.py,form_coverage_check(check_shader_records,check_f16_exact_extra_forms,check_sdwa_cvt_forms),tests/docs_links_check.py,tests/bidi_controls_check.py, andtests/rdna2_tools_check.pyall pass. Ready for a re-run on21e6bca1.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:02:25Z.
Win2025 WARP receipt for head
0e7481deafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
0e7481defd3be223c04c9b3a9b15c87b659780d2:--preset dev):cmake --build --preset dev -- -j 2):26.52s(configure3.28s)ctest --preset dev -R 'pixel_aot_sdwa_cvt_warp|pixel_aot_f16_exact_extra_warp' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (4.16s:pixel_aot_sdwa_cvt_warp2.76s,pixel_aot_f16_exact_extra_warp4.03s)/O2(--preset release):cmake --build --preset release -- -j 2):16.59s(configure2.24s)ctest --preset release -R 'pixel_aot_sdwa_cvt_warp|pixel_aot_f16_exact_extra_warp' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (3.42s:pixel_aot_sdwa_cvt_warp2.37s,pixel_aot_f16_exact_extra_warp3.28s)tests/form_coverage_check.pyok (15.0s),tests/mesh_clip_cull_check.pyok (5.7s),tests/mesh_dynamic_geometry_check.pyok (0.3s),tests/mesh_heap_sampler_check.pyok (0.9s),tests/pso_readiness_check.pyok (1.6s),tests/rdna2_tools_check.pyok (3.5s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.4s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.4s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.6s),tests/startup_gfx2hlsl_f32_nan_check.pyok (6.5s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (8.0s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (6.1s),tests/startup_image_load_d16_check.pyok (1.5s),tests/startup_image_sample_a16_check.pyok (0.3s),tests/vk_offscreen.pyok (1.9s)sccache: 32/169 hits; wall119.9sAI-assisted; commands listed were executed locally.