shader: accept SGPR, hex literal and zero sources in gfx2hlsl packed f16 ops #3615
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3615
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3613"
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?
@Ammmae0x on GitHub · 2026-11-30 14:22 UTC · original
Ammmae0x:shader/pk-f16-sources→main· +343 −38 · 6 files · 3 commits · merged 2026-11-30 15:48 UTCRefs #2022, #1723
@Leyukakareleased this claim on #2022 on 2026-11-29 (keeping only thev_pk_mul_f1632-bit literal in merged PR #3490). This change letsv_pk_add_f16,v_pk_mul_f16andv_pk_fma_f16accept the same non-VGPR sources thatv_pk_min_f16andv_pk_max_f16already accept: numeric SGPRss0..s105, 32-bit hex literals0x..., and inline0.What changed
Stage.packed_half()(tools/startup/gfx2hlsl.py) now applies one source-validation and word-lowering path to all five packed f16 ops, and thev_pk_mul_f16-only literal special case from #3490 is removed:i >= 1): single VGPR (v0..v255), single numeric SGPR (s0..s105, withreject_lane_mask_datarunning beforeS()so lane-mask SGPRs inself.masksare always refused), 32-bit hex literal (0x[0-9a-f]{1,8}), inline0(0x00000000u,+0.0in both halves).i == 0): still a single VGPR (v0..v255). This also closes a gap the f16 forms had:v_pk_add_f16 v256, v0, v1used to be accepted and now refuses withdestination v256 is out of range.reject_lane_mask_data+S()on every form (previously only whenselect_bits=True); VGPRs keep the sameu(tok, low16_only=not any(both))call, sonote_whole_readbehaviour is unchanged. Modifier checks (clamp,neg_lo,neg_hi, arity,op_sel/op_sel_hi) are unchanged and strict. The_i16/_u16forms are untouched (they already passselect_bits=True).Tests
tests/startup_gfx2hlsl_f16_alu_check.py:v_pk_add_f16 v3, s0, v1,v_pk_mul_f16 v3, s20, v0,v_pk_mul_f16 v3, v0, 0) are positive tests, plus-0.0 + +0.0 == +0.0,Inf * 0 == NaN(inline zero) andfma(-0.0, x, 0) == +0.0.s0/s105, literals0x80003c00/0x7bff0400/0x7c00fc00, inline0) in every source position of all three ops, over every selector pair, plus mixed combinations, checked againstf16_packed_model.Stage.one()for literals in every position (add src0/src1, fma src0/src1/src2), plus an SGPR decode and an inline-zero decode.s106,s[0:1],vcc_lo,exec_lo,m0,src_scc, float literal2.0,-1,0x100000000,v256source/destination,v[3:4], scalar/literal destinations,clamp,neg_lo,neg_hi,mul:2, malformedop_sel, arity), including a d16 low-half pin (a high-half pick of a d16-loaded VGPR refuses; a low-only pick is accepted).tests/startup_gfx2hlsl_f16_alu_draw_check.py: six new:src:draw keys (SGPR, 32-bit literal, inline 0 and mixed lanes per op, both halves) with recorded words, a decode round-trip in the controls, and a Linux evaluation of the translated pixel program against the model reference. The check is wired intotests/checks/python-linux/startup-gfx2hlsl-f16-alu.txt, so Linux CI runs it.tests/startup_gfx2hlsl_pk_minmax_check.py: the add/fma hex-literal refusal is gone (now accepted).docs/experiments/startup-gfx2hlsl-pk-minmax.md: the stale sentencePacked add, mul and fma still require VGPRs.now states that add, mul and fma accept the same source forms, covered intests/startup_gfx2hlsl_f16_alu_check.pyandtests/startup_gfx2hlsl_f16_alu_draw_check.py. Thedocs/experiments/native-packed-f16-inline.mdnote covers the direct-compute C++ path, not this translator, so it is untouched.Linux verification (
/tmp/pe-env, branchshader/pk-f16-sourcesfromorigin/main077bff3a)tests/startup_gfx2hlsl_f16_alu_check.py— ok (~6s)tests/startup_gfx2hlsl_f16_alu_draw_check.py(controls) — ok, 346 checkstests/startup_gfx2hlsl_pk_minmax_check.py(controls) — oktools/run_checks_parallel.py --from-dir tests/checks/python-linux— 68/68 passed (includes the newly wiredstartup_gfx2hlsl_f16_alu_check.py, 18.2s)tests/form_coverage_check.py,tests/docs_links_check.py(186 files / 736 links),tests/bidi_controls_check.py(2726 files) — passpy_compile,git diff --checkclean,git merge-tree --write-tree origin/main HEADexits 0packed_half()(destination bounds,select_bits,s0..s105,reject_lane_mask_data,0x[0-9a-f]{1,8},0, arity/mods,low16_only) are killed by the three packed-f16 suites.Not verified on this host: the draw check's
binary(llvm-mc) comparison — no llvm-mc here. The recorded words are instead pinned by the decode round-trip in the controls, which runs on Linux and Windows CI.Follow-up (
2be4157b, mergedorigin/main35a3f6d6)Windows verification of
240bf98fpasseddev+release(7/7) and CI is green. The audit's remaining pins are closed here:docs/experiments/startup-gfx2hlsl-pk-minmax.md: the stale sentencePacked add, mul and fma still require VGPRs.now reads that add, mul and fma accept the same source forms, covered intests/startup_gfx2hlsl_f16_alu_check.pyandtests/startup_gfx2hlsl_f16_alu_draw_check.py.tests/startup_gfx2hlsl_f16_alu_check.py: symbolic SGPRs throughS()(a const word inlines as its literal withused_sempty, a user-data word lowers toudN, aTG_SIZEregister still refuses outsides_and_b32), a repeated numeric SGPR source (s20, s20), short hex literals (0x0,0x3c00, zero-extended) and the uppercase-hex refusal (0x80003C00).Linux re-verification on
2be4157b(/tmp/pe-env): f16 alu check ok, draw controls ok (346 checks), pk_minmax controls ok,run_checks_parallel.py --from-dir tests/checks/python-linux68/68 passed, form/docs/bidi pass (186 files / 736 links, 2729 files),diff --checkclean,merge-treeexits 0.Windows Verification (
2be4157b)ext Commit: 2be4157bf4d90718d505afde4f73c54426e92d7f (merge-tree upstream/main -> clean, exit 0) Host: Windows 11 build 26100.7623, NVIDIA GeForce RTX 4050 Laptop GPU (driver 32.0.15.9186, XBOX2WINDOWS_ADAPTER=NVIDIA, debug_layer=unavailable) dev: cmake --build --preset dev --target offscreen_check dev: ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_f16_alu|startup_gfx2hlsl_f16_alu_draw_.*|startup_gfx2hlsl_pk_minmax.*)$' --output-on-failure -> 7 passed, 0 failed (47.19s; f16_alu 4.21s, draw controls/warp/hw 0.47s/19.73s/19.05s, pk_minmax 0.14s/1.25s/2.19s) release: cmake --build --preset release --target offscreen_check release: ctest --preset release --no-tests=error -R '^(startup_gfx2hlsl_f16_alu|startup_gfx2hlsl_f16_alu_draw_.*|startup_gfx2hlsl_pk_minmax.*)$' -E 'cpu_native_archive_' --output-on-failure -> 7 passed, 0 failed (46.12s; f16_alu 4.13s, draw controls/warp/hw 0.50s/19.01s/18.80s, pk_minmax 0.16s/1.22s/2.13s) Checks: startup_gfx2hlsl_f16_alu_check.py, startup_gfx2hlsl_pk_minmax_check.py, form_coverage_check.py, docs_links_check.py (186 files, 736 links), bidi_controls_check.py (2729 files) -> all passed CI: Assemble & translate gfx1013 (3m20s), Windows (3m22s), Python checks on Linux (3m39s) -> all passedAI-assisted.
@R0Y00 on GitHub · 2026-11-30 15:48 UTC · original · approved these changes
Independent Debug check on
2be4157bwithctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^startup_gfx2hlsl_(f16_alu|pk_minmax)': seven passed, zero skips, including WARP and physical RTX draws. The shared source validation admits numeric SGPRs, literal words and inline zero while keeping lane-mask and undefined-half refusals. The min/max regressions passed as well.