tombox-xshader: f16 NaN sign, propagation and default NaN as RDNA2 does #390
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!390
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-390"
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?
@SchmashinPrunes on GitHub · 2026-11-25 20:12 UTC · original
SchmashinPrunes:f16-nan-default-path→main· +20 −5 · 2 files · 1 commits · open@omonkeyz, this is a small follow-up to #389 for the default MODE path. It also came out of comparing the translator with gfx1036 on every lane (#387 harness).
The bug
tb_hadd/tb_hsub/tb_hmul(the f16 add/sub/subrev/mul helpers from #375), and the f16 VOP3abs/negsource modifiers, left NaN signs and the generated NaN to the host:v_sub_f16(−0, NaN 0x7e00)gives0xfe00on gfx1036, but0x7e00on both WARP and an RX 9060 XT;v_subrev_f16(NaN, 0)behaves the same way;v_add_f16with VOP3negon a NaN source behaves the same way.The gfx1036 record (the #387 run, default MODE) gives the rule:
0xfe55 + 1.0,0x7e00 + x−0 − 0x7e000xfe00: the subtrahend's NaN with its sign flipped−inf + inf,inf × 00xfe00, the generated f16 NaN (the same rule #389 implements for the MODE path)Change
tb_hadd/tb_hsub/tb_hmulpropagate an input NaN, src0 first, with the subtrahend's sign flipped intb_hsub, and return0xfe00for an invalid operation.h16, the f16 VOP3absandnegmodifiers clear or flip the sign bit instead of usingabs()/(-x).The signalling-NaN passthrough (gfx1036 keeps
0x7c01, while the hosts'f16tof32quiets it on the operand read) is not covered. That needs operand reads changed across all f16 ops.Tests
New
exec_vop::basic::f16_nan_sign_and_generation_as_rdna2, 8 cases from the gfx1036 record.hlsl.rschangetests/exec.rstests/exec.rsisa_sweeptarget, WARPWARP_KNOWNf64 deviations)The PR gate is clean. This touches the same
h16closure as #385 and the prelude next to #388's helpers, so whichever lands second may need a trivial rebase. I'll do it.🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.