shader: lower s_load_dword and s_load_dwordx2 descriptor fetches in pixel_aot #903

Merged
rasptum merged 1 commit from upstream-pr/910 into main 2026-11-23 17:09:42 +00:00
rasptum commented 2026-11-23 16:49:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T16:49:48Z.


Claim: GPU VA / descriptor milestone (issue #132 bucket). Interface: tools/pixel_aot.py lower(..., pointer_constants=...) and the CLI --pointer-constant SGPR POINTER_OFFSET DWORDS OFFSET. There is no open SMEM issue, so the claim is here.

What changes

pixel_aot now lowers s_load_dword and s_load_dwordx2 when they fetch a table pointer that a later s_load_dwordx4 uses to reach a constant-buffer descriptor in a nested table.

  • New contract pointer_constants: entries of (entry SGPR, pointer byte offset, pointer dwords 1|2, descriptor byte offset). The parent table is named as in extra_constants. Entries map in order to the cbuffer slots after the extra_constants ones, as uint4 under the integer export and float4 otherwise.
  • s_load_dwordx2 reads a 2-dword pointer as a full 64-bit address. The descriptor fetch must use the loaded high word unchanged. s_load_dword reads a 1-dword pointer (the low word). The program must then set the high word to a tracked zero.
  • Both forms use the existing scalar-load completion model. The destination SGPRs stay outstanding until s_waitcnt lgkmcnt(0). No new lowering table is added: the existing s_load_dwordx4 descriptor branch accepts the new table marker.
  • Fail closed: a pointer offset or width the contract does not name, a descriptor offset not named for that pointer, an address that is itself a loaded pointer, a pointer used as a numeric operand or as a texture table, an SGPR offset operand, glc/dlc, odd or out-of-range destination pairs, and contracts whose pointer overlaps another pointer, a constant descriptor or a texture descriptor in the same table.
  • write_case in tests/pixel_aot_check.py may now combine the extra-buffer flag (bit 3) with the integer render-target flag (bit 0). The renderer already accepted that combination; it needed no C++ change.

SMEM coverage: s_load_dword and s_load_dwordx2 join s_load_dwordx4, s_load_dwordx8 and the three s_buffer_load_dword{,x2,x4} forms. The new CTest records them through FORM_COVERAGE_RECORD.

Tests

New CTest pixel_aot_smem_pointers_{warp,hardware} (tests/pixel_aot_check.py draw-smem-pointers). It reads b1 word 2 through a 64-bit pointer and b2 words 5 and 6 through a 32-bit pointer, plus b0 word 3. All reads go through R32G32B32A32_UINT and are compared bit for bit. Every other buffer word is a sentinel naming its buffer and index. The two word sets include a quiet NaN payload, a binary32 denormal, negative zero, all ones and zero.

Negative controls, each verified as a reported mismatch:

  • a reference with b1 and b2 exchanged;
  • a reference expecting the b0 sentinel;
  • a translation with the two contract entries exchanged (it also passes against the exchanged reference);
  • a translation reading b1 word 3 in place of word 2.

The CPU controls (check_smem_pointer_controls, run in every mode) cover the refusals listed above, among them mutated descriptor offsets, mutated or unaligned pointer offsets, width swaps, a missing wait, a missing or clobbered high word, and contract overlaps. The fixture is also part of the LLVM binary round trip.

Results

Commit 2137118 (rebased on ca0cc0e). Windows 10 Pro 19045.6466, D3D12 debug layer enabled (debug_layer=enabled on both backends). WARP: Microsoft Basic Render Driver, d3d10warp.dll 10.0.19041.5794. Hardware: NVIDIA GeForce RTX 3060, driver 32.0.15.9636. DXC from Windows SDK 10.0.26100.0.

cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^pixel_aot_smem_pointers_' -V
cmake --build --preset release
ctest --preset release --no-tests=error -R '^pixel_aot_smem_pointers_' -V
Preset pixel_aot_smem_pointers_warp pixel_aot_smem_pointers_hardware
dev Passed Passed
release Passed Passed

No capability skips.

Regression run ctest --preset {dev,release} --no-tests=error -R '^pixel_aot_' -j 3: 96 of 98 pass on both presets, no skips. The two failures are pixel_aot_blend_scalar_hardware (channel 0 3fa04000 vs 3fa0c000 on the RTX 3060) and pixel_aot_title_loads_warp. Both fail the same way with the base commit's Python files (fc89b9e) against the same renderer, so they predate this change. They are not touched here.

Python and binary checks on 2137118:

python -B tests/pixel_aot_check.py                 # exit 0
python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <libLLVM>   # exit 0
python -B tests/form_coverage_check.py             # exit 0
python -B tests/docs_links_check.py                # exit 0
python -B tests/bidi_controls_check.py             # exit 0

Binary mode ran locally with LLVM 15.0.7 on Windows: clang --target=amdgcn--amdpal -x assembler stood in for llvm-mc, with -mattr=±wavefrontsize64 mapped to -m[no-]wavefrontsize64, plus llvm-objcopy.exe and LLVM-C.dll.

docs/experiments.md documents the contract, the refusals and the measured result next to the three-buffers fixture.

Scope: these are explicit desktop bindings supplied by the caller. The translator does not infer how a title lays out nested tables. This does not establish title startup or execution.

Overlap: checked against the 29 open PRs on 2026-11-23, right before pushing (pr_overlap_check.py --auto plus the opcode, contract and CTest names). No overlap, and the branch is current with main.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6564256771 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/910). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T16:49:48Z. --- Claim: GPU VA / descriptor milestone (issue #132 bucket). Interface: `tools/pixel_aot.py` `lower(..., pointer_constants=...)` and the CLI `--pointer-constant SGPR POINTER_OFFSET DWORDS OFFSET`. There is no open SMEM issue, so the claim is here. ## What changes `pixel_aot` now lowers `s_load_dword` and `s_load_dwordx2` when they fetch a table pointer that a later `s_load_dwordx4` uses to reach a constant-buffer descriptor in a nested table. - New contract `pointer_constants`: entries of (entry SGPR, pointer byte offset, pointer dwords 1|2, descriptor byte offset). The parent table is named as in `extra_constants`. Entries map in order to the cbuffer slots after the `extra_constants` ones, as `uint4` under the integer export and `float4` otherwise. - `s_load_dwordx2` reads a 2-dword pointer as a full 64-bit address. The descriptor fetch must use the loaded high word unchanged. `s_load_dword` reads a 1-dword pointer (the low word). The program must then set the high word to a tracked zero. - Both forms use the existing scalar-load completion model. The destination SGPRs stay outstanding until `s_waitcnt lgkmcnt(0)`. No new lowering table is added: the existing `s_load_dwordx4` descriptor branch accepts the new table marker. - Fail closed: a pointer offset or width the contract does not name, a descriptor offset not named for that pointer, an address that is itself a loaded pointer, a pointer used as a numeric operand or as a texture table, an SGPR offset operand, `glc`/`dlc`, odd or out-of-range destination pairs, and contracts whose pointer overlaps another pointer, a constant descriptor or a texture descriptor in the same table. - `write_case` in `tests/pixel_aot_check.py` may now combine the extra-buffer flag (bit 3) with the integer render-target flag (bit 0). The renderer already accepted that combination; it needed no C++ change. SMEM coverage: `s_load_dword` and `s_load_dwordx2` join `s_load_dwordx4`, `s_load_dwordx8` and the three `s_buffer_load_dword{,x2,x4}` forms. The new CTest records them through `FORM_COVERAGE_RECORD`. ## Tests New CTest `pixel_aot_smem_pointers_{warp,hardware}` (`tests/pixel_aot_check.py draw-smem-pointers`). It reads `b1` word 2 through a 64-bit pointer and `b2` words 5 and 6 through a 32-bit pointer, plus `b0` word 3. All reads go through `R32G32B32A32_UINT` and are compared bit for bit. Every other buffer word is a sentinel naming its buffer and index. The two word sets include a quiet NaN payload, a binary32 denormal, negative zero, all ones and zero. Negative controls, each verified as a reported mismatch: - a reference with `b1` and `b2` exchanged; - a reference expecting the `b0` sentinel; - a translation with the two contract entries exchanged (it also passes against the exchanged reference); - a translation reading `b1` word 3 in place of word 2. The CPU controls (`check_smem_pointer_controls`, run in every mode) cover the refusals listed above, among them mutated descriptor offsets, mutated or unaligned pointer offsets, width swaps, a missing wait, a missing or clobbered high word, and contract overlaps. The fixture is also part of the LLVM binary round trip. ## Results Commit `2137118` (rebased on `ca0cc0e`). Windows 10 Pro 19045.6466, D3D12 debug layer enabled (`debug_layer=enabled` on both backends). WARP: Microsoft Basic Render Driver, `d3d10warp.dll` 10.0.19041.5794. Hardware: NVIDIA GeForce RTX 3060, driver 32.0.15.9636. DXC from Windows SDK 10.0.26100.0. ```powershell cmake --build --preset dev ctest --preset dev --no-tests=error -R '^pixel_aot_smem_pointers_' -V cmake --build --preset release ctest --preset release --no-tests=error -R '^pixel_aot_smem_pointers_' -V ``` | Preset | `pixel_aot_smem_pointers_warp` | `pixel_aot_smem_pointers_hardware` | |---|---|---| | dev | Passed | Passed | | release | Passed | Passed | No capability skips. Regression run `ctest --preset {dev,release} --no-tests=error -R '^pixel_aot_' -j 3`: 96 of 98 pass on both presets, no skips. The two failures are `pixel_aot_blend_scalar_hardware` (channel 0 `3fa04000` vs `3fa0c000` on the RTX 3060) and `pixel_aot_title_loads_warp`. Both fail the same way with the base commit's Python files (`fc89b9e`) against the same renderer, so they predate this change. They are not touched here. Python and binary checks on `2137118`: ```bash python -B tests/pixel_aot_check.py # exit 0 python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <libLLVM> # exit 0 python -B tests/form_coverage_check.py # exit 0 python -B tests/docs_links_check.py # exit 0 python -B tests/bidi_controls_check.py # exit 0 ``` Binary mode ran locally with LLVM 15.0.7 on Windows: `clang --target=amdgcn--amdpal -x assembler` stood in for `llvm-mc`, with `-mattr=±wavefrontsize64` mapped to `-m[no-]wavefrontsize64`, plus `llvm-objcopy.exe` and `LLVM-C.dll`. `docs/experiments.md` documents the contract, the refusals and the measured result next to the `three-buffers` fixture. Scope: these are explicit desktop bindings supplied by the caller. The translator does not infer how a title lays out nested tables. This does not establish title startup or execution. Overlap: checked against the 29 open PRs on 2026-11-23, right before pushing (`pr_overlap_check.py --auto` plus the opcode, contract and CTest names). No overlap, and the branch is current with `main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:45:21 +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!903
No description provided.