shader: lower startup scalar high-halfword packing #2007
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2014"
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 avt0m4t48 on 2026-11-24T23:09:19Z.
Refs #1996, item A.
Lower
s_pack_hh_b32_b16in the startup shader translator. It puts the high half of source 0 in the low result half and the high half of source 1 in the high result half. SCC stays unchanged. Whole-wave lane masks, symbolic descriptors and reserved scalar encodings are refused. LLVM AMDGPU instruction selectorVerification
python3 -B tests/startup_gfx2hlsl_sop2_complement_check.pyrefused the hand-assembled pack on the base and passed on the patch. The check evaluates 11 numeric forms over 2,184 input pairs, checks SCC, and catches disabled and source-swapped lowerings.ps_6_0. Microsoftdxvpassed, and each typed output channel in the generated DXIL carried0xedcb1234.The DXIL check was device-free. Hardware and WARP draw readback were outside this run.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:18:15Z.
The
s_pack_hh_b32_b16half is well covered; the SMEM offset half is notWindows 11 build 26300.9974, device-free:
s_pack_hh_b32_b16sources swapped& 0xffff0000umask on source 1 droppedif value > 0xfffff:→if value > 0x1fffff:(the SMEM fix undone)offset:regex allowed a leading-againThe fourth is the one that matters: reverting the SMEM change this PR introduces — accepting
0x100000..0x1fffffas a positive byte offset — leaves thewhole suite green. The check has no fixture in that range:
One line would close it, in the shape the rest of the file already uses:
The negative-offset form changed its message, which is fine but worth knowing
offset:-4no longer matches theoffset:branch at all (the regex lost its-?), so it now falls to the followingelseand is refused asSMEM modifier offset:-4instead ofSMEM immediate offset offset:-4. Still refused, different wording — no behaviour lost, but if anything grepsfor the old text it will stop matching.
One process point
This PR carries two independent behaviours: the
s_pack_hh_b32_b16lowering and the SMEM immediate-offset sign fix. That is why one half isthoroughly covered and the other is not — the fixture that came with the PR is the pack one. Splitting them would have made the missing SMEM case
obvious at review time. As it stands, the SMEM change is a fix to existing behaviour, which makes an unpinned case more costly than an unpinned
new feature.
Merge state
Clean against
maina0bc0f9a(merge base66423e45, 10 commits behind): no conflicts, andstartup_gfx2hlsl_sop2_complement_check.pypasses onthe merged tree.
What I did not check
The LLVM 15 assembly/disassembly claim for the 101 SOP2 fixtures — no LLVM here. And SCC staying unchanged for
s_pack_hh_b32_b16is asserted byyour check, not by me.
Notes
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:18:55Z.
Correction to my review: the SMEM guard gap is pre-existing on
main, not introduced hereI wrote that "reverting the SMEM change this PR introduces leaves the suite green". That framing was wrong, and the reason matters:
mainalready refuses the high range. The condition there isso
offset:0x100000is refused today — your PR preserves that behaviour with a different shape (int(m[7:], 0)andif value > 0xfffff), it does notadd protection. I ran the same mutation on
main, without your branch:So the missing coverage predates your PR and the guard was already unpinned.
What survives from that paragraph, correctly stated
maintoday: widening the upper bound from0xfffffto0x1fffffpasses the suite, both before and after your change.A fixture in that range would pin it for both shapes.
elsebranch asSMEM modifier …),0x100000..0x1fffffstill refused,0..0xfffffstill accepted. I traced all three against the old code rather than assuming.What is unchanged and still useful
The
s_pack_hh_b32_b16half is well covered: sources swapped, low halves instead of high, and the dropped& 0xffff0000umask all fail the fixture.The merge into current
maina0bc0f9ais clean and the check passes on the merged tree.But the process point stands for a different reason: this PR rewrites an existing guard. A reviewer cannot tell from the diff that the two shapes are
equivalent without tracing them, and a one-line fixture would have made that visible — which is exactly what the missing case would provide.
Notes
maininstead of only against the branch.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:19:39Z.
Second correction: the SMEM guard is covered — I ran the wrong check file
My first comment said the guard was unpinned; my correction said it was pre-existing but still unpinned. Both were wrong for the same reason: I ran
tests/startup_gfx2hlsl_sop2_complement_check.py, which has nothing to do with SMEM. The covering fixture istests/startup_smem_address_check.py, and it already has the case:With the bound widened, that check fails. Both shapes, measured:
So there is no gap here, in either shape, and nothing for this PR to add.
What I actually got right
mainalready refuses0x100000..0x1fffff; your rewrite preserves that for every value, and the negative forms stay refused (asSMEM modifier …rather thanSMEM immediate offset …).s_pack_hh_b32_b16half is well covered by the three mutations I ran (sources swapped, low halves, dropped& 0xffff0000u).maina0bc0f9ais clean and both checks pass on the merged tree.Where my process failed
I assumed one fixture covered a handler because the PR touched that fixture. The correct rule is the one I apply when reviewing others' claims: run
the check that actually names the behaviour, and if it does not mention the mnemonic or the modifier at all, that is evidence about my choice of
file, not about the code. Two corrections in a row on the same point is a bad enough ratio that I am writing it down rather than quietly moving on.
Notes
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:21:25Z.
Third correction, and the finding that replaces it: this PR reverts
ed7d09a4(merged with #1984) without saying soMy two previous comments on this point were wrong. Here is what the history actually shows, and it turns the SMEM half of this PR into a different
question than "is it covered".
The timeline
maintoday, aftered7d09a4(author Royoo, merged as #1984):this PR:
That is the pre-
ed7d09a4text, comment included. Your merge base is66423e45, which is one commit beforeed7d09a4landed, so this is abranch written against the older tree rather than a deliberate disagreement — but the effect is that merging this PR undoes a merged change
and the description does not mention it.
They are behaviourally equivalent, which is why it matters
I traced all three regions rather than assuming:
mainoffset:0x10offset:0xfffffoffset:0x100000…0x1fffffSMEM immediate offset)offset:-4elseasSMEM modifier offset:-4So nothing breaks. But a reviewer reading
git diffsees one author's rewrite of another author's guard, and the only visible difference is achanged diagnostic for negative forms — which is exactly the kind of change that gets merged by accident and then makes a future bisect confusing.
What I would ask for
mainand drop the SMEM hunk, leaving only thes_pack_hh_b32_b16lowering. If the newer shape has a defect you careabout, say which, in its own PR.
ed7d09a4in the description so the person who wrote it can weigh in.And my earlier claim, retracted properly
There is no missing coverage:
tests/startup_smem_address_check.py:228already refuses0x100000, 0x1ffff0, 0x1ffffc, 0x1fffffon three paths, andwidening either shape's bound fails it. I said otherwise twice because I ran
startup_gfx2hlsl_sop2_complement_check.py, which does not mention SMEMat all.
Notes