feat: half precision (f16) in the HLSL recompiler (25 encodings) #219
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!219
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/219/head"
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?
@IxMxAMAR on GitHub · 2026-11-25 16:22 UTC · original
IxMxAMAR:feat/rdna2-f16-hlsl→main· +308 −7 · 6 files · 5 commits · merged 2026-11-25 18:37 UTCChange
Replaces #165, which was closed during the 25 November triage. It is stacked on #218 (the f16 interpreter, which replaces #163): its first 5 commits are that PR's, and this one starts at "the HLSL recompiler translates f16 VOP1 and VOP2". I will rebase it on
mainas soon as #218 is merged.The RDNA 2 → HLSL recompiler translates the 25 f16 encodings the interpreter runs with #218, in compute, vertex and pixel shaders:
v_add,v_sub,v_subrev,v_mul,v_fmac,v_fmamk,v_fmaak,v_max,v_minandv_ldexp_f16, in VOP2 and VOP3;v_fma_f16, in VOP3;v_cvt_f16_f32andv_cvt_f32_f16, in VOP1 and VOP3.They live in a new module,
emu/rdna2_hlsl_f16.py, wired intordna2_hlsl.py(before the SDWA/DPP path, as in the interpreter),rdna2_hlsl_graphics.pyand, since the rebase,rdna2_hlsl_wave64.py.There are no 16-bit types (shader model 6.0 is unchanged, with neither
halfnorf16tof32): an f16 value stays half of a VGPR.precisefunction and comes back to f16 through an integer routine: round to nearest even, denormals, infinities, NaN 0x7E00.The forms the interpreter refuses are refused here too, with the same message; the tests reuse the
REFUSED_VOP3list oftests/test_rdna2_f16.py.New since the rebase: the wave64 path that
maingained (emu/rdna2_hlsl_wave64.py) translates f16 throughrdna2_hlsl.statements, but its prelude lacked theF16*functions. A wave64 program with f16 calledF16AddorF16Fmawithout defining them. One commit adds the functions to that prelude, and the f16 code now takes the caller's active-lane condition (LANE_ONin wave64), like the rest ofmain.test_wave64_translation_carries_the_f16_helpersfails without that commit.Linked issue: Refs #115
AMD driver:
x + 0folded despitepreciseOn the RX 9070 XT (RDNA 4),
v_add_f16 v10, 0, v1with v1 = -0 gave -0 instead of +0. The DXIL from dxc does containfadd float %x, 0.0, with no fast-math flag: the AMD driver folds it into x. Intel and WARP give +0. The sign of an exactly zero result (sum or FMA) is therefore set in integer from the operands; without this, the GPU test fails on the Radeon.Verification
anyxboxx_gpu_run.execame from an older build ofruntime/(set throughANYXBOXX_RUNTIME). With it, the whole suite gives 14 failures, all in runtime tests that need the newer runtime (HDR luminance, console identity, the--adaptateurfields); none is in the f16 files.ab55a2a.main's newtest_multi_lane_pixel_shader_lane_dependent_matches_interpreter[diagonal_split-verts1](#68) fails now and then, onmainalone too.1200+from #218.On NVIDIA, for the earlier revisions:
b73d77c:tests/test_rdna2_hlsl_f16.py19 passed, same bytes as the interpreter (#112).f6ac137: 19 passed on an RTX 4070 Ti SUPER, an RDNA 2 iGPU and WARP.b3d0b59: 31/31 and 19/19, plus 65,536 FMA cases checked on the GPU against exact integer arithmetic (comment on #165).Oracle and test data
The reference interpreter (#218): each GPU test runs the same program in the interpreter and on the GPU, then compares the whole memory byte for byte.
op_sel.Untranslatable; the refusal tests also require the reason in the message.Checklist
Untranslatable).test_readme_sync.pychecks it).Made with AI assistance.