shader: lower flat_load_dwordx2 and global_load_dwordx2 through TitleLookup in pixel_aot #2378
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2386"
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 Makto94 on 2026-11-25T14:41:21Z.
Refs #319
Problem
tools/pixel_aot.pylowersflat_load_dwordand theoffform ofglobal_load_dwordthroughTitleLookup(#694), but refuses the two-DWORD forms. A shader that loads a 64-bit value withflat_load_dwordx2orglobal_load_dwordx2cannot be translated.Change
flat_load_dwordx2 v[d:d+1], v[a:b] [offset:N](only withflat_global_only=True, likeflat_load_dword) andglobal_load_dwordx2 v[d:d+1], v[a:b], off [offset:N]lower totitle_load_dwordx2. It callsTitleLookup(..., 8, ...)and reads the aliased buffer withLoad2.vmcntaccounting are the same as for the DWORD forms. Both destination words stay outstanding until a covering wait, and the QWORD counts as one load invmcnt.0xdeadbeefin both words. This follows the contract written insrc/title_va_lookup.hlsli: a lookup succeeds only when the whole access lies inside one range.git grep "TitleLookup("intools,srcandtestsfinds only 4-byte callers before this change, so this is the first 8-byte caller. The choice is isolated in thetitle_load_dwordx2helper and in its control; the lowering does not split the access. The question about this case in the 24 Nov comment on #319 is still unanswered.saddr,glc/slc/dlc,lds, 8/16-bit and D16 loads, stores, atomics, scratch, flat offsets with bit 11 set, and a missing explicit profile.No open PR or public branch with a flat/global prototype from thepatrickworld was found when this PR was prepared.
Tests
tests/pixel_aot_check.py:check_title_load_x2_controls(part ofcheck_controls): translation shape, the 8-byte lookup, one helper, DWORD output unchanged, the refused forms above, register-pair and offset errors,vmcntreadiness of both words, overlap with a DWORD load in flight, thev[254:255]pair in both segments, and a partialvmcnt(1).check_title_load_draws: a second source-built program reads the QWORDs at A + 2040 (flat) and B - 2048 (global). Seven cases: hit in two slots; last QWORD of two ranges; QWORD across the adjacent ranges at0x2_0000_1000and across a range end (both words miss); two misses; QWORD across the 32-bit boundary inside one range and last QWORD of that range; last QWORD of the last range and a QWORD across a range end into a hole; the negative global offset borrowing across the low 32 bits with the QWORD crossing 2^32 inside one range.pixel_mismatch, each followed by the passing draw: words swapped, 4-byte lookup instead of 8, range accepted for the first word only, separate lookup per word. 15 draws in one--check-pixel-batchprocess, withinpixel_aot_title_loads_(warp|hardware).docs/experiments.md: new paragraph after the DWORD one.Mutation checks
Each mutant was applied in a temporary copy. The test fails with the mutant and passes on this change. The mutants were run at the previous revision of this branch; between it and
d54443e4the only change intools/pixel_aot.pyis a line break in a comment, and the tests only gained the borrow case.swap_words(helper returns the words swapped)draw-title-loads, WARPmiss_second_zero(second word of a miss is 0, not0xdeadbeef)draw-title-loads, WARPcarry_dropped(carry of the low-word add dropped in the x2 helper)draw-title-loads, WARPsecond_word_vector_wrong(second word bound to the wrong register)draw-title-loads, WARPdraw-title-loads, WARP, case 7 (negative offset, QWORD across 2^32); it survives without that casecheck_title_load_x2_controls)vmcntcounterVerification
Commit under test:
d54443e4. Windows 11 build 26300.9974, Debug build, dxc 1.9.2602.17.pixel_aot_title_loads_warp: passed (1/1).pixel_aot_title_loads_hardware: passed (1/1), serial run on an idle machine. 0 capability skips (77). The successful test does not print the adapter; the only hardware adapter in this machine is an NVIDIA GeForce RTX 3070 Ti, driver 32.0.16.2101.offscreen_checkenables the D3D12 debug layer when it is available, and other runs of the same renderer on this machine printdebug_layer=enabled. In--check-pixel-batcha debug-layer error marks the case aserror, so a passing batch had no debug-layer errors.Limits
pixel-binaryruns it.TitleLookuprequires only 4-byte alignment. This is not a measurement of the console.TitleLookupcontract, not a statement about how the console resolves a QWORD across two allocations.ctest --preset pr) does not selectpixel_aot_title_loads_*, so the draw runs above are local.