shader: lower v_fract_f16 in direct Compute and Pixel DXIL #3271
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!3271
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3269"
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 03:08 UTC · original
legacy-code-archaeologist:shader/direct-fract-f16→main· +442 −1 · 4 files · 2 commits · merged 2026-11-28 05:26 UTCLowers VOP1 (
0x5f) and VOP3 (0x1df)v_fract_f16in direct Compute and Pixel DXIL.Fixes #3269. Refs #2935.
Summary
src/gfx1013_direct_compute.inl:v_fract_f16inDirectCompute::float_alu()withabs,neg,clamp,op_sel[0]/op_sel[3](high-half VGPR read and high/low destination placement preserving the other 16 bits ofvdst), VGPR/SGPR/literal/inline sources, exactmin(x - floor(x), 0x3bff)clamping tiny negative fractions that round to1.0down to0x3bff, non-finite±Inf/NaN ->0x7e00(+0.0underclamp), and the full0x8000ccubinary16 mode gate (half_binary = trueinDirectCompute::lower()).dpp_control/permuted), SDWA,omod, unused VOP3 operand/op_sel bits, high-halfop_selon non-VGPR source, special scalar sources, and non-default or unknown binary16 rounding/denormal modes.tests/native_fract_f16_check.py,tests/cmake/native_fract_f16.cmake:29cases: positive/negative fractions and exact integers (0.0,-0.0,±1.0,±65504.0), tiny negative inputs (-2^-11,-2^-12,-2^-24->0x3bff), positive binary16 subnormals (0x0001,0x03ff),±Infand NaN (-> 0x7e00or+0.0underclamp), VOP3abs/neg/op_sel=0b1001with0xDEADCAFEother-half preservation, SGPR/literal/inline (248,129) sources, and partialEXEC_LO(0xAAAAAAAA) lane preservation.10refusals:omod != 0, unusedop_sel[1]/s1bits, high-halfop_selon SGPR, DPP16, SDWA,vcc_losource,s_round_mode 0x4,s_denorm_mode 0x3, and conditionalMODEwrite.Verification (
devandrelease/O2, Windows10.0.26100)ctest --preset dev --no-tests=error -V -R '^native_fract_f16_'&ctest --preset release --no-tests=error -V -R '^native_fract_f16_':native_fract_f16_ir: Passed (29cases matched exactFractionmodel;10refusals matched).native_fract_f16_controls: Passed (29cases compiled to DXIL;10refusals verified).native_fract_f16_pixel_warp: Passed (Microsoft Basic Render Driver10.0.26100.9711,14pixel draws /28cases matched;debug_layer=unavailable).native_fract_f16_pixel_hardware: Passed (14pixel draws /28cases matched;NVIDIA Quadro M1000M,32.0.15.7371,debug_layer=unavailable).native_fract_f16_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 -R '^native_.*_(controls|ir)$' --output-on-failure: 71/71 passed (0skips).rc=8): dropping0x3bffclamp (tiny_neg_min_subnormal), droppingnon_finiteoverride (pos_inf/neg_inf/clamped), and removingv_fract_f16fromhalf_binary = true(s_round_modeunhandled) all failednative_fract_f16_ir.AI-assisted.
@R0Y00 on GitHub · 2026-11-28 03:35 UTC · original · requested changes
The hardware compute result missing from the author report is now verified. At
ab36ae6eplus main0fe4cebc, Debug and Release /O2 each pass all fivenative_fract_f16_*cases with zero skips, including the wave32 compute readback on RTX and both WARP and RTX pixel cases. Release also passes 5/5 on main5033d2d3, integration tree804af877.Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, WARP 10.0.26100.9818, DXC 10.0.26100.0. Please add the direct Compute/Pixel scope and the reproduction command to the experiment documentation. That will give the public capability record a reproducible entry and keep the existing Python/DPP scope clear.
@Leyukaka on GitHub · 2026-11-28 03:39 UTC · original
I reviewed the diff (not run). I found nothing wrong in the lowering itself. Several fixture cases do not test what their comments say, though, and some branches are not reached by any case:
tiny_neg_2_m11uses0xB000, which is -0.125, not -2^-11. Its fract is 0.875 (0x3b00), not0x3bff.tiny_neg_2_m12andliteral_src0use0xAC00, which is -0.0625, not -2^-12.0x9000(-2^-11, exact0x3bff) and0x8C00(-2^-12). For0x8C00, 1 - 2^-12 is a binary16 tie that rounds to0x3c00, so it is the input that needs the PR's clamp to0x3bff(min(..., 0x3BFF)in the model).0x8001reaches the clamp below 1.0.0x8001has an exactly representable result. A truncating conversion in place ofpacked_half_rnewould still match all of them, since0x8001gives0x3bffeither way.0x9500(-5 * 2^-12) and0x9480(-9 * 2^-13) would tell the two apart: nearest-even gives0x3bfe, truncation0x3bfd.vop3_abs_negon0xB400(-0.25), where-|x|equalsx. Dropping both the abs and the neg handling would still pass. A positive input withneg, or a negative one withabsalone, would catch it.clamp=1cases have results of +0 only (0xFC00and NaN). A finite input withclamp, for example 1.25 or -0.25, would check that clamp leaves values in [0, 1) unchanged.op_sel=0b1001appears, and theop_sel[0]=0cases have zero high source halves. Swapping the source and destination selection, or testing a single bit for both, would not show. Separate0b0001and0b1000cases, with a nonzero high half in the source, would.AI-assisted.
@legacy-code-archaeologist on GitHub · 2026-11-28 05:17 UTC · original
Thanks @R0Y00 and @Leyukaka — addressed both the documentation request and the fixture feedback:
docs/experiments/native-fract-f16.mddocumentingv_fract_f16(VOP10x5f/ VOP30x1df) Direct Compute and Pixel lowering,min(x - floor(x), 0x3bff)semantics,clamp=1behavior, supported VOP3 modifiers/sources, explicit refusals/mode gate (((mode_bits ^ 0xf0u) & 0x8000ccu)), 32-case Compute / 16-draw Pixel coverage, and exact reproduction command.tests/native_fract_f16_check.py(32 cases total, withassert len(cases) <= 32incompute_program):-2^-11(0x9000exact0x3BFF) and-2^-12(0x8C00on bothtiny_neg_2_m12andliteral_src0)tiny_neg_5_m12(0x9500->0x3BFE) andtiny_neg_9_m13(0x9480->0x3BFE)vop3_abs_neginto separatevop3_abs(0x7BFFB400,abs_=1) andvop3_neg(0x7BFF3400,neg=1)clamp=1casesvop3_clamp_pos(0x7BFF3D00) andvop3_clamp_neg(0x7BFFB400)vop3_opsel_hi_src(op_sel=0b0001) andvop3_opsel_hi_dst(op_sel=0b1000), and set nonzero high halves (0x7BFF) onop_sel[0]=0VGPR inputsVerification (
devandreleasepresets):python -B tests/docs_links_check.py: passed (134Markdown files,636links)ctest --preset dev --no-tests=error --output-on-failure -j 1 -V -R '^native_fract_f16_':native_fract_f16_ir(32cases,10refusals),native_fract_f16_controls(32cases compiled,10refusals),native_fract_f16_pixel_warp(16draws /32cases), andnative_fract_f16_pixel_hardwarepassed;native_fract_f16_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_fract_f16_':4passed,1skipped (77on Intel HD Graphics 530)dev(dropping the0x3BFFclampselect(cmp("eq", h, "15360"), "15359", h)->h): killed bynative_fract_f16_irontiny_neg_2_m12,tiny_neg_min_subnormal, andliteral_src0(0xdead3c00 != 0xdead3bff)AI-assisted.
@R0Y00 on GitHub · 2026-11-28 05:26 UTC · original · approved these changes
Re-reviewed
25d4699d. The experiment note now states the Direct Compute and Pixel scope, mode/refusal coverage and complete build commands. The fixture revision covers the actual-2^-11and-2^-12encodings and checks the rounding bound.I built
compile_dxil,native_compute_ir_dump,native_store_replayandoffscreen_checkin Release and ranctest --preset release --no-tests=error --output-on-failure -j 1 -R '^native_fract_f16_'. All five passed, with no skips, including physical wave32 Compute and both WARP and hardware Pixel readback. Windows 11 26200.9974, DXC 10.0.26100.0, RTX 4060 Laptop driver 32.0.16.1656 and inbox WARP 10.0.26100.9818. The documentation request is resolved.