shader: lower flat_load_dwordx2 and global_load_dwordx2 through TitleLookup in pixel_aot #2378

Merged
Makto94 merged 1 commit from upstream-pr/2386 into main 2026-11-25 15:10:11 +00:00
Makto94 commented 2026-11-25 14:41:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T14:41:21Z.


Refs #319

Problem

tools/pixel_aot.py lowers flat_load_dword and the off form of global_load_dword through TitleLookup (#694), but refuses the two-DWORD forms. A shader that loads a 64-bit value with flat_load_dwordx2 or global_load_dwordx2 cannot be translated.

Change

  • flat_load_dwordx2 v[d:d+1], v[a:b] [offset:N] (only with flat_global_only=True, like flat_load_dword) and global_load_dwordx2 v[d:d+1], v[a:b], off [offset:N] lower to title_load_dwordx2. It calls TitleLookup(..., 8, ...) and reads the aliased buffer with Load2.
  • Address, offset ranges, profile and vmcnt accounting are the same as for the DWORD forms. Both destination words stay outstanding until a covering wait, and the QWORD counts as one load in vmcnt.
  • A QWORD that does not lie inside one range, including one that straddles two adjacent ranges, reads 0xdeadbeef in both words. This follows the contract written in src/title_va_lookup.hlsli: a lookup succeeds only when the whole access lies inside one range. git grep "TitleLookup(" in tools, src and tests finds only 4-byte callers before this change, so this is the first 8-byte caller. The choice is isolated in the title_load_dwordx2 helper 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.
  • The helper is emitted only when a program uses it, so DWORD-only output is unchanged.
  • Still refused: x3, x4, 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 of check_controls): translation shape, the 8-byte lookup, one helper, DWORD output unchanged, the refused forms above, register-pair and offset errors, vmcnt readiness of both words, overlap with a DWORD load in flight, the v[254:255] pair in both segments, and a partial vmcnt(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 at 0x2_0000_1000 and 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.
  • Four wrong references must report 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-batch process, within pixel_aot_title_loads_(warp|hardware).
  • The x2 program is added to the LLVM round-trip fixtures.
  • 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 d54443e4 the only change in tools/pixel_aot.py is a line break in a comment, and the tests only gained the borrow case.

Mutant Killed by
swap_words (helper returns the words swapped) draw-title-loads, WARP
miss_second_zero (second word of a miss is 0, not 0xdeadbeef) draw-title-loads, WARP
carry_dropped (carry of the low-word add dropped in the x2 helper) draw-title-loads, WARP
second_word_vector_wrong (second word bound to the wrong register) draw-title-loads, WARP
borrow ignored in the x2 helper draw-title-loads, WARP, case 7 (negative offset, QWORD across 2^32); it survives without that case
overlap check on the last destination register only default check (check_title_load_x2_controls)
VGPR limit 254 instead of 255 default check
QWORD load does not advance the vmcnt counter default check

Verification

Commit under test: d54443e4. Windows 11 build 26300.9974, Debug build, dxc 1.9.2602.17.

python -B tests/pixel_aot_check.py
ctest --preset dev --no-tests=error -R '^pixel_aot_title_loads_(warp|hardware)$' -V -j1
  • Default check: exit 0.
  • 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_check enables the D3D12 debug layer when it is available, and other runs of the same renderer on this machine print debug_layer=enabled. In --check-pixel-batch a debug-layer error marks the case as error, so a passing batch had no debug-layer errors.

Limits

  • Hardware evidence is NVIDIA (RTX 3070 Ti) and WARP only. No AMD adapter.
  • The LLVM 15 round trip was not run locally; the CI job pixel-binary runs it.
  • A QWORD address aligned to 4 but not to 8 is accepted, because TitleLookup requires only 4-byte alignment. This is not a measurement of the console.
  • The straddle case is a miss by the TitleLookup contract, not a statement about how the console resolves a QWORD across two allocations.
  • A skip (77) is not a pass.
  • The pull-request CI job (ctest --preset pr) does not select pixel_aot_title_loads_*, so the draw runs above are local.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6607033893 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2386). Originally posted by [Makto94](https://github.com/Makto94) on 2026-11-25T14:41:21Z. --- Refs #319 ## Problem `tools/pixel_aot.py` lowers `flat_load_dword` and the `off` form of `global_load_dword` through `TitleLookup` (#694), but refuses the two-DWORD forms. A shader that loads a 64-bit value with `flat_load_dwordx2` or `global_load_dwordx2` cannot be translated. ## Change - `flat_load_dwordx2 v[d:d+1], v[a:b] [offset:N]` (only with `flat_global_only=True`, like `flat_load_dword`) and `global_load_dwordx2 v[d:d+1], v[a:b], off [offset:N]` lower to `title_load_dwordx2`. It calls `TitleLookup(..., 8, ...)` and reads the aliased buffer with `Load2`. - Address, offset ranges, profile and `vmcnt` accounting are the same as for the DWORD forms. Both destination words stay outstanding until a covering wait, and the QWORD counts as one load in `vmcnt`. - A QWORD that does not lie inside one range, including one that straddles two adjacent ranges, reads `0xdeadbeef` in both words. This follows the contract written in `src/title_va_lookup.hlsli`: a lookup succeeds only when the whole access lies inside one range. `git grep "TitleLookup("` in `tools`, `src` and `tests` finds only 4-byte callers before this change, so this is the first 8-byte caller. The choice is isolated in the `title_load_dwordx2` helper 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. - The helper is emitted only when a program uses it, so DWORD-only output is unchanged. - Still refused: x3, x4, `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 of `check_controls`): translation shape, the 8-byte lookup, one helper, DWORD output unchanged, the refused forms above, register-pair and offset errors, `vmcnt` readiness of both words, overlap with a DWORD load in flight, the `v[254:255]` pair in both segments, and a partial `vmcnt(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 at `0x2_0000_1000` and 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. - Four wrong references must report `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-batch` process, within `pixel_aot_title_loads_(warp|hardware)`. - The x2 program is added to the LLVM round-trip fixtures. - `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 `d54443e4` the only change in `tools/pixel_aot.py` is a line break in a comment, and the tests only gained the borrow case. | Mutant | Killed by | |---|---| | `swap_words` (helper returns the words swapped) | `draw-title-loads`, WARP | | `miss_second_zero` (second word of a miss is 0, not `0xdeadbeef`) | `draw-title-loads`, WARP | | `carry_dropped` (carry of the low-word add dropped in the x2 helper) | `draw-title-loads`, WARP | | `second_word_vector_wrong` (second word bound to the wrong register) | `draw-title-loads`, WARP | | borrow ignored in the x2 helper | `draw-title-loads`, WARP, case 7 (negative offset, QWORD across 2^32); it survives without that case | | overlap check on the last destination register only | default check (`check_title_load_x2_controls`) | | VGPR limit 254 instead of 255 | default check | | QWORD load does not advance the `vmcnt` counter | default check | ## Verification Commit under test: `d54443e4`. Windows 11 build 26300.9974, Debug build, dxc 1.9.2602.17. ```powershell python -B tests/pixel_aot_check.py ctest --preset dev --no-tests=error -R '^pixel_aot_title_loads_(warp|hardware)$' -V -j1 ``` - Default check: exit 0. - `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_check` enables the D3D12 debug layer when it is available, and other runs of the same renderer on this machine print `debug_layer=enabled`. In `--check-pixel-batch` a debug-layer error marks the case as `error`, so a passing batch had no debug-layer errors. ## Limits - Hardware evidence is NVIDIA (RTX 3070 Ti) and WARP only. No AMD adapter. - The LLVM 15 round trip was not run locally; the CI job `pixel-binary` runs it. - A QWORD address aligned to 4 but not to 8 is accepted, because `TitleLookup` requires only 4-byte alignment. This is not a measurement of the console. - The straddle case is a miss by the `TitleLookup` contract, not a statement about how the console resolves a QWORD across two allocations. - A skip (77) is not a pass. - The pull-request CI job (`ctest --preset pr`) does not select `pixel_aot_title_loads_*`, so the draw runs above are local.
upstream-sync closed this pull request 2026-11-25 16:05:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2378
No description provided.