Lower binary16 interpolation of plain 32-bit exports #2219
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2227"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Ybucaille on 2026-11-25T06:18:18Z.
Refs #1996 (item C). Follow-up of #2052, as discussed with @denn0x there.
Summary
#2052 lowered
v_interp_p1ll_f16/v_interp_p2_f16only when the vertex stage exports the attribute withcompr. As denn0x found in an aggregate scan, the programs that use the pair export it as a plain 32-bit word instead: the vertex stage packs the two binary16 halves itself (e.g. withv_cvt_pkrtz_f16_f32) and exports withoutcompr, so #2052 refused all of them. This lowers that plain form.What it does
hof 32-bit channelcisf16tof32(word_c >> 16 * h). When, and only when, the pixel stage reads the attribute as binary16, the vertex stage also outputs two interpolated float4 copies,hparamN_loandhparamN_hi, thef16tof32of the low and high halves of the four words. The pixel stage reads channelcof the copy thathighselects. Channelsxtoware accepted.comprpath is unchanged (halfhof channelcis still float channel2 * c + h; channels aboveyare still refused there).compr, and a read of a channel exported asoff. All the refusals of #2052 still apply (modifiers,op_sel, readers of the upper half, branches between p1ll and p2, I/J not the entry values).Evidence
Local (Linux), on the head of this PR:
python3 -B tests/startup_gfx2hlsl_interp_f16_check.py:controls ok. New controls: plain export, halves lo and hi, compared word by word with a reference computed from the ISA layout; negative controls: the plain fixture read through thecomprmapping, thecomprfixture exported plain, and the high bit inverted, each reads other words than its reference.tests/startup_gfx2hlsl_*_check.py,startup_translator_check.py,startup_image_sample_l_check.py,startup_image_3d_check.py,docs_links_check.py,bidi_controls_check.py: pass.git diff --check origin/main...HEAD: clean.drawmode (whatstartup_gfx2hlsl_interp_f16_warp/_hardwarerun) now draws thecomprpair and the plain pair for both halves, each against its reference, plus a negative control (the other half against this half's reference must mismatch).I cannot run the DXIL draws here (no Windows). As a cross-check, I compiled the translated HLSL of the same fixtures to SPIR-V (
dxc -spirv) and drew it with Vulkan on lavapipe (llvmpipe) and on an Intel UHD (TGL) GPU, with a local tool that is not part of this PR:compr, plain lo and plain hi match their references bit for bit on all 4096 pixels on both devices, and the three negative controls (plain hi against the lo reference, plain lo against hi,compragainst the plain lo reference) fail from pixel (0,0). This is not a substitute for the WARP and hardware runs.Not run: the Windows WARP and hardware draws, and the
/O2configuration. @tedin7, if your server is free:Clean-room: semantics from the same public sources as #2052 (LLVM 15
VOP3Instructions.td/IntrinsicsAMDGPU.td, Mesa ACOemit_interp_instr); fixtures are source-built.AI-assisted (Claude); the commands above were run locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:22:25Z.
Review: COMMENTED
Review of head
38614ae010762898417d79865f1534a4a1088fce(Linux only, no Windows run by me).Findings: P1=0, P2=0.
Checked:
tools/startup/gfx2hlsl.py,tests/startup_gfx2hlsl_interp_f16_check.py,docs/experiments.md). Title is neutral, PR is mergeable. CI: Linux python checks and gfx1013 fixtures pass; the Windows build job was still pending when I looked.f16tof32(word_c >> 16*h), viahparamN_lo/_hi) matches the packed-binary16 layout. Thecomprpath is unchanged.hparamoutputs are emitted by the vertex stage only for attributes the pixel stage reads as binary16 (hlsl_vsdrops them otherwise), and thep + r - qcombine of the generated interpolation wrapper also carries them.offchannel, and the earlier modifier/op_sel/upper-half restrictions are kept.Commands run locally on the PR head:
python3 tests/startup_gfx2hlsl_interp_f16_check.py-> "controls ok", "plain controls ok", "Self-test passed."python3 tests/docs_links_check.py-> 18 files, 412 links OKpython3 tests/bidi_controls_check.py-> no bidirectional controlsgit diff --check origin/main...HEAD-> cleanhparam_lo-> the plain-half readback assertion fails. Killed.git checkout -- .after each mutation.Nits (non-blocking):
plain_params[N]records only the off-set of the latest plain export of a param. If two plain exports to one param differ in their off channels, only the last one is checked. Probably unreachable in practice; a short comment or a refusal would make it explicit.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:41:22Z.
Review: COMMENTED
Re-review of head
223208fe829b5d8521d8c8af13a285cfb722052f(previous review:38614ae). Linux only, no Windows run by me.Findings: P1=0, P2=0.
Delta since
38614ae(2 files, +13/-7):interp_f16now resolves the attribute throughnote_attr, so the pixel attribute follows the interface-table link to the vertex parameter, and the interface component mask is enforced (tools/startup/gfx2hlsl.py:2285).note_attralso records thef16use, so the duplicateattrs.setdefaultin p1/p2 was dropped. This is correct: the lookup intoplain_params/compr_paramsnow uses the linked parameter number, which was wrong before for remapped attributes.wis refused ("undeclared component w").Checked:
f16tof32(word_c >> 16*h)viahparamN_lo/_hi, compr path unchanged,hparamoutputs dropped byhlsl_vsunless read.Commands run locally on the PR head:
python3 tests/startup_gfx2hlsl_interp_f16_check.py-> "plain controls ok", "controls ok"python3 tests/docs_links_check.py-> 18 files, 412 links OKpython3 tests/bidi_controls_check.py-> no bidirectional controlsgit diff --check origin/main...HEAD-> cleangit checkout -- .after each.Nits (non-blocking):
plain_params[N]keeps only the off-set of the latest plain export of a param. A comment or a refusal would make that explicit.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:45:56Z.
I added one integration correction before merging. The f16 pair now reads the stream interface link and component mask, as the ordinary interpolation paths do. A source-built test remaps pixel attr3 to vertex param0 and checks that masking off w is rejected. The plain and compressed GPU draws and wrong-half controls passed on WARP and RTX 4060 Laptop.