shader: support neg_lo, neg_hi, and clamp on v_pk_min/max_f16 #3265
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!3265
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3263"
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?
@legacy-code-archaeologist on GitHub · 2026-11-28 02:37 UTC · original
legacy-code-archaeologist:shader/direct-packed-minmax-f16-mods→main· +123 −44 · 3 files · 2 commits · merged 2026-11-28 05:24 UTCSupports VOP3P
neg_lo,neg_hi, andclampmodifiers onv_pk_min_f16andv_pk_max_f16inDirectCompute::packed_minmax(), addressingunsupported packed 16-bit min/max encodingin #3226's refreshed census.Fixes #3263. Refs #2935, #3226.
Summary
src/gfx1013_direct_compute.inl(DirectCompute::packed_minmax()):NEG_LO[1:0],NEG_HI[1:0], andCLAMPwhenfloating(v_pk_min_f16/v_pk_max_f16), while continuing to refuseNEG_LO[2],NEG_HI[2],OP_SEL[2], nonzerosrc2, and all clamp/negation bits onv_pk_min/max_{i16,u16}withunsupported packed 16-bit min/max encoding.xor 32768) before NaN/zero/min/max comparison and applies binary16 output clamp (NaN/ negative ->+0.0,> 0x3bff->1.0, positive subnormals preserved) after NaN selection.tests/native_packed_minmax_check.py:packed(),half_result(), andexpected()withneg_lo,neg_hi, andclamp.MOD_CASES(9asymmetricneg_lo/neg_hi,-0.0/-Inf/+Inf/ NaN clamp, positive subnormal clamp, and combined negation+clamp cases, across VGPR, SGPR, and literalsrc0) verified incontrols,compute, and losslesspixel(warpandhardware:i164 +u164 +f1613 cases).controls()to keep testing reserved modifier bits onf16(NEG_HI[2],OP_SEL[2],NEG_LO[2]) and existing refusals oni16/u16.Verification (
devandrelease/O2, Windows10.0.26100)ctest --preset dev --no-tests=error -V -R '^native_packed_minmax_'&ctest --preset release --no-tests=error -V -R '^native_packed_minmax_':native_packed_minmax_controls: Passed (6 opcodes compiled includingf16withneg_lo/neg_hi/clamp; reserved/integer mods andf16flush mode refused).native_packed_minmax_pixel_warp: Passed (Microsoft Basic Render Driver10.0.26100.9711,4+4+13Pixel cases matched;debug_layer=unavailable).native_packed_minmax_pixel_hardware: Passed (4+4+13Pixel cases matched;NVIDIA Quadro M1000M,32.0.15.7371,debug_layer=unavailable).native_packed_minmax_compute_hardware: Skipped (77) (Intel(R) HD Graphics 530, vendor8086, device191b, driver31.0.101.2111lacks SM 6.6 wave32 — needs testing on a wave32-capable GPU).ctest --preset dev --no-tests=error -V -R '^native_f16_alu_ir$': Passed (82results,14refusals); the remaining68native_.*_(controls|ir)tests indevalso passed.rc=8): swappingi.neg/i.absbetweenlowandhighlanes (f16-mod-0), disablingif (i.clamp)(f16-mod-4), and dropping the NaN check inclamp(f16-mod-7) all failednative_packed_minmax_pixel_warp.AI-assisted.
@R0Y00 on GitHub · 2026-11-28 02:49 UTC · original · requested changes
I reviewed
8d5bd5d145on main4d7265c0(trialb9b6c8a6eb). The modifier bits are applied per half before comparison, clamp is applied after selection, and integer/reserved encodings retain their refusal controls. The Compute adapter that was skipped in the author run is now covered: exact 2,064-word readbacks include both negate groups, subnormal and NaN clamp cases, and the buffer guards.Debug and Release /O2 each passed 5/5, zero skips, including physical Compute and both Pixel adapters. Windows 11 26200.9974, RTX 4060 Laptop 32.0.16.1656, and inbox WARP 10.0.26100.9818. Pixel used the debug layer. The standalone Compute replay did not.
Please update docs/experiments/native-packed-minmax.md. It still says that negation and clamp are refused for the whole family. The new scope is floating-point only, with the integer and reserved-encoding refusals preserved. Include the extended fixture coverage.
@legacy-code-archaeologist on GitHub · 2026-11-28 05:10 UTC · original
Thanks @R0Y00 — updated
docs/experiments/native-packed-minmax.mdto match thev_pk_min_f16/v_pk_max_f16modifier support:neg_lo[1:0],neg_hi[1:0](sign-bit flip per selected operand half prior to comparison) andclamp([+0.0, 1.0]saturation withNaN -> +0.0after min/max selection)v_pk_min/max_{i16,u16}modifiers and unused third-operand fields (src2,op_sel[2],neg_lo[2],neg_hi[2])MOD_CASESand 13f16Pixel fixture casesRe-verified on the updated commit (
devandreleasepresets):python -B tests/docs_links_check.py: passed (132Markdown files,635links)ctest --preset dev --no-tests=error --output-on-failure -j 1 -V -R '^native_packed_minmax_':native_packed_minmax_controls,native_packed_minmax_pixel_warp(Microsoft Basic Render Driver), andnative_packed_minmax_pixel_hardwarepassed;native_packed_minmax_compute_hardwareskipped (77on local Intel HD Graphics 53031.0.101.2111lacking SM 6.6 wave32)ctest --preset release --no-tests=error --output-on-failure -j 1 -V -R '^native_packed_minmax_':3passed,1skipped (77on Intel HD Graphics 530)AI-assisted.
@R0Y00 on GitHub · 2026-11-28 05:24 UTC · original · approved these changes
Re-reviewed
9388799c. The only revision since8d5bd5d1is the experiment note. It now covers FP16-only negate/clamp, the integer and reserved-encoding refusals, and the new fixture cases. The implementation and fixtures are byte-identical to those independently tested in Debug and Release /O2 (5/5 each, zero skips, including RTX Compute and RTX/WARP Pixel). The requested documentation change is resolved.@pigalot on GitHub · 2026-11-28 06:18 UTC · original · approved these changes
Reviewed
9388799cintegrated over currentmainaeef65b2. The merge is clean (tree9d345bc7) andgit diff --cached --checkis clean.R0Y00's changes request on
8d5bd5d1(docs): addressed.9388799cchanges onlydocs/experiments/native-packed-minmax.md. It now limits negation and clamp tov_pk_min_f16/v_pk_max_f16, keeps the integer-form and unused third-operand refusals (src2,op_sel[2],neg_lo[2],neg_hi[2]), and describes the 9MOD_CASESand the 13f16Pixel cases. Each statement matches the code and the check.What I traced in
packed_minmax().negfield and NEG_HI theabsfield. The low lane takesi.negand the high lanei.abs, and bit j flips the sign of source j's selected half before the NaN test and the compare. That is the per-lane meaning of the VOP3P negate bits.-0.0too) become+0.0, anything above0x3bffbecomes1.0, and positive subnormals pass through.clamp,neg_loandneg_hi.half_result()in the check follows the same order: negate, select, clamp.What I ran.
devandrelease/O2.ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^native_(packed_minmax_.*|f16_alu_ir)$' -E '_hardware$':native_packed_minmax_controls,native_packed_minmax_pixel_warpandnative_f16_alu_irpass in each preset.ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_packed_minmax_.*_hardware$'passes 2/2 in each preset, with no skips.native_packed_minmax_compute_hardwarematches 2064 words for each ofi16,u16andf16, plus the 9×2 modifier cases. This is the wave32 Compute run the description lists as skipped.native_packed_minmax_pixel_hardwarematches 4+4+13 cases.ctest --test-dir out/build/dev --no-tests=error -j 8 -E '(startup_audio|_hardware$)'gives 2033 tests: 1973 pass, 0 fail and 60 are capability skips.Mutants of
src/gfx1013_direct_compute.inl, each rebuilt indevand run againstnative_packed_minmax_controls,native_packed_minmax_pixel_warpandnative_packed_minmax_compute_hardware, after an unmutated baseline that passes:src1negation dropped+0.0f16acceptsNEG_LO[2]clamp0x3bff→0x3fff(only values above 2.0 saturate)Restored afterwards;
git diff --quietis clean.Non-blocking. No clamped lane has a result strictly between 1.0 and 2.0. Every clamped value above 1.0 in
MOD_CASESis 2.0 (0x4000),+Infor 65504 (0x7bff), and each of those is also above0x3fff. So the threshold could sit anywhere in0x3bff..0x3fffwithout a failure. A clampedmaxwhose result is0x3c01(the next value above 1.0), or 1.5 (0x3e00), would pin it.Verdict: approve on
9388799c.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on9388799c.This reply was AI-assisted.