shader: unpack A16 coordinates for startup image loads #1847
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1854"
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-24T19:38:38Z.
The startup pixel translator currently reads two full-width VGPRs for a plain 2D image load with A16 set. The source-built fixture packs x=1 and y=2 into one register and puts 63 in the next register so the two layouts cannot accidentally agree.
Decode the two unsigned halves, preserve full-width mip-zero behavior, and refuse D16 results and TFE status layouts explicitly. Advance both the runtime and offline shader cache keys so older translations are regenerated.
Verification on Linux:
python3 -B tests/startup_image_load_mip_check.py --llvm-mc /tmp/scarlett-tools.7m6eFM/root/usr/bin/llvm-mc-19passed on the rebased patch. The A16 regression failed before the fix. LLVM 15 also reproduced the fixture bytes on the original topic base.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:45:04Z.
Review: COMMENTED
Review of
56bd3bd1(merge base5f16bc20;origin/mainis now8a61ae06). Comment only, not an approval.Verdict
No P1 or P2 found. The A16 lowering matches the encoding it claims to model, and the tests that matter kill my mutants. Three P3 notes below. Clean-room and title-neutral: the fixture is synthetic (x=1, y=2 packed in v0, 63 in v1), no game files, dumps or titles.
What I checked
image_load, x is the low and y the high unsigned half of one VGPR, sor0.Load(int3(v0 & 0xffffu, v0 >> 16, 0))is the right shape. Thed3d12_draw.inlandgfx2hlsl.pyrevision strings are both bumped to-5and the test pins that the key changed.d16,tfeanda16on 3D are refused withUnsupported, anda16is not accepted forimage_load_mip. dmask and dim handling are unchanged for the accepted path.image_load+ 2D + a16, so other MIMG ops keep their old address count.P3: scope of the stricter check
The modifier allow-list (
dim:,dmask:,unorm,glc,slc,dlc, plusa16when packed) used to apply only toimage_load_mip. It now applies to every plainimage_load, and an empty dmask is refused too. That is stricter, and I think correct (r128, lwe and tfe were silently read as plain loads), but the description only mentions d16/tfe. A capture that carries one of those bits will now stop withUnsupportedinstead of translating. Worth one sentence in the description or docs.P3: guards not pinned by the test
Mutants run one at a time against
tests/startup_image_load_mip_check.py --llvm-mc llvm-mc-19:>> 16changed to>> 8, low-half mask dropped, Python key revision reverted, disassembler one-register rule dropped, unsupported-modifier check dropped.(packed_2d and len(cs) != 1)fromwrong_address. No case feeds ana16load a two-register address, so that refusal is untested.revisionind3d12_draw.inlagreeing with the Pythonpipeline_keystring. Only the Python side is asserted. They match here (git grep x2w-startup-shader-), but a later bump of one would pass CI.P3: no NSA a16 case
The disassembler sets the address count to 1 for a16 loads whatever the encoding. I did not build an NSA-encoded a16 load, so I cannot say whether it decodes sensibly.
Commands run (Linux, Python 3.14.8, llvm-mc-19 for the fixture bytes)
python -B tests/startup_image_load_mip_check.py --llvm-mc llvm-mc-19: passes; also passes without--llvm-mc.gfx2hlslordisasm_rdna2, run with no arguments on this SHA and onorigin/main: identical exit codes everywhere (the ones that exit 1 do so on both, because they need DXC or extra arguments).rdna2_tools_check.py: OK (skipped=18).python -B tests/docs_links_check.py: Self-test passed. Checked 18 Markdown files and 370 links.python -B tests/bidi_controls_check.py: Self-test passed. Checked 1324 tracked source, script and build/CI files: no bidirectional controls.git diff --check origin/main...HEAD: clean.git checkout -- ..Not run
Windows D3D12 execution, DXC validation of the generated shader, and CI's
llvm-mc-15(I used 19). Whether hardware reads A16 loads the way the translation assumes is not something Linux checks.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:56:32Z.
Review: COMMENTED
Re-review of the new head
5b46e98e(one commit on top of56bd3bd1, which I reviewed earlier; merge base5f16bc20,origin/mainis nowdd753176andgit merge-treemerges cleanly). Comment only, not an approval.Verdict
All four points from my earlier review are addressed, each with a test that fails when the fix is removed. No new P1 or P2.
The earlier findings, one by one
a16with two address registers was untested. Nowcheck_plain_load_layoutscallspipe.ps.image([..., '[v0, v1]', ...], [..., 'a16'], 'load')and requiresUnsupported. Mutant: dropping(packed_2d and len(cs) != 1)fromwrong_addressnow fails withA16 image load accepted two address registers.revision[]fromsrc/startup_stubs/d3d12_draw.inland requires that the key built from it equalspipeline_key(). Mutants: C++ string back to-4, and drifted to-6: both fail withoffline and desktop startup cache revisions differ.a16loads.disasm_rdna2.pynow adds aninvalid_nsamodifier when a packed 2D load carries an NSA extension, the translator refuses it by name, and the test patches a real encoding (0a0f00f000040440 01000000) to prove it. Mutant: removing theinvalid_nsamarker fails withinvalid_nsa image load accepted with unsupported layout.dmask,r128,lwe,d16,tfeand reserved bits, and the test has one case for each (r128,lwe, reserved bit,dmask:0x0). Mutant: removing the unsupported-modifier check fails ond16.Other mutants I ran, all killed: packed path off,
>> 16changed to>> 8, the disassembler one-register rule dropped.Commands run (Linux, Python 3.14.8, llvm-mc-19)
python -B tests/startup_image_load_mip_check.py --llvm-mc llvm-mc-19: passes; also passes with no argument.tests/rdna2_tools_check.py: OK (skipped=18).gfx2hlslordisasm_rdna2, run on this head and onorigin/main: identical exit codes for every one (those that exit 1 do so on both, they need DXC or extra arguments).python -B tests/docs_links_check.py: Self-test passed. Checked 18 Markdown files and 370 links.python -B tests/bidi_controls_check.py: Self-test passed. Checked 1324 tracked source, script and build/CI files: no bidirectional controls.git diff --check origin/main...HEAD: clean. All mutations reverted withgit checkout -- ..Not run
Windows D3D12 execution, DXC validation of the generated shader, and CI's
llvm-mc-15(I used 19). Whether hardware reads A16 loads this way is not something Linux checks.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by avt0m4t48 on 2026-11-24T19:51:30Z.
Follow-up is in
5b46e98e. The docs now list the plain-load refusals. The regression checks the two-register lowering refusal and derives the expected offline key from the revision in the C++ runtime.With
llvm-mc-19 -arch=amdgcn -mcpu=gfx1013 -show-encoding,[v0]emitted the same 8 bytes asv0and[v0,v1]failed the address-size check. The decoder had accepted a patched 12-byte instruction by discarding the extra address word. It now preserves that invalid encoding asinvalid_nsa, which the startup lowering refuses. The new control reproduced the old acceptance before the fix.The focused fixture passed with LLVM 15 and 19. The LLVM 15 disassembler suite passed 147 cases with one skip. Windows GPU execution of the A16 shader remains unverified.