shader: lower flat_load_dword through TitleLookup in pixel_aot #688
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/694"
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 Its3rr0rsWRLD on 2026-11-22T20:40:57Z.
This is Claude Opus 5.5. It is the first flat-load step for #319, built on the design notes thepatrickworld posted there.
flat_load_dword, andglobal_load_dwordwithoff, now read one DWORD throughTitleLookupfrom #284. The address is the VGPR pair plus the offset, sign-extended to 64 bits with the carry or borrow taken into the high word. Ranges are aStructuredBuffer<TitleRange>att0, space1and the aliased buffers areByteAddressBuffer TitleAliases[8]att1, space1withNonUniformResourceIndex, onps_6_0. A miss, a DWORD not inside a single range, a misaligned address or a slot past 8 reads0xdeadbeef. The globaloffform is included because it is the same lowering, and LLVM 15 only accepts gfx1013 flat offsets from 0 to 2047, so the borrow case can only be tested through it. Wider, sub-DWORD and D16 loads, stores, atomics, scratch, thesaddrandldsforms and cache bits stay refused, each by a control.One program reads two addresses from the constant buffer. Six cases cover the first and last word of a range, carry and borrow across the 32-bit boundary, misses, a straddling DWORD and four slots. Eight wrong references must report
pixel_mismatch, each followed by a passing draw: 22 draws in one batch. The program is also in the LLVM 15 round trip.Test:
ctest --preset dev --no-tests=error -R '^pixel_aot_title_loads_(warp|hardware)$' -V. Passed on an RTX 4070 Ti (1.4 s) and on WARP (0.8 s);pixel_aot_hardwareandpixel_aot_warpstill pass.Questions for R0Y00:
title_ranges=N, as now), or read at run time from a root constant orGetDimensions?0xdeadbeefthe right result for a miss, a straddling DWORD and a misaligned address, or should translation refuse instead?tools/scan_unsupported_shaders.pycount these forms as supported? This PR leaves it unchanged.dwordx2/x3/x4, then 8- and 16-bit loads, then the globalsaddrform?🤖 Generated with Claude Code
https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T04:36:27Z.
For the first DWORD-only profile, keep the fixed range count, eight bound aliases and existing TitleLookup miss sentinel. Document those as properties of the explicit binding profile.
global_load_dword ... offfits directly. Acceptflat_load_dwordonly when that profile explicitly guarantees a global address and excludes scratch/LDS apertures. Keep bit-11 flat offsets outside this slice until there is an independent encoding and effective-address comparison. Please keep these forms out of generic scanner coverage unless the scanner can establish the profile’s binding and address preconditions. Wider, sub-DWORD and saddr forms can remain separate. The existing carry/borrow, alignment, straddle and wrong-slot cases should stay in the DWORD fixture.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T06:29:43Z.
I pushed
7ec6337with the explicitflat_global_only=Truebinding option and resolved the renderer and lowerer conflicts. The new static control rejects a flat load when only the range table is supplied, while the globaloffform still lowers in that mode. Windows Release passed title-load readbacks on hardware and WARP, plus the existing WARP buffer-color and compressed-export checks. The LLVM and Windows CI results for the pushed commit are pending.Imported from R0Y00/Xbox2Windows. Originally posted by MatyEjsr on 2026-11-23T06:52:53Z.
Verdict: Approve (static, Python, offline DXC, and ISA review of head
7ec6337ba6c3677ddb7479479e40958b7396d65a, compared againstmain20e4357).Verification
Environment: Windows 11 x64, Python 3.12.10, DXC
1.9.0.5512(C:\VulkanSDK\1.4.363.0\Bin\dxc.exe) for offline HLSL-to-DXIL compile checks, and WSL Archllvm-mc23.1.5 (-triple=amdgcn--amdpal -mcpu=gfx1013) for ISA offset bounds. Zero-GPU review (no WARP or hardware draw executed locally; all 4 CI jobs including Windowsdevand/O2passed on7ec6337).Commands and results on
7ec6337:python -B tests/pixel_aot_check.py: passed (exit 0).python -B tests/rdna2_tools_check.py: 64 passed, 1 skipped (test_llvm_comparison, skipped becauseLLVM_LIBis not set on Windows).python -B tests/docs_links_check.py(13 files, 154 links) andpython -B tests/bidi_controls_check.py(654 files): both passed.git merge-tree --write-tree main 7ec6337: clean against20e4357(exit 0).Independent ISA, DXC, and negative-control checks:
llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013 -show-encoding): Confirmedflat_load_dwordaccepts0..2047and rejects2048/4095/-4(expected a 11-bit unsigned offset), andglobal_load_dword ..., offaccepts-2048..2047and rejects2048/-2049(expected a 12-bit signed offset), matchingTITLE_OFFSETS.-T ps_6_0 -E main -WXand-T ps_6_6 -E main -WX): Bothflat_load_dword(title_ranges=2, flat_global_only=True) andglobal_load_dword ... off(title_ranges=2) lowered HLSL compiled cleanly (exit 0, 0 warnings/errors).flat_load_dwordwithoutflat_global_only=True,flat_load_dwordwithouttitle_ranges,title_rangesin{0, -1, True},flat_load_dwordexported withouts_waitcnt,glcmodifier, andoffset:2048.flat_load_dword v18, v[18:19]).scan_unsupported_shaders.is_instruction_supported("flat_load_dword v12, v[18:19]") == False(andis_opcode_recognized("flat_load_dword") == True), matching the explicit binding-profile requirement.Non-blocking note: on
gfx1013hardware,flat_load_dwordincrements bothvmcntandlgkmcnt, whereaslower()tracks it only viasample_dest(vmcnt), sos_waitcnt vmcnt(0)alone clears it here. That is acceptable for the explicitflat_global_only=Trueglobal-address slice, and worth keeping in mind if a future profile models non-global flat apertures.AI-assisted review (local Python, offline DXC, and
llvm-mcchecks executed locally).