shader: lower binary16 pknorm/pkrtz packs and the SDWA cndmask #3605
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3605"
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 lambirou on 2026-11-30T12:57:51Z.
Part of the f16 conversion/pack slice (Refs #839).
This adds four forms:
v_cvt_pknorm_i16_f16,v_cvt_pknorm_u16_f16,v_cvt_pkrtz_f16_f32_e64andv_cndmask_b32_sdwa.v_cvt_pknorm_i16_f16/_u16_f16: VOP3 only, with each source's low half statically proven finite; the exact RNE integer model scales and saturates to [-32767, 32767] or [0, 65535], src0 fills bits 15:0 and src1 bits 31:16.v_cvt_pkrtz_f16_f32_e64: two binary32 values converted to binary16 with round toward zero throughpack16_rtz(built fromnarrow16RNE and a magnitude step-back), finite overflow to 0x7bff/0xfbff, infinities preserved and NaNs signed and quiet.v_cndmask_b32_sdwa: the exact VOP2 select,D = VCC[lane] ? selected(src1) : selected(src0), with the same direction as plainv_cndmask_b32. The fourth operand is the implicitvcc/vcc_louse and must name a tracked comparison; there is nosrc2. VGPR sources usesrc0_sel/src1_selwithBYTE_0..3,WORD_0..1orDWORD, anddst_sel/UNUSED_PAD/UNUSED_PRESERVEplace the result over a tracked old word.sext(),UNUSED_SEXT, SGPR/literal sources, non-vccor untracked masks, modifiers and missing/extra fields are refused.The standalone #3669 carried the same form and is now redundant. Its corrected select, references, refusals and fixtures are folded into this branch at
b7c0c70f; #3669 was closed without merge after this branch's CI passed.Tests
pixel_aot_f16_packs_warpandpixel_aot_f16_packs_hardwarepass with no skips. The cndmask part now has four programs with three rows each:plainties an SDWA result to a non-SDWAv_cndmask_b32_e32result, anddword/bytes/wordscover every destination and source selector plus PAD/PRESERVE. The pknorm and pkrtz programs are unchanged.pixel_mismatch: pknorm signedness/source order, pkrtz half order/dropped negation/RTZ→RNE, and eleven cndmask mutations including swapped sources, inverted comparison, reversed fields, wrong word half, destination byte and PAD/PRESERVE changes.check_f16_packs_controlspins all four forms and the cndmask refusals;form_coverage_check.pypasses and keeps the f16 interpolation and unsupported pack neighbours uncovered;rdna2_tools_check.pypasses 162 tests with 19 LLVM-dependent skips;docs_links_check.pyandbidi_controls_check.pypass.The local draws ran on WARP (Microsoft Basic Render Driver
1414:008c, driver10.0.26100.10068) and AMD Radeon RX 9060 XT (1002:7590, driver32.0.32029.2010, Windows 11 build26300, D3D12 debug layer unavailable, DXC1.8.2502.11). The branch was re-merged withorigin/maina3bfd019; the only conflict was the pixel draw-mode dispatch, resolved by keeping bothdraw-f16-packs-cndmaskanddraw-interp-mov.Limits
pknormaccepts static sources only and noop_sel,abs/negor modifiers. Thepkrtze64 form produces one packed word and does not feed the e32 compressed-export(lo, hi)path.v_cndmask_b32_sdwamodels VGPR sources only, refusessext()/UNUSED_SEXT, and requires a comparison tracked by this translator. No console measurement or title run was made; the f16 interpolation and the DS/MIMG slices are untouched.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T20:42:21Z.
Review: CHANGES_REQUESTED
Reviewed
708885efby reading the diff; not built or run.Verdict: changes requested.
v_cndmask_b32_sdwaselects the wrong source. The two packs look right.v_cndmask_b32isD = VCC[lane] ? S1 : S0. The existing non-SDWA lowering a few lines above follows that: it unpacksdst, unset, chosen, i.e. src0 = unset and src1 = chosen. So does the gfx2hlsl SDWA fixture (tests/startup_gfx2hlsl_sdwa_cndmask_check.py:11: "the select picks src1 where the lane's VCC bit is set"). The new branch (tools/pixel_aot.py,v_cndmask_b32_sdwa) setschosen = src0and emitscond ? src0 : src1, which is reversed. The draw cannot catch it, becausecndmask_expectedintests/pixel_aot_check.pyuses the same rule (low0 if condition else high0withlow0froms44= src0). The "cndmask source order" mutation therefore only proves the two agree. Please swap the operands in the lowering and in the reference. Adding one row whose expected word comes from the non-SDWAv_cndmask_b32would tie the two forms together.pack16_rtz:0x7bff/0xfbff(sign-magnitudeh--), and Inf stays Inf becauseinf > infis false.pkrtz_source_bitsapplies abs/neg on the bits before any float op._e64spelling is covered byHALF_ROUNDING_EXEMPT's prefix.v_cvt_pknorm_{i16,u16}_f16: src0 goes toD[15:0]and src1 toD[31:16], through the existing exactcvt_norm_*_f16model. It requires proven finite halves andhalf_denorm="preserve".UNUSED_SEXTrefused,UNUSED_PRESERVEneeding a numeric old word, and unbalanced or literalsext()refused.Tests: the controls run in the Linux LLVM job (passed).
pixel_aot_f16_packs_{warp,hardware}are not in the Windowsprpreset filter, so the draw has only your WARP + RX 9060 XT run. The pkrtz and pknorm rows look complete. The cndmask rows need the reference fix above.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T23:06:14Z.
@lukaslw-lab La correction est repliée dans
b7c0c70f. Le lowering sélectionne maintenant src1 quand VCC est vrai et src0 sinon, et la référence cndmask_expected est corrigée. Le programme plain compare une ligne SDWA à _cndmask_b32_e32 avec le même masque et les mêmes sources. Les sources sont désormais VGPR uniquement, avec sext(), les SGPR/littéraux et UNUSED_SEXT refusés. Vérifications locales : draw WARP et RX 9060 XT sans skip, 16 mutations détectées, orm_coverage_check.py,dna2_tools_check.py (162 tests, 19 skips LLVM), docs et bidi verts. #3669, la PR autonome redondante, sera fermée après la CI verte de cette branche.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T01:31:15Z.
Review: APPROVED
Reviewed
818dd5efby reading the diff; not built or run. The delta since our review at708885efisb7c0c70f, plus two merges of main.Verdict: approve. The MUST is fixed in the lowering and in the reference, and the new
plainprogram ties the SDWA form tov_cndmask_b32_e32. No MUST, no SHOULD.tools/pixel_aot.py,v_cndmask_b32_sdwa):unsetcomes from src0/src0_sel,chosenfrom src1/src1_sel, and it emitscond ? chosen : unset, the same direction as the plain form above it.sdwa_cndmask_expectedtakesw1/s1whena < b. The rows give both outcomes (row 1 true, rows 0 and 2 false), so a swap shows up in the draw.plainprogram: the SDWA DWORD/DWORD and BYTE_0 rows sit next to_e32rows with the same sources and mask. A wrong direction now disagrees with the existing, independent lowering, not just with a shared reference.sext()is refused and the mask must bevcc/vcc_lo. The scanner regex matches that, and the refusal controls cover each case (SGPR, literal,sext,s52mask, modifiers, VGPR range,src2_sel).D = VCC ? src1 : src0and the narrowed scope.Tests: CI passed at this head.
pixel_aot_f16_packs_{warp,hardware}are still outside the Windowsprfilter, so the draw rests on your WARP + RX 9060 XT runs. The scanner agreement test and the controls run in the Linux job.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T19:02:48Z.
Review: APPROVED
Reviewed
c9c7e767on the updated branch. The SDWA select takes src1 when VCC is set and src0 otherwise. The new normalized and RTZ pack cases and the restored wrong-select control exercise distinct input values. Independent Windows 11 build 26300 / MSVC Debugctest --preset dev --no-tests=error -V -j 1 -R '^pixel_aot_f16_packs_(warp|hardware)$'passed 2/2, with WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 for the GPU fixtures.