shader: lower two-word constant buffer reads in the pixel translator #299
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/304"
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 rasptum on 2026-11-21T21:37:28Z.
Change
tools/pixel_aot.pynow lowerss_buffer_load_dwordx2. It reads two consecutive words from the tracked four-SGPR constant descriptor into an SGPR pair, and each word becomes one component ofparams[...], the same value model the four-word load and the one-word load from #277 use. Before this change the instruction stopped translation withUnsupported instruction.The rules are the ones the neighbouring loads already apply:
s_load_dwordx4;nullis offset zero), dword-aligned, and both words must lie inside the 256-byte desktop binding, so the last accepted offset is 248. An 8-byte alignment is not required: the instruction reads two words at any dword-aligned address;s[104:105]. This is the only pair form LLVM names: LLVM 15 answerss[61:62]withinvalid register alignment;s_waitcnt lgkmcnt(0).The register-offset form, the eight-word and sixteen-word buffer loads and
s_load_dwordx2remain rejected.Shared interface touched: the scalar constant load branch of
lower()intools/pixel_aot.py(one pattern and the destination-width check) and the fixture lists intests/pixel_aot_check.py.fp_operand, the scalar value model and thes_waitcnthandling are unchanged. This builds on #277.Overlapping open work, checked with
git merge-tree --write-treeagainst each PR head on 2026-11-21, before the final rebase ontob53bfb0:tools/pixel_aot.py. #279 gets a textual conflict intests/pixel_aot_check.pyonly, where both sides add fixtures at the same places. #232 and #257 already conflict with currentmainin the same files and this change adds no file to that.s_waitcnthandling): #271 merges cleanly. #176 already conflicts with currentmain; this change does not touch the wait handling orsample_pending.tests/pixel_aot_check.py(and #283 indocs/experiments.md), again from adjacent additions. #288 merges cleanly.None of these needs to land first. I will rebase and rerun if one of them merges before this.
Verification
Commit 28ef21b on
main1292d15(rebased after #292, #297 and #279 landed; results below are from this commit). Windows 10 22H2 build 19045, debug layer enabled.Fail before, with the new tests and the translator from
main:Pass after:
pixel_aot_warppixel_aot_hardwaredevThe new draw reads pairs at offsets 12, 20 and 248 and compares all four channels of 4,096 pixels bitwise with a CPU reference, with two sets of constants. The negative controls report
pixel_mismatch x=0 y=0on all three adapters: changing the second word of each pair in the bound buffer (bytes 16, 24 and 252, one draw each) and reading the middle pair one word early.Full suite,
ctest --preset dev --no-tests=error: 145 tests, 126 passed, 17 skipped (capability skips, reported separately from passes), 2 failed. Both failures are on the in-box WARP 10.0.19041 and are outside this change, which touches onlytools/pixel_aot.py,tests/pixel_aot_check.pyanddocs/experiments.md.bc7_draw_warpreportsAOT color export differs from CPU referenceand fails the same way with the test and translator sources frommain.gpu_alias_lookup_writes_warp, a compute test added by #284, reportsrecord=1 field=64 expected=0001f5a0 actual=0007d680. Both pass on WARP 1.0.22.Full suite on the Agility SDK build with WARP 1.0.22,
ctest --test-dir out/build/w10-full --no-tests=error: 145 tests, 140 passed, 3 skipped, 2 failed. The failures arebvh_wave64_warpandwave_shuffle_warp, the known WARP behaviour in #145.LLVM 15.0.7 round trip:
Passed, exit 0, with one caveat: the Windows LLVM 15.0.7 package has no
llvm-mc, so a local wrapper outside the repository forwarded the assembler call toclang --target=amdgcn--amdpal -mcpu=gfx1013 -c -x assembler. The test file itself is unchanged, and CI runs it with the realllvm-mc-15. LLVM 15 prints the new fixture lines exactly as written in the test, for examples_buffer_load_dwordx2 s[62:63], s[44:47], 0x14, prints offset zero asnull, and prints the register-offset form ass_buffer_load_dwordx2 s[64:65], s[44:47], s60, which the translator rejects. I did not check a newer LLVM spelling.Pure-Python checks from
AGENTS.md(bcpack_check,form_coverage_check,dxcontainer_part_offsets_check,layout_chunks_check,resource_ranges_check,script_state_check,intake/paths_check): all exit 0.Evidence and follow-up
The fixture is a source-built text program in
tests/pixel_aot_check.py(with_scalar_pair_reads), written for this change and submitted under the MIT License like the rest of the test. Each of the six loaded words feeds its own step (multiply, maximum, add, subtract, move, multiply), and the reference asserts that every step is exact in binary32, so the comparison does not depend on rounding direction or fusion. The first pair spans twofloat4rows of the desktop buffer.check_controlsadds 20 rejected variants of one load (misaligned and out-of-range offsets, register offset, odd, short, long and out-of-range destinations, wrong base, the one-word and four-word mnemonics with a pair destination,s_load_dwordx2, and the eight-word and sixteen-word loads) plus ordering cases: a load before the descriptor is ready, reads and writes of either word before the wait, a second load into a pending pair, and a load after the descriptor registers were overwritten.Assumptions: the desktop buffer mirrors the 256 bound bytes word for word, as for the existing loads. Execution with a title's own pipeline state remains unverified.
The README shader row already says supported programs read constants, so it is unchanged.
docs/experiments.mdhas a new paragraph under Offline pixel shader recompilation; the reproduction command there is unchanged:ctest --preset dev -R '^pixel_aot_' -V.Follow-up another contributor can pick up: the register-offset form of the scalar buffer loads, the eight-word and sixteen-word loads, and the two in-box WARP 10.0.19041 failures noted above (
bc7_draw_warp, which I am looking at, andgpu_alias_lookup_writes_warp).AI-assisted (Claude Code). The Windows results were measured locally.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:58:31Z.
At
3bce854the merge conflicts are intests/pixel_aot_check.py. Keep the x2 LGKM and alias tests alongside the landed scalar/BFE cases.Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-21T22:07:10Z.
Conflicts resolved
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T02:38:49Z.
I reviewed
28ef21b. #283 has since landed, and GitHub now refuses the merge. Both branches replace thecheck_binaryfixture list ending in(ceiling(), translate), (scalar64(), translate)intests/pixel_aot_check.py. Please retain main’saffine_coordinates()alongside your two-word constant load cases, keep the MAD fixture added by #288, and rerun the LLVM 15 round trip and Windows pixel tests on the reconciled head.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:26:21Z.
I reviewed
8d3113c; it resolves the previous overlap and passed all three jobs. #293 landed immediately before the merge attempt. A test merge now reports justtests/pixel_aot_check.py. Please retain the new class-mask fixture alongside your constant-pair cases there. I’ll prioritize the reconciled head when its checks finish.