shader: lower the binary16 interpolation forms #3613
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!3613
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3611"
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?
@lambirou on GitHub · 2026-11-30 13:51 UTC · original
lambirou:shader/f16-interp→main· +531 −17 · 12 files · 7 commits · openPart of the f16 interpolation slice (Refs #839).
This adds the three binary16 interpolation forms:
v_interp_p1ll_f16,v_interp_p1lv_f16andv_interp_p2_f16, in the attribute profile without a sampler and under the entry mask. Thecomprlayout places the two halves ofattr0.xinTEXCOORD0.xyand the two halves ofattr0.yin.zw. p1ll/p1lv record a typed partial and p2 writesnarrow16(uv.<component>)as ahalf16result, so only the low 16 bits are defined. The p1lv source must be a VGPR whose selected half is finite and proven;half_denorm="preserve"is required and round-toward-zero is refused.Refusals: modifiers,
clamp, omod,op_sel, non-VGPR sources, attributes beyondattr0.y, a sampled programme, a missing/differentm0, a non-entry mask, unaudited readers, the full-word, pack and export uses, and reading the p1 partial.Tests
pixel_aot_f16_interp_warpand_hardwarepass (2/2) on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010).pixel_mismatchon both adapters.check_f16_interp_controlspins the three forms and every spelling, proof, mode, scheduling and reader refusal;form_coverage_check.pypasses and keeps the f32 interpolation, the MIMG sample forms and the packs uncovered.rdna2_tools_check.pypasses 162 tests (19 LLVM-dependent skips);pixel_aot_attributeandpixel_aot_e64_spellingsstill pass (6/6).Limits
The AOT translator has no LDS binding: the desktop rasteriser evaluates the plane, as for the f32 pair, and the lowering does not consume the Scarlett P0/P10/P20 binary16 words directly. Exact equality with the native calculation for non-exact binary16 vertices remains an assumption. The high half of the p2 destination is not observed. The path is limited to
attr0.x/y, the entry mask and programmes without a sampler; runtime or non-finite p1lv sources are refused.AI-assisted.
@lukaslw-lab on GitHub · 2026-11-30 20:40 UTC · original · requested changes
Reviewed
188818b0by reading the diff; not built or run.Verdict: changes requested.
v_interp_p1lv_f16drops its VGPRP0operand, so an accepted program can produce the wrong value.p1lvcomputesP10·I + S2.half: the VGPR half replaces the attribute'sP0. Afterp2, the guest result isP0' + P10·I + P20·J, whereP0'isS2. The lowering provesS2finite and then discards its value (tools/pixel_aot.py,form == "p1lv"branch). The completedp2always emitsnarrow16(uv.<c>)(p2branch), which is the host-interpolated attribute with its ownP0. That is right only whenS2equalsP0, which the translator cannot know. The draw shows it:v20 = 0x3c003800givesS2= 0.5 (low) and 1.0 (high). At vertex 0 oftests/pixel_aot_vs.hlsl, attr0.y's halves areuv.z = 0.25anduv.w = 1.0, so thehighrow matches only by coincidence. For the low-half rows, hardware returnsuv.z + 0.25, while the lowering and its reference returnuv.z. No mutation changesS2, so the draw cannot see this. Suggest either refusingp1lvin this slice (keepp1ll+p2), or bindingP0explicitly (e.g. a flat input like #3625'sTEXCOORD1), lowering tonarrow16(uv.c − P0 + S2)and deciding where it rounds.p1ll+p2matches the host plane whenP0comes from the attribute, andnarrow16is RNE. The1 + uv/64vertices separate RNE from truncation.attr0.xto.xyandattr0.yto.zw, and thehighbit picks the second of each pair.attr0.y, a sampled program, non-entry masks, unpairedp1/p2, and round-toward-zero (the generic binary16 gate).half16result only reaches the audited readers.Tests: the draw compares against
TEXCOORD0with two mutations (halves swapped, channel swapped). Neither changesS2, so thep1lvoperand is unpinned. The controls run in the Linux LLVM job (passed).pixel_aot_f16_interp_{warp,hardware}are not in the Windowsprpreset filter. Theoffscreen_checkchanges add only the f16/fine batch entry points.@Leyukaka on GitHub · 2026-12-01 16:09 UTC · original · reviewed
The fine draw does not exercise rounding for the P1LL/P2 pairs. In both test programs those pairs read X and Y. At the 64 pixel centers, the fine X values are 1 + (2x + 1)/1024, and Y follows the same formula with y. Every one is exactly representable in binary16. Counting where nearest-even differs from truncation gives X=0, Y=0, Z=32, W=0. Only the P1LV/P2 pair on Z detects the truncating-reference mutation.
For example, changing only the fine X input to 1 + u/128 would give 32 pixels where rounding matters for a P1LL/P2 result. Please add a mutation that truncates only that result. Its readback should then differ on X while the P1LV/P2 outputs remain unchanged.
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.