shader: lower v_min3_f16, v_max3_f16, and v_med3_f16 in direct Compute and Pixel DXIL (#3266 merged with main) #3454
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!3454
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3452"
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?
@Leyukaka on GitHub · 2026-11-29 12:13 UTC · original
Leyukaka:takeover-3266-minmax-med3-f16→main· +457 −1 · 4 files · 5 commits · merged 2026-11-29 13:21 UTC#3268 by @legacy-code-archaeologist, merged with
mainso it can land. Supersedes #3268. Fixes #3266. Refs #2935.What is here
b82ba196(lowering) anddf6c0545(five added test cases).main(fe1c1d31, merge commit5b06bab7). It is the only change of mine.Conflict resolution
git merge-tree --write-tree fe1c1d31 df6c0545exits 1 with one conflicted file and one region: thehalf_binaryop list inDirectCompute::lower(),src/gfx1013_direct_compute.inl.mainextended the list afterv_fract_f16; #3268 added its three ops at the same place. The resolution keeps both sides,main's entries first:tests/native_minmax_med3_f16_check.pyandtests/cmake/native_minmax_med3_f16.cmakeare new files and merge without conflict.Verified
Not covered
ctest --preset pr. Its filter does not includenative_minmax_med3_f16_*, so a green check here does not run the tests this PR adds. They need a run by a reviewer on this head (ctest --preset dev -R '^native_minmax_med3_f16_').df6c0545over oldermaincommits, beforev_ldexp_f16and thev_cvt_pknorm_*_f16entries joined the list. They are not repeated here.df6c0545(29 cases, 14 draws).@JohnConnorNPC on GitHub · 2026-11-29 12:25 UTC · original
Review of head
5b06bab7(read-only, on Linux; no build or ctest run here). I found no MUST items, 1 SHOULD and 4 NITs.The merge leaves the #3268 commits unchanged:
git range-diff d649e470..df6c0545 fe1c1d31..5b06bab7shows1: b82ba196 = 1: b82ba196and2: df6c0545 = 2: df6c0545. The only thing the merge adds is the union of thehalf_binarylist.git merge-tree --write-tree origin/main 5b06bab7exits with rc 0 on current main.SHOULD
5b06bab7runs none of them, because the pr preset doesn't include them:gh run view 46261152654 --log | grep -c minmax_med3prints0. #3451 (1990fead, in this base) made the launchers default to native shaders. So these three ops are now lowered on the default launcher path with no flag, where before this PR they were refused. Before merge, please run this on this head, on WARP and on a GPU:ctest --preset dev --no-tests=error -R '^native_minmax_med3_f16_'(On the author's Intel adapter,
_compute_hardwareexited 77, a capability skip.) I expect a pass. The commits are identical, and the helper drift sinced649e470doesn't affect this check:native_f16_alu_checkSTRIDE went from 512 to 1024, but this check uses a fixed PROLOGUE literal and the hard-coded layoutgroup * 1024 + lane * 32.NIT
(mode_bits & 0xc0u) != 0xc0u. That is correct, since min/max don't round. But its message says "rounding or denormal". The gate also can't be reached:consume_half_moderefuses first, so neither mode refusal control ever hits it.0x7e00, sNaN quieting in IEEE mode, and med3 signed-zero ties. For example, med3(-0, +0, -1) gives0x8000here, while the ISA pseudocode (max3 == S0compared as floats, givingmax(S1,S2)) gives0x0000. This matches the existingv_med3_f32andv_pk_min_f16, so it is not a regression._controls, the DXIL marker is weak:assert 'icmp ugt i32' in dump and 'icmp ult i32' in dump. The compile rc and the refusal cases carry the real weight.git grep -E 'v_(min3|max3|med3)_f16' -- '*.md'finds nothing, while the f32 forms are indocs/experiments.md. The case counts in the #3268 body are also stale. Both are already listed under "Not covered" in the body.This comment was AI-assisted.
@Leyukaka on GitHub · 2026-11-29 12:42 UTC · original
SHOULD 1, run on head
5b06bab7in an isolated Windows Sandbox with no network: dev preset configured with-DX2W_WITH_OPUS=OFF, full build, thenctest --preset dev --no-tests=error -R '^native_minmax_med3_f16_'Test output:
_ir: 29 cases matched exact model; 7 refusals matched._controls: compiled 29 cases to DXIL; verified 7 refusals._compute_hardware: 29 cases matched across 2x32 lanes and guards, on a hardware adapter. It passed, it did not exit 77._pixel_warpand_pixel_hardware: 14 pixel draws (28 cases) matched on each.WARP is covered by the pixel test only:
tests/cmake/native_minmax_med3_f16.cmakeregisters no WARP variant of the compute test.NITs:
src/gfx1013_direct_compute.inl:2661tests only(mode_bits & 0xc0u) != 0xc0u, so its message becomes a denormal-only one, as the packed min/max gate at line 3233 already has. The two mode controls get their string fromconsume_half_mode, so their expected text does not change.docs/experiments/entry for the three ops in the same follow-up commit. The counts in this PR's body (29 cases, 14 draws) match the run above; the #3268 description is not ours to edit.The follow-up commit changes the head, so the five tests will be rerun on it and the result posted here.
@Leyukaka on GitHub · 2026-11-29 12:56 UTC · original
Follow-up commits
14aae9baand63416373(NIT 1 and NIT 4), head is now63416373. Three files:src/gfx1013_direct_compute.inl:2662: the min3/max3/med3 gate message changes fromunsupported binary16 rounding or denormal modetounsupported binary16 min3/max3/med3 denormal mode. The condition is unchanged.tests/native_minmax_med3_f16_check.py:188: the expected string of the conditional-branch MODE control follows the new message.docs/experiments/native-minmax-med3-f16.md: new entry for the three ops (scope, refusals, test coverage, reproduction).Correction to my previous comment: only the
s_denorm_mode 3control gets its message fromconsume_half_mode; the conditional-branch control writes denorm16 = 3, whichconsume_half_modeaccepts, and the refusal comes from the gate itself, so its expected string did change.Rerun on
14aae9ba(63416373on top only rewords one sentence ofdocs/experiments/native-minmax-med3-f16.md, so it was not rerun), same procedure as before (isolated Windows Sandbox, no network, dev preset with-DX2W_WITH_OPUS=OFF, full build):ctest --preset dev --no-tests=error -R '^native_minmax_med3_f16_'@JohnConnorNPC on GitHub · 2026-11-29 13:21 UTC · original
Re-review of the delta
5b06bab7→63416373(read-only, on Linux; no build or ctest run here). No MUST, SHOULD or new NIT items. Merging.ctest --preset dev --no-tests=error -R '^native_minmax_med3_f16_'gave 5/5 passed on14aae9ba, with_compute_hardwarepassing on a hardware adapter rather than exiting 77.git diff 14aae9ba 63416373 --stattouches onlydocs/experiments/native-minmax-med3-f16.md, so not rerunning on63416373is fine.(mode_bits & 0xc0u) != 0xc0u), and the message now readsunsupported binary16 min3/max3/med3 denormal mode. Thanks for the correction: the conditional-branch MODE control does reach this gate. My earlier note that neither control could reach it was wrong. The test now pins the new string for that control and keepsconsume_half_mode's string fors_denorm_mode 3.docs/experiments/native-minmax-med3-f16.md. It agrees with the code: opcodes 0x351/0x354/0x357, two NaNs give0x7e00, med3 with a NaN givesmin(min(a, b), c), and clamp sends NaN or a negative result to+0.0hand anything above1.0hto1.0h. It also states that WARP covers only the Pixel path.git merge-tree --write-tree origin/main 63416373rc 0 on mainc04e0dd6. CI at63416373: Windows, Linux Python and gfx1013 fixtures pass. Delta hygiene:git diff --checkrc 0, non-noreply emails 0, title-pattern hits 0, added@lines 0.This comment was AI-assisted.