shader: lower flat and global dwordx3 loads in pixel AOT #3687

Manually merged
github merged 1 commit from github-bot/gh-3685 into gh-pr/3685/base 2026-12-01 08:53:12 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-01 01:38 UTC · original
timbot103:shader-pixel-dwordx3-loads → main · +159 −23 · 4 files · 1 commits · merged 2026-12-01 08:49 UTC

Lower flat_load_dwordx3 and global_load_dwordx3 ... off on the pixel title alias-table profile. FLAT requires flat_global_only=True. The caller guarantees that effective FLAT addresses exclude the scratch and LDS apertures.

Each load makes one 12-byte TitleLookup request and reads the matching alias with Load3. A miss returns 0xdeadbeef in all three destinations. The three destinations share one vmcnt operation. The existing title-load fixture checks three distinct words in order, preservation of the fourth output, offset carry and borrow, and misses in all three words for holes and one- or two-word straddles. It follows #2386 and #2419.

Refs #319

Verification

Run the commands from the repository root. The red runs used a3bfd019 with the new fixtures and the original lowering. The green and mutation runs used commit a2ca1113.

.\tools\dev.ps1
cmake --preset dev
cmake --build --preset dev --target offscreen_check
cmake --preset release
cmake --build --preset release --target offscreen_check

The two configurations and focused builds passed. Release uses /O2.

Red then green

python -B tests/pixel_aot_check.py
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V --output-junit "$PWD/out/dwx3-followup/coverage-red.xml"
ctest --preset release --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V
wsl -d Ubuntu-24.04 -- python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

All four red checks failed with Unsupported instruction 23: flat_load_dwordx3 v[12:14], v[20:21] offset:2036. The binary check stopped at the shared controls. The Python controls, Release WARP, and LLVM 15 round trip then passed with the lowering. The LLVM checks used the CI runner with the pixel entry and argv shown above. The passing dev WARP command is in the coverage sequence below.

The x3 fixture covers 19 shader and address cases in 35 draws. Each nonzero-offset shader runs nine cases and four deliberate mismatches, each followed by a passing replay. One zero-offset FLAT draw at 0x2_0000_0000 checks that equality does not cause a carry. The Python controls also check that vmcnt(2) leaves the older DWORD pending in both segments and that x3 followed by x2 emits both helpers.

Coverage

Run the baseline block at a3bfd019 with its original test and lowering. Read both reports before running CTest on the branch. CTest writes the fixture record to the same path in both blocks.

ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V --output-junit "$PWD/out/dwx3-followup/coverage-baseline.xml"
python -B tools/form_coverage.py out/dwx3-followup/coverage-baseline.xml --records out/build/dev/form_coverage --gaps gfx1013
python -B tools/form_coverage.py out/dwx3-followup/coverage-baseline.xml --records out/build/dev/form_coverage --gaps gfx1030

Run this block on the branch.

ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V --output-junit "$PWD/out/dwx3-followup/coverage-green.xml"
python -B tools/form_coverage.py out/dwx3-followup/coverage-green.xml --records out/build/dev/form_coverage --gaps gfx1013
python -B tools/form_coverage.py out/dwx3-followup/coverage-green.xml --records out/build/dev/form_coverage --gaps gfx1030
rg --crlf '^(flat|global)_load_dwordx3$' out/build/dev/form_coverage/pixel_aot_title_loads_warp.txt

Both CTest runs passed 1/1. All four coverage commands exited 0. Output filtered to the two x3 forms follows.

baseline gfx1013 x3 gap rows:
FLAT	flat_load_dwordx3	unobserved
FLAT	global_load_dwordx3	unobserved
baseline gfx1030 x3 gap rows:
FLAT	flat_load_dwordx3	unobserved
FLAT	global_load_dwordx3	unobserved
green gfx1013 x3 gap rows:
(none)
green gfx1030 x3 gap rows:
(none)
green fixture record:
flat_load_dwordx3
global_load_dwordx3

This measures recorded coverage from the selected fixture for both ISA inventories. The LLVM 15 fixtures assemble for gfx1013.

WARP and physical GPU readback

Ran locally on this branch. Run the two hardware commands from a PowerShell session initialized by .\tools\dev.ps1.

$env:XBOX2WINDOWS_ADAPTER = 'RTX 5080'
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_hardware$' -V
$env:XBOX2WINDOWS_ADAPTER = 'Radeon'
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_hardware$' -V
Preset and adapter Driver CTest Draws Matches Expected mismatches
dev Microsoft WARP 10.0.26100.9818 1/1 (10.70 s) 126 94 32
Release Microsoft WARP 10.0.26100.9818 1/1 (5.56 s) 126 94 32
dev NVIDIA GeForce RTX 5080 (10de:2c02) 32.0.16.2140 (621.40) 1/1 (17.70 s) 126 94 32
dev AMD Radeon Graphics (1002:13c0) 32.0.21030.2001 1/1 (7.25 s) 126 94 32

Each run had zero draw errors and zero capability skips. The D3D12 debug layer was unavailable on this host.

Mutations

Each row is an independent edit to tools/pixel_aot.py. The clean checks passed before and after the edits.

python -B tests/pixel_aot_check.py
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V
Edit Python Dev WARP Observation
L796, address, 12, slot → address, 8, slot Fail Fail Width assertion and readback mismatches for the two-word straddles into a range or hole.
L799, Load3(byteOffset); → Load3(byteOffset).zyx; Pass Fail Reversed words in positive readbacks.
L797, uint3({miss:#x}u, {miss:#x}u, {miss:#x}u) → uint3({miss:#x}u, {miss:#x}u, 0u) Pass Fail Third word differs in miss readbacks.
L6166, title_loads_x3 |= count == 3 → title_loads_x3 = False Fail DXC error Python detects the missing definition.
L793, remove + (low < base.x ? 1u : 0u) Pass Fail Readback differs when the low address word carries.
L6166, title_loads_x3 |= count == 3 → if count == 3: title_loads_x3 = True; dests.append(f"v{int(dests[-1][1:]) + 1}"); values.append(values[-1]) Fail Fail The extra pending destination and changed fourth output are detected.
L793, low < base.x → low <= base.x Pass Fail Zero-offset FLAT case returns a readback mismatch at 0x2_0000_0000.
L6166, title_loads_x3 |= count == 3 → title_loads_x3 = count == 3 Fail Pass The mixed x3 and x2 program loses its x3 helper.
L6166, title_loads_x3 |= count == 3 → if count == 3: title_loads_x3 = True; vector_loads += 2 Fail Pass vmcnt(2) wrongly makes the older DWORD readable.

Neighboring checks

ctest --preset dev --no-tests=error -j 1 -R '^(gpu_alias_lookup|pixel_aot_(region_waits|flat_scratch|smem_pointers|uncompressed_integer_export))_warp$' -V
out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
git diff HEAD^ HEAD --check

All five neighboring WARP tests, Python coverage checks, and documentation link checks passed. Git reported no whitespace errors.

Environment

  • Windows 11 25H2 build 26200.9974, MSVC 19.44.35230, Windows SDK 10.0.26100.0, DXC 1.9.2602.17, and Python 3.14.7.
  • WSL Ubuntu 24.04, LLVM 15.0.7, and Python 3.12.3.
  • Desktop readback used the synthetic fixed-range fixture. Native console address behavior remains unverified.

Prepared with AI assistance; all commands above were run locally.

**@⁠timbot103** on GitHub · 2026-12-01 01:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3685) `timbot103:shader-pixel-dwordx3-loads` → `main` · +159 −23 · 4 files · 1 commits · merged 2026-12-01 08:49 UTC Lower `flat_load_dwordx3` and `global_load_dwordx3 ... off` on the pixel title alias-table profile. FLAT requires `flat_global_only=True`. The caller guarantees that effective FLAT addresses exclude the scratch and LDS apertures. Each load makes one 12-byte `TitleLookup` request and reads the matching alias with `Load3`. A miss returns `0xdeadbeef` in all three destinations. The three destinations share one `vmcnt` operation. The existing title-load fixture checks three distinct words in order, preservation of the fourth output, offset carry and borrow, and misses in all three words for holes and one- or two-word straddles. It follows #2386 and #2419. Refs #319 ## Verification Run the commands from the repository root. The red runs used `a3bfd019` with the new fixtures and the original lowering. The green and mutation runs used commit `a2ca1113`. ```powershell .\tools\dev.ps1 cmake --preset dev cmake --build --preset dev --target offscreen_check cmake --preset release cmake --build --preset release --target offscreen_check ``` The two configurations and focused builds passed. Release uses `/O2`. ### Red then green ```powershell python -B tests/pixel_aot_check.py ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V --output-junit "$PWD/out/dwx3-followup/coverage-red.xml" ctest --preset release --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V wsl -d Ubuntu-24.04 -- python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` All four red checks failed with `Unsupported instruction 23: flat_load_dwordx3 v[12:14], v[20:21] offset:2036`. The binary check stopped at the shared controls. The Python controls, Release WARP, and LLVM 15 round trip then passed with the lowering. The LLVM checks used the CI runner with the pixel entry and argv shown above. The passing dev WARP command is in the coverage sequence below. The x3 fixture covers 19 shader and address cases in 35 draws. Each nonzero-offset shader runs nine cases and four deliberate mismatches, each followed by a passing replay. One zero-offset FLAT draw at `0x2_0000_0000` checks that equality does not cause a carry. The Python controls also check that `vmcnt(2)` leaves the older DWORD pending in both segments and that x3 followed by x2 emits both helpers. ### Coverage Run the baseline block at `a3bfd019` with its original test and lowering. Read both reports before running CTest on the branch. CTest writes the fixture record to the same path in both blocks. ```powershell ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V --output-junit "$PWD/out/dwx3-followup/coverage-baseline.xml" python -B tools/form_coverage.py out/dwx3-followup/coverage-baseline.xml --records out/build/dev/form_coverage --gaps gfx1013 python -B tools/form_coverage.py out/dwx3-followup/coverage-baseline.xml --records out/build/dev/form_coverage --gaps gfx1030 ``` Run this block on the branch. ```powershell ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V --output-junit "$PWD/out/dwx3-followup/coverage-green.xml" python -B tools/form_coverage.py out/dwx3-followup/coverage-green.xml --records out/build/dev/form_coverage --gaps gfx1013 python -B tools/form_coverage.py out/dwx3-followup/coverage-green.xml --records out/build/dev/form_coverage --gaps gfx1030 rg --crlf '^(flat|global)_load_dwordx3$' out/build/dev/form_coverage/pixel_aot_title_loads_warp.txt ``` Both CTest runs passed 1/1. All four coverage commands exited 0. Output filtered to the two x3 forms follows. ```text baseline gfx1013 x3 gap rows: FLAT flat_load_dwordx3 unobserved FLAT global_load_dwordx3 unobserved baseline gfx1030 x3 gap rows: FLAT flat_load_dwordx3 unobserved FLAT global_load_dwordx3 unobserved green gfx1013 x3 gap rows: (none) green gfx1030 x3 gap rows: (none) green fixture record: flat_load_dwordx3 global_load_dwordx3 ``` This measures recorded coverage from the selected fixture for both ISA inventories. The LLVM 15 fixtures assemble for gfx1013. ### WARP and physical GPU readback Ran locally on this branch. Run the two hardware commands from a PowerShell session initialized by `.\tools\dev.ps1`. ```powershell $env:XBOX2WINDOWS_ADAPTER = 'RTX 5080' ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_hardware$' -V $env:XBOX2WINDOWS_ADAPTER = 'Radeon' ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_hardware$' -V ``` | Preset and adapter | Driver | CTest | Draws | Matches | Expected mismatches | | --- | --- | --- | --- | --- | --- | | dev Microsoft WARP | 10.0.26100.9818 | 1/1 (10.70 s) | 126 | 94 | 32 | | Release Microsoft WARP | 10.0.26100.9818 | 1/1 (5.56 s) | 126 | 94 | 32 | | dev NVIDIA GeForce RTX 5080 (10de:2c02) | 32.0.16.2140 (621.40) | 1/1 (17.70 s) | 126 | 94 | 32 | | dev AMD Radeon Graphics (1002:13c0) | 32.0.21030.2001 | 1/1 (7.25 s) | 126 | 94 | 32 | Each run had zero draw errors and zero capability skips. The D3D12 debug layer was unavailable on this host. ### Mutations Each row is an independent edit to `tools/pixel_aot.py`. The clean checks passed before and after the edits. ```powershell python -B tests/pixel_aot_check.py ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_title_loads_warp$' -V ``` | Edit | Python | Dev WARP | Observation | | --- | --- | --- | --- | | L796, `address, 12, slot` → `address, 8, slot` | Fail | Fail | Width assertion and readback mismatches for the two-word straddles into a range or hole. | | L799, `Load3(byteOffset);` → `Load3(byteOffset).zyx;` | Pass | Fail | Reversed words in positive readbacks. | | L797, `uint3({miss:#x}u, {miss:#x}u, {miss:#x}u)` → `uint3({miss:#x}u, {miss:#x}u, 0u)` | Pass | Fail | Third word differs in miss readbacks. | | L6166, `title_loads_x3 \|= count == 3` → `title_loads_x3 = False` | Fail | DXC error | Python detects the missing definition. | | L793, remove ` + (low < base.x ? 1u : 0u)` | Pass | Fail | Readback differs when the low address word carries. | | L6166, `title_loads_x3 \|= count == 3` → `if count == 3: title_loads_x3 = True; dests.append(f"v{int(dests[-1][1:]) + 1}"); values.append(values[-1])` | Fail | Fail | The extra pending destination and changed fourth output are detected. | | L793, `low < base.x` → `low <= base.x` | Pass | Fail | Zero-offset FLAT case returns a readback mismatch at `0x2_0000_0000`. | | L6166, `title_loads_x3 \|= count == 3` → `title_loads_x3 = count == 3` | Fail | Pass | The mixed x3 and x2 program loses its x3 helper. | | L6166, `title_loads_x3 \|= count == 3` → `if count == 3: title_loads_x3 = True; vector_loads += 2` | Fail | Pass | `vmcnt(2)` wrongly makes the older DWORD readable. | ### Neighboring checks ```powershell ctest --preset dev --no-tests=error -j 1 -R '^(gpu_alias_lookup|pixel_aot_(region_waits|flat_scratch|smem_pointers|uncompressed_integer_export))_warp$' -V out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py python -B tests/docs_links_check.py git diff HEAD^ HEAD --check ``` All five neighboring WARP tests, Python coverage checks, and documentation link checks passed. Git reported no whitespace errors. ### Environment - Windows 11 25H2 build 26200.9974, MSVC 19.44.35230, Windows SDK 10.0.26100.0, DXC 1.9.2602.17, and Python 3.14.7. - WSL Ubuntu 24.04, LLVM 15.0.7, and Python 3.12.3. - Desktop readback used the synthetic fixed-range fixture. Native console address behavior remains unverified. Prepared with AI assistance; all commands above were run locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 01:43:45 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-01 02:33 UTC · original · approved these changes

Reviewed a2ca1113 by reading the diff; not built or run.

Verdict: approve. The x3 lowering follows the existing x2/x4 path exactly. No MUST, no SHOULD.

  • Checked, no finding:
    • TITLE_MEMORY_X3 (tools/pixel_aot.py:789) matches the x2/x4 helpers: the same carry into the high word, one 12-byte TitleLookup, a three-word miss, and Load3. TitleLookup already accepts any size that is a multiple of 4 and refuses a misaligned address (src/title_va_lookup.hlsli:35), so 12 needs no change there.
    • The destination width goes through registers(..., 3), so v[12:13] and v[12:15] are refused as a width mismatch. The mask != "entry", VGPR ≤ 255 and pending-destination guards apply unchanged.
    • The three words share one vector_loads issue. The vmcnt(1)/vmcnt(2) controls show that the older DWORD retires first and that all three x3 words stay pending until the wait.
    • Cache-policy bits, saddr, lds, a missing or misplaced off, and offsets just outside the 11-bit FLAT / 12-bit signed GLOBAL ranges stay refused. The x3 entries were removed from the old neighbour lists, not left behind as stale refusals.
    • The docs row and the experiments.md paragraph match the code (flat_global_only, one issue, all-or-nothing miss).

Tests: check_title_load_x3_controls proves the helper text, the profile and offset refusals, the width checks and the vmcnt ordering. The x3 fixtures prove the words on WARP: first and last word of a range, one- and two-word straddles, holes, and carry/borrow across the 32-bit boundary, with planted wrong references. CI ran pixel_aot_check.py at this head (windows.yml:50). The pixel_aot_title_loads_warp / _hardware draws are outside the pr filter. They rest on the author's local WARP, RTX 5080 and Radeon runs.

**@⁠lukaslw-lab** on GitHub · 2026-12-01 02:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3685#pullrequestreview-6124148769) · **approved these changes** Reviewed `a2ca1113` by reading the diff; not built or run. **Verdict: approve.** The x3 lowering follows the existing x2/x4 path exactly. No MUST, no SHOULD. - Checked, no finding: - `TITLE_MEMORY_X3` (`tools/pixel_aot.py:789`) matches the x2/x4 helpers: the same carry into the high word, one 12-byte `TitleLookup`, a three-word miss, and `Load3`. `TitleLookup` already accepts any size that is a multiple of 4 and refuses a misaligned address (`src/title_va_lookup.hlsli:35`), so 12 needs no change there. - The destination width goes through `registers(..., 3)`, so `v[12:13]` and `v[12:15]` are refused as a width mismatch. The `mask != "entry"`, VGPR ≤ 255 and pending-destination guards apply unchanged. - The three words share one `vector_loads` issue. The `vmcnt(1)`/`vmcnt(2)` controls show that the older DWORD retires first and that all three x3 words stay pending until the wait. - Cache-policy bits, saddr, `lds`, a missing or misplaced `off`, and offsets just outside the 11-bit FLAT / 12-bit signed GLOBAL ranges stay refused. The x3 entries were removed from the old neighbour lists, not left behind as stale refusals. - The docs row and the `experiments.md` paragraph match the code (`flat_global_only`, one issue, all-or-nothing miss). Tests: `check_title_load_x3_controls` proves the helper text, the profile and offset refusals, the width checks and the vmcnt ordering. The x3 fixtures prove the words on WARP: first and last word of a range, one- and two-word straddles, holes, and carry/borrow across the 32-bit boundary, with planted wrong references. CI ran `pixel_aot_check.py` at this head (`windows.yml:50`). The `pixel_aot_title_loads_warp` / `_hardware` draws are outside the `pr` filter. They rest on the author's local WARP, RTX 5080 and Radeon runs.
github-bot changed target branch from main to gh-pr/3685/base 2026-12-01 08:53:11 +00:00
github manually merged commit a2ca111387 into gh-pr/3685/base 2026-12-01 08:53:12 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.